how can i extract a bitmap from a PICT?

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

  1. #1

    Default how can i extract a bitmap from a PICT?

    Hello,

    I need to save single frames from a Quicktime video stream. I can
    grab individual frames with GrabPict(..) which works. Under OS 9
    I draw the PICT to an offscreen port and then copybits the image
    to a buffer. But the offscreen port is locked under Carbon.

    Does anyone know how I can get the bits out under Carbon?
    TIA.

    je
    John Elemans Guest

  2. Similar Questions and Discussions

    1. Artwork Not Smooth in Pict Files
      Hi, When I export Illustrator graphics as a PICTs, the graphics in the PICT files aren't smooth anymore. i.e. Curved lines become a series of...
    2. [Director MX]: Splash pict for OS X projector
      Hello, I recently updated to DIrector MX. Previously I used to have splash screens (BMP on Windows, PCT on Mac OS) for my projector. In my new...
    3. importing pict or tif
      Hello Is it possible to import or export an image (not jpg or gif) without using an XTra? And is it also possible to sending an image by mail...
    4. How do I create a PICT resource?
      I am just starting out programming and I'm trying to create a simple Carbon-based OS X program which opens a window and displays text and a small...
    5. PICT to Quicktime Movie Converter
      In article <446a1b2b.0307251313.f2fb554@posting.google.com>, pschmitt@students.depaul.edu (Gashad) wrote: QuickTime Player itself can import...
  3. #2

    Default Re: how can i extract a bitmap from a PICT?

    I'm trying to go from picture to pixmap. I'm using DrawPict to an
    offscreen port, but all I get are black boxes!

    Here's what I'm doing;

    osErr = SGGrabPict(gSeqGrabber,&ph,&boundsRect,32,grabFlag s);

    SetRect(&boundsRect,0,0,640,480);

    qdResult = NewGWorld(&osWorld8,0,&boundsRect,NULL,NULL,noNewD evice);
    osWorld8PixMapHandle = GetGWorldPixMap(osWorld8);

    lockPixResult = LockPixels(osWorld8PixMapHandle);

    myGWFlags = UpdateGWorld (&osWorld8, 8, &boundsRect, NULL,
    device1Handle, clipPix);

    (*osWorld8PixMapHandle)->pixelType = 0;
    (*osWorld8PixMapHandle)->pixelSize = 8;
    (*osWorld8PixMapHandle)->cmpCount = 1;
    (*osWorld8PixMapHandle)->cmpSize = 8;

    (*osWorld8PixMapHandle)->rowBytes = ((( 8 * 640 + 15) >> 4) << 1
    ) | 0x8000;

    SetGWorld(osWorld8,NULL);

    DrawPicture(ph,&boundsRect);

    BlockMove((*osWorld8PixMapHandle)->baseAddr,(Ptr)buffer,640L*480);

    This should, I think, get me the pixmap in my buffer. Under OS 9, I do
    something very similar with an offscreen port instead of a GWorld and it
    works fine.

    TIA.

    In article <BB66969A.6C83%mike@objc-source.-DELETE-.org>,
    Mike Kluev <mike@objc-source.-DELETE-.org> wrote:
    > in article [email]jelemans-48A531.15200613082003@shawnews.vc.shawcable.net[/email], John
    > Elemans at [email]jelemans@macpacs.com[/email] wrote on 14/08/2003 02:20:
    >
    > > I need to save single frames from a Quicktime video stream. I can
    > > grab individual frames with GrabPict(..) which works. Under OS 9
    > > I draw the PICT to an offscreen port and then copybits the image
    > > to a buffer. But the offscreen port is locked under Carbon.
    >
    > What do you mean by this? To go from picture to pixmap use
    > DrawPicture. To go from pixmap to picture use OpenPicture/
    > CopyBits/ClosePicture.
    John Elemans Guest

  4. #3

    Default Re: how can i extract a bitmap from a PICT?

    In article <jelemans-999A67.13470418082003@shawnews.vc.shawcable.net>,
    John Elemans <jelemans@macpacs.com> wrote:
    > qdResult = NewGWorld(&osWorld8,0,&boundsRect,NULL,NULL,noNewD evice);
    > osWorld8PixMapHandle = GetGWorldPixMap(osWorld8);
    >
    > lockPixResult = LockPixels(osWorld8PixMapHandle);
    >
    > myGWFlags = UpdateGWorld (&osWorld8, 8, &boundsRect, NULL,
    > device1Handle, clipPix);
    UpdateGWorld can easily change the pixmap being used for the GWorld.
    Your osWorld8PixMapHandle is probably no longer legal, and also unlocked
    at this point.

    Why not simply create the GWorld at the desired depth (8) rather than 0
    in the first place?
    > (*osWorld8PixMapHandle)->pixelType = 0;
    > (*osWorld8PixMapHandle)->pixelSize = 8;
    > (*osWorld8PixMapHandle)->cmpCount = 1;
    > (*osWorld8PixMapHandle)->cmpSize = 8;
    >
    > (*osWorld8PixMapHandle)->rowBytes = ((( 8 * 640 + 15) >> 4) << 1
    > ) | 0x8000;
    Modifying the pixmap handle that belongs to the GWorld isn't a good
    idea, and isn't needed UpdateGWorld has in fact change things for you.
    > SetGWorld(osWorld8,NULL);
    >
    > DrawPicture(ph,&boundsRect);
    >
    > BlockMove((*osWorld8PixMapHandle)->baseAddr,(Ptr)buffer,640L*480);
    This blockmove assumes that the rowBytes are == the depth * the width.
    This is an invalid assumption.
    Tom Dowdy Guest

  5. #4

    Default Re: how can i extract a bitmap from a PICT?

    In Article [email]jelemans-999A67.13470418082003@shawnews.vc.shawcable.net[/email], John
    Elemans wrote:
    > I'm trying to go from picture to pixmap. I'm using DrawPict to an
    > offscreen port, but all I get are black boxes!
    >
    > Here's what I'm doing;
    >
    > osErr = SGGrabPict(gSeqGrabber,&ph,&boundsRect,32,grabFlag s);
    >
    > SetRect(&boundsRect,0,0,640,480);
    >
    > qdResult = NewGWorld(&osWorld8,0,&boundsRect,NULL,NULL,noNewD evice);
    > osWorld8PixMapHandle = GetGWorldPixMap(osWorld8);
    >
    > lockPixResult = LockPixels(osWorld8PixMapHandle);
    >
    > myGWFlags = UpdateGWorld (&osWorld8, 8, &boundsRect, NULL,
    > device1Handle, clipPix);
    >
    > (*osWorld8PixMapHandle)->pixelType = 0;
    > (*osWorld8PixMapHandle)->pixelSize = 8;
    > (*osWorld8PixMapHandle)->cmpCount = 1;
    > (*osWorld8PixMapHandle)->cmpSize = 8;
    >
    > (*osWorld8PixMapHandle)->rowBytes = ((( 8 * 640 + 15) >> 4) << 1
    > ) | 0x8000;
    >
    > SetGWorld(osWorld8,NULL);
    >
    > DrawPicture(ph,&boundsRect);
    >
    > BlockMove((*osWorld8PixMapHandle)->baseAddr,(Ptr)buffer,640L*480);
    >
    > This should, I think, get me the pixmap in my buffer. Under OS 9, I do
    > something very similar with an offscreen port instead of a GWorld and it
    > works fine.
    I guess the end result you want to achieve is buffer of pixel values,
    not offscreen itself. Instead of the above (which is wrong in many
    different ways) try the following:

    //allocate buffer to hold 640*480 bytes

    SetRect(&r, 0, 0, 640, 480);
    err = NewGWorldFromPtr(&offscreen, 8, &r, NULL, NULL, 0, buffer, 640);
    // check for error
    GetGWorld(&savedPort, &savedDevice);
    SetGWorld(offscreen, NULL);
    EraseRect(&r);
    DrawPicture(pict, &r);
    SetGWorld(savedPort, savedDevice);
    DisposeGWorld(offscreen);

    Also, ensure that grabbed picture is really what you think it is.

    --
    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