Converting a GWorld to a Picture Handle

Ask a Question related to Mac Programming, Design and Development.

  1. #1

    Default Re: Converting a GWorld to a Picture Handle

    In Article [email]01HW.BB6D05170007A03E16E34AC0@news.dsl.pipex.com[/email], David Burgun
    wrote:
    > Could anyone tell me the best way to turn a GWorld into a Picture Handle (not
    > a file)???
    It's FAQ. OpenPicture/CopyBits/ClosePicture.

    --
    Mike Kluev

    PS. Remove "-DELETE-." part of my e-mail address to reply.

    Mike Kluev Guest

  2. Similar Questions and Discussions

    1. Converting Quicktime movie to flash .swf with Flix -> No picture
      Hi there, I am using Flix 3.1 on windows XP to convert Quicktime movies to Flash MX swf files. Sound is OK, but no picture is in the swf. Do I on...
    2. Converting immage to picture for Filemaker Containor field
      I have a Filemaker database 8.0 into whose containor field I insert a "picture" of a document (letters, notes, lab results) via the filemaker script...
    3. Tie::Handle::CSV Help...
      Hello All,, I need some assistance please, i've been fussing with this for a while but i'm stuck. What i need here is, while my Style column...
    4. handle the IE.
      Hello, I need to show full screen, when IE is shown. Can I handle the appearence of IE by some flash commands ? Also, can I hanlde the html,...
    5. Is the bitmap of a picture still necessary after converting to a symbol?
      Assume I imported a picture into the library. Then I converted this small Bitmap to a symbol (e.g. a Button). Provided that i do not need the...
  3. #2

    Default Re: Converting a GWorld to a Picture Handle

    David Burgun <NOdburgunSPAM@earthlink.net> wrote in message news:<01HW.BB6D05170007A03E16E34AC0@news.dsl.pipex .com>...
    > Could anyone tell me the best way to turn a GWorld into a Picture Handle
    PicHandle GWorldToPicture(GWorldPtr gworld, SInt16 mode)
    {
    PicHandle picture = nil;

    GWorldPtr saveGWorld;
    GDHandle saveDevice;
    Rect pictureFrame;
    OpenCPicParams pictureParams;
    PixMapHandle pixels;


    GetGWorld(&saveGWorld, &saveDevice);
    SetGWorld(gworld, nil);

    pixels = GetGWorldPixMap(gworld);


    bool wasUnlocked = ((GetPixelsState(pixels) & pixelsLocked) == 0);

    LockPixels(pixels);

    GetPortBounds(gworld, &pictureFrame);

    pictureParams.srcRect = pictureFrame;
    pictureParams.hRes = 0x00480000;
    pictureParams.vRes = 0x00480000;
    pictureParams.version = -2;

    picture = OpenCPicture(&pictureParams);

    if (picture != nil)
    {
    const BitMap * bits = GetPortBitMapForCopyBits(gworld);

    // copy the data on top of itself

    CopyBits(bits, bits, &pictureFrame, &pictureFrame, mode, nil);
    ClosePicture();
    }

    if (wasUnlocked)
    UnlockPixels(pixels);

    SetGWorld(saveGWorld, saveDevice);

    return picture;
    }


    Hope it helps

    Bryan
    Bryan Pietrzak Guest

  4. #3

    Default Re: Converting a GWorld to a Picture Handle

    In Article [email]74288c70.0308232120.270dbee@posting.google.com[/email], Bryan Pietrzak
    wrote:
    > PicHandle GWorldToPicture(GWorldPtr gworld, SInt16 mode)
    > {
    > PicHandle picture = nil;
    >
    > GWorldPtr saveGWorld;
    > GDHandle saveDevice;
    > Rect pictureFrame;
    > OpenCPicParams pictureParams;
    > PixMapHandle pixels;
    >
    >
    > GetGWorld(&saveGWorld, &saveDevice);
    > SetGWorld(gworld, nil);
    >
    > pixels = GetGWorldPixMap(gworld);
    >
    >
    > bool wasUnlocked = ((GetPixelsState(pixels) & pixelsLocked) == 0);
    >
    > LockPixels(pixels);
    >
    > GetPortBounds(gworld, &pictureFrame);
    >
    > pictureParams.srcRect = pictureFrame;
    > pictureParams.hRes = 0x00480000;
    > pictureParams.vRes = 0x00480000;
    > pictureParams.version = -2;
    >
    > picture = OpenCPicture(&pictureParams);
    >
    > if (picture != nil)
    > {
    > const BitMap * bits = GetPortBitMapForCopyBits(gworld);
    >
    > // copy the data on top of itself
    >
    > CopyBits(bits, bits, &pictureFrame, &pictureFrame, mode, nil);
    > ClosePicture();
    > }
    >
    > if (wasUnlocked)
    > UnlockPixels(pixels);
    >
    > SetGWorld(saveGWorld, saveDevice);
    >
    > return picture;
    > }
    Brian,

    It lacks HLock((Handle)pixels). My experiments show that this
    is required on 9 (due to bug in CopyBits & co) especially with
    picture recording.

    Then I would say LockPixels is not necessary because QuickDraw
    will do it internally within CopyBits. The only time explicit
    LockPixels call is required is when it can fail (and it can only
    fail if pixels are purgeable) (so you can recover from its failure
    prior to calling QuickDraw), but if to not check LockPixels
    success/failure (and not recover from its failure) there is
    little point to call it explicitly. If to remove LockPixels all
    the above logic of saving/restoring pixels state could be removed.

    Then why not to use simpler OpenPicture call? I believe OpenCPicture
    is for advanced usage when you want to specify non standard resolution.

    Then, assuming we know nothing about GWorld I would set foreground
    and background colors if the is no intention to use CopyBits's
    colorization.

    Also, I'd set clip region to picture bounds: if we leave it as it
    is and it is wide open that would cause problems if picture is
    ever displayed with scaling.

    Three of above corrections are essential. I could continue (like:
    .... If we know nothing about GWorld what if it has pen level < 0,
    so picture will not be recorded? What if it is already in picture
    recording mode, so you can't just say OpenPicture without ruining
    the currently recorded picture? ...), but we need to stop somewhere :)

    --
    Mike Kluev

    PS. Remove "-DELETE-." part of my e-mail address to reply.

    Mike Kluev Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139