Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: QuickDraw GX Environment and Utilities /
Chapter 1 - QuickDraw GX and the Macintosh Environment / Using the QuickDraw-to-QuickDraw GX Translator


Factors in Translation

This section describes some of the factors that influence the translation process, and how you can manipulate them.

Graphics Port and View Port

The translation from QuickDraw to QuickDraw GX takes into account the current QuickDraw grafPort origin. Therefore, each resulting QuickDraw GX shape incorporates, either in its shape geometry or in its transform mapping, the origin of the graphics port that was active at the time of translation.

The QuickDraw GX shape that results from the translation must be associated with a view port. This can be accomplished by

Scaling During Translation

The translator allows you to scale the QuickDraw data as it is converted. For example, you can use scaling to convert from a screen resolution of 72 dpi to a printer resolution of 300 dpi. You specify the scaling factor in the form of source and destination rectangles.

Also, in order to allow the translator to properly scale dash picture comments and other items, you can supply a pair of integer scale factors, which may be different in the x and y directions. The scale factors for both the source and destination rectangles and the pattern-stretch parameters are usually the destination resolution divided by the screen resolution (72 dpi), rounded to the nearest integer. Typical examples are shown in
Table 1-1.
Table 1-1 Translation scaling factors
SourceDestinationScale Factor
72 7272 721 1
72 7272 801 1
72 72144 1442 2
72 72150 1502 2
72 72300 3004 4

Translation Options

When you translate QuickDraw data to QuickDraw GX shapes, you specify one or more translation options. You can use either the default translation option provided by QuickDraw GX or a combination of the other available options. Some translation options provide simpler and faster translations, but with a resulting loss of pixel-for-pixel matching. Table 1-2 lists and describes the available translation options; the constants are defined in the gxTranslationOptions enumeration.
Table 1-2 Translation options settings
ConstantValueExplanation
gxDefaultOptionsTranslation0x0000This is the default setting used for translation. This option generates the most accurate representation of the QuickDraw data that the translator is capable of producing.
gxOptimizedTranslation0x0001This option allows for optimizations to be applied during translation. For example, a sequence of QuickDraw lines can be combined into one polygon. In most cases, this results in the generation of a smaller number of QuickDraw GX shapes.
gxReplaceLineWidthTranslation0x0002The width of a resulting QuickDraw GX line is the average of the original pen's width and height. This option also affects the way in which the SetLineWidth PicComment is interpreted. The LaserWriter driver scales the current line width with the newly specified picture comment. The translator normally uses the LaserWriter mechanism. When you specify this option, the translator uses a mechanism in which the line is replaced with the newly specified width; this mimics the behavior of the LaserWriter SC driver.
gxSimpleScalingTranslation0x0004This option causes the translator to scale data from source resolution to destination resolution by using a simple multiplication, which is incorporated into the shape's transform. The translator makes no attempt to compensate for this increase in resolution. The resulting scaled image will not render the original QuickDraw data accurately, but will be similar to what QuickDraw would have produced when it attempted to scale the data.
gxSimpleGeometryTranslation0x0008This option results in a translation of QuickDraw data without taking into account the QuickDraw hanging pen. Normally the translator reproduces a QuickDraw triangle, for example, as a 6-sided or 7-sided polygon. This option sacrifices accuracy in order to produce an image that draws faster with QuickDraw GX and can be more useful for pen-based output devices. For example, QuickDraw lines become QuickDraw GX lines with flat endcaps. This option also turns on the simple lines translation and the simple scaling translation.
gxSimpleLinesTranslation0x000CThis option results in simple geometry and scaling. The translator maintains the width of lines that are at an angle. Because QuickDraw uses a hanging pen, a diagonal line appears to be thicker than a horizontal or vertical line with the same pen size. Using this option causes the line width to be the same as the pen width, at the expense of the accuracy of the original QuickDraw data. This option also turns on the simple scaling translation and the simple geometry translation.
gxLayoutTextTranslation0x0010Normally the translator turns off layout-shape-specific capabilities when translating QuickDraw text into layout shapes. This option restores layout features such as default glyph substitutions. This results in a more attractive text; however it can be different from the original QuickDraw data.
gxRasterTargetTranslation0x0020This option causes PostScript picture comments to be discarded. The bitmap proxies sent along with such comments are preserved.
gxPostScriptTargetTranslation0x0040This option causes PostScript picture comments to be incorporated as tags attached to picture shapes. The bitmap proxies sent along with such comments are discarded.
gxVectorTargetTranslation0x0080This option causes PostScript picture comments to be discarded. The bitmap proxies sent along with such comments are preserved. Also, when this option is combined with the option gxOptimizedTranslation, lines are preserved and not combined in thick framed polygons.

How Option Settings Affect Translation of Lines

The translation of QuickDraw lines is affected by the translation options setting you choose. Consider the simple line generated by the QuickDraw commands given in Listing 1-2.

