Ask a Question related to Mac Programming, Design and Development.
-
John Elemans #1
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
-
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... -
[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... -
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... -
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... -
PICT to Quicktime Movie Converter
In article <446a1b2b.0307251313.f2fb554@posting.google.com>, pschmitt@students.depaul.edu (Gashad) wrote: QuickTime Player itself can import... -
John Elemans #2
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
-
Tom Dowdy #3
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:
UpdateGWorld can easily change the pixmap being used for the GWorld.> qdResult = NewGWorld(&osWorld8,0,&boundsRect,NULL,NULL,noNewD evice);
> osWorld8PixMapHandle = GetGWorldPixMap(osWorld8);
>
> lockPixResult = LockPixels(osWorld8PixMapHandle);
>
> myGWFlags = UpdateGWorld (&osWorld8, 8, &boundsRect, NULL,
> device1Handle, clipPix);
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?Modifying the pixmap handle that belongs to the GWorld isn't a good> (*osWorld8PixMapHandle)->pixelType = 0;
> (*osWorld8PixMapHandle)->pixelSize = 8;
> (*osWorld8PixMapHandle)->cmpCount = 1;
> (*osWorld8PixMapHandle)->cmpSize = 8;
>
> (*osWorld8PixMapHandle)->rowBytes = ((( 8 * 640 + 15) >> 4) << 1
> ) | 0x8000;
idea, and isn't needed UpdateGWorld has in fact change things for you.
This blockmove assumes that the rowBytes are == the depth * the width.> SetGWorld(osWorld8,NULL);
>
> DrawPicture(ph,&boundsRect);
>
> BlockMove((*osWorld8PixMapHandle)->baseAddr,(Ptr)buffer,640L*480);
This is an invalid assumption.
Tom Dowdy Guest
-
Mike Kluev #4
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 guess the end result you want to achieve is buffer of pixel values,> 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.
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



Reply With Quote

