Documentation Archive Developer
Search

ADC Home > Reference Library > Technical Q&As > Legacy Documents > Graphics & Imaging >

Legacy Documentclose button

Important: This document is part of the Legacy section of the ADC Reference Library. This information should not be used for new development.

Current information on this Reference Library topic can be found here:

Using PICT Comments to Stretch and Rotate Objects


Important for all Apple Printing and Graphics Developers:

The information in this Technical Q & A is still relevant up to and including Mac OS 7.6 with QuickDraw GX 1.1.5. Beginning with the release of Mac OS 8.0, however, Apple plans to deliver a system which incorporates QuickDraw GX graphics and typography only. QuickDraw GX printer drivers and GX printing extensions will not be supported in Mac OS 8.0 or in future Mac OS releases. Apple's goal is to simplify the user experience of printing by unifying the Macintosh graphic and printing architectures and standardizing on the classic Printing Manager.

For details on Apple's official announcement, refer to </dev/technotes/gxchange.html>

Q: We are trying to add full GX-printing support to our drawing program, which isn't a GX-aware application, and we're running into some problems with the translator. When we use PICT comments to stretch and rotate objects, the objects sometimes disappear completely. Using direct GXRotateShape routines to rotate a shape has the same result. However, direct rotation and concatenation of the mappings works properly.

A: This happens because support for flipping with picture comments was not included in the current implementation of GX. This will be fixed in a future release.

If you are using the translator, you're limited by the way it performs its translation. You would be better off providing your own replacement for the translator, because you understand your data structures better.

You can use the following code snippet as a starting point to create your own translator. It creates a GX Ink with a simple 8 x 8 black and white bit pattern, allows an arbitrary color for foreground and another for background, and can be added to a frame or fill:

//Code for calling SetShapeQDPattern()
            {
                char        pattern[] = {0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55};
                RGBColor    fore, back;

                fore.red = 0xFFFF;
                fore.green = 0;
                fore.blue = 0;
                back.red = 0;
                back.green = 0xFFFF;
                back.blue = 0;

                SetShapeQDPattern(tempShape, (PatPtr)&pattern, &fore, &back);
            }

//SetShapeQDPattern()
// -------------------------------------------------------------------------------------
static void SetShapeQDPattern(
                gxShape theShape,               // shape to set pattern on
                PatPtr pPattern,                // 1 bit QD pattern to use
                RGBColor *pForeColor,           // color of the 0 bits (or is this 1?)
                RGBColor *pBackColor)           // color of the 1 bits (or is this 0?)
{
    gxPatternRecord     pattern;
    gxBitmap            bits;
    gxSetColor          colors[2];

    pattern.attributes  = 0;
    pattern.u.x         = ff(8);
    pattern.u.y         = ff(0);
    pattern.v.x         = ff(0);
    pattern.v.y         = ff(8);

    colors[0].rgb.red = pForeColor->red;
    colors[0].rgb.green = pForeColor->green;
    colors[0].rgb.blue = pForeColor->blue;
    colors[1].rgb.red = pBackColor->red;
    colors[1].rgb.green = pBackColor->green;
    colors[1].rgb.blue = pBackColor->blue;

    bits.image      = (char*)pPattern;
    bits.width      = 8;
    bits.height     = 8;
    bits.rowBytes   = 1;
    bits.pixelSize  = 1;
    bits.space      = gxIndexedSpace;
    bits.set        = GXNewColorSet(gxRGBSpace, 2, &colors);
    bits.profile    = nil;
    pattern.pattern = GXNewBitmap(&bits, nil);
    GXDisposeColorSet(bits.set);

    GXSetShapePattern(theShape, &pattern);
    GXDisposeShape(pattern.pattern);

} // SetShapeQDPattern

//--------------------------------------------------

[May 01 1995]