Listing 1-2 QuickDraw commands to draw a simple line

PenSize(5, 3);
MoveTo(100, 40);
LineTo(120, 70);
The QuickDraw commands in Listing 1-2 produce the line shown in Figure 1-2.

Figure 1-2 A QuickDraw line[Missing image]

The gxDefaultOptionsTranslation setting produces the best replication of the original QuickDraw picture. However, it is also the slowest translation. If you use the gxDefaultOptionsTranslation setting for the translation of the original QuickDraw line shown in Figure 1-2, the resulting QuickDraw GX polygon shape mimics the QuickDraw hanging pen. Furthermore, any scaling between the source and destination rectangles is incorporated into the translated shape's geometry. The original QuickDraw line would be translated to the QuickDraw GX shape shown in Figure 1-3.

Figure 1-3 Translation of the QuickDraw line using gxDefaultOptionsTranslation[Missing image]

If you use the gxSimpleGeometryTranslation option setting, the resulting QuickDraw GX line shape runs along the center of the original QuickDraw line and covers all the pixels of the QuickDraw line and more; it is a superset. The resulting QuickDraw GX shape looks like the line shape shown in Figure 1-4.

Figure 1-4 Translation of the QuickDraw line using gxSimpleGeometryTranslation[Missing image]

If you use the gxReplaceLineWidthTranslation option setting, the resulting QuickDraw GX line shape has a width that is the average of the QuickDraw pen width and height. The line runs along the center of the original QuickDraw line between the extreme pixels at each end of the original QuickDraw line. The translation results in the QuickDraw GX shape shown in Figure 1-5.

Figure 1-5 Translation of the QuickDraw line using gxReplaceLineWidthTranslation[Missing image]

Translation of Fill Patterns

The QuickDraw-to-QuickDraw GX translator converts those 8-bit 8-bit QuickDraw fill patterns that are commonly used to represent gray patterns to colors that are blends of the foreground and background colors. In the case of QuickDraw black-and-white patterns, a uniform grayscale shade that ranges from 0 to 100 percent black is produced, depending on the overall apparent density of the original pattern, as shown in Figure 1-6.

Figure 1-6 Conversion of standard QuickDraw fill patterns to QuickDraw GX shape fills[Missing image]

Translation of QuickDraw Picture Comments

The capabilities of QuickDraw GX exceed those of QuickDraw. This means that a picture comment (picComment) can be incorporated into the translated shapes as part of the conversion process. With QuickDraw alone, picture comments can only be seen when the picture is printed, because the comments are interpreted at the printer level.

It is common practice for developers to include QuickDraw drawing commands (usually one or more bitmaps) within a picture comment as a proxy that provides an alternate representation of the picture comment. That way, if the picComment is not supported by a printer, some output--although at a lower resolution-- is produced.

When processing a picture comment, the QuickDraw-to-QuickDraw GX translator typically discards the QuickDraw proxy and applies the picComment to the object--for example, by rotating the shape's transform or setting a dash in the shape's style. When processing PostScript picture comments, however, the translator creates a picture shape that contains QuickDraw GX shape objects (based on the QuickDraw proxies) as well as tag objects (containing the PostScript data). In this way, QuickDraw GX can render the picture both on a raster device (by drawing the items in the picture shape) and on a PostScript device (by applying the information in the tag objects).

Sample code for applying a picComment for rotation is shown in Listing 1-3.

Listing 1-3 QuickDraw picture data that includes a picComment

RotComHandle   rInfo = NewHandle(sizeof(RotComRecord));

(*rInfo)->rFlip = 0
(*rInfo)->rAngle = 90;

MoveTo(100,100);
PicComment(RotateBegin, sizeof(RotComRecord), (Handle)rInfo);
LineTo(100, 200);
PicComment(RotateEnd, 0, nil);
The output of the sample code in Listing 1-3 is shown in Figure 1-7. Notice that the QuickDraw screen output is not rotated. This is because QuickDraw picture comments are interpreted by the printer. In contrast, the printed QuickDraw output and the translated QuickDraw GX shape (both printed and displayed onscreen) correctly represent the intent of the original QuickDraw data.

Figure 1-7 Translating QuickDraw data containing a rotation picComment[Missing image]

Translation Statistics

The translator keeps various statistics about the QuickDraw picture data that it translates. You can examine these statistics after the translation if you are interested in this information. The statistics information is returned in the form of bit flags, as shown in Table 1-3.
Table 1-3 Translation statistics options
ConstantValueExplanation
gxContainsFormsBegin0x0001The data that was translated contained "formsBegin" picture comments.
gxContainsFormsEnd0x0002The data that was translated contained "formsEnd" picture comments.
gxContainsPostScript0x0004The data that was translated contained PostScript picture comments.
gxContainsEmptyPostScript0x0008The data that was translated contained PostScript picture comments in which there was no actual PostScript data.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996