Ask a Question related to Mac Programming, Design and Development.
-
Mike Kluev #1
Re: Converting a GWorld to a Picture Handle
In Article [email]01HW.BB6D05170007A03E16E34AC0@news.dsl.pipex.com[/email], David Burgun
wrote:
It's FAQ. OpenPicture/CopyBits/ClosePicture.> Could anyone tell me the best way to turn a GWorld into a Picture Handle (not
> a file)???
--
Mike Kluev
PS. Remove "-DELETE-." part of my e-mail address to reply.
Mike Kluev Guest
-
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... -
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... -
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... -
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,... -
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... -
Bryan Pietrzak #2
Re: Converting a GWorld to a Picture Handle
David Burgun <NOdburgunSPAM@earthlink.net> wrote in message news:<01HW.BB6D05170007A03E16E34AC0@news.dsl.pipex .com>...
PicHandle GWorldToPicture(GWorldPtr gworld, SInt16 mode)> Could anyone tell me the best way to turn a GWorld into a Picture Handle
{
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
-
Mike Kluev #3
Re: Converting a GWorld to a Picture Handle
In Article [email]74288c70.0308232120.270dbee@posting.google.com[/email], Bryan Pietrzak
wrote:
Brian,> 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;
> }
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



Reply With Quote

