Professional Web Applications Themes

how can i extract a bitmap from a PICT? - Mac Programming

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

  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. #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%mikeobjc-source.-DELETE-.org>,
    Mike Kluev <mikeobjc-source.-DELETE-.org> wrote:
    > in article [email]jelemans-48A531.15200613082003shawnews.vc.shawcable.net[/email], John
    > Elemans at [email]jelemansmacpacs.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

  3. #3

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

    In article <jelemans-999A67.13470418082003shawnews.vc.shawcable.net>,
    John Elemans <jelemansmacpacs.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

  4. #4

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

    In Article [email]jelemans-999A67.13470418082003shawnews.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

Similar Threads

  1. Artwork Not Smooth in Pict Files
    By hultquist@adobeforums.com in forum Adobe Illustrator Macintosh
    Replies: 7
    Last Post: May 14th, 04:38 PM
  2. [Director MX]: Splash pict for OS X projector
    By Christian Kirchhoff in forum Macromedia Director Basics
    Replies: 1
    Last Post: January 8th, 05:24 PM
  3. importing pict or tif
    By Velvet in forum Macromedia Director Lingo
    Replies: 1
    Last Post: December 7th, 06:21 PM
  4. How do I create a PICT resource?
    By Andrew Fowler in forum Mac Programming
    Replies: 5
    Last Post: July 31st, 03:00 PM
  5. PICT to Quicktime Movie Converter
    By Tom Dowdy in forum Mac Applications & Software
    Replies: 1
    Last Post: July 26th, 02:35 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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