offscreen drawing and saving...

offscreen drawing and saving...

Post by Rick Tschu » Sun, 17 Aug 2003 02:54:45


I want to open an offscreen PixelMap, draw into it and make the drawing a
PICT resource. I have a LWindow open that contains this resource and the
resource will then appear in the open window.

I can not use the de *** but to test the drawing portion I have used
CopyBits to move it to the open window and I get something that is not the
drawing and looks like a hunk of memory displayed pictorially.

Note: CreateOffScreen,LockOffScreen,UnlockOffScreen & DisposeOffScreen are
all from ...Technical Note QD13--Principia Off-Screen Graphics Environments.
at ...developer.apple.com/technotes/qd/qd_13.html.

here is a short hunk..

CGrafPtr colorPort
GDHandle colorDevice;
GrafPtr savedPort;
GDHandle savedDevice;
CTabHandle offColors;
RGBColor aColor;
OSErr error
Handle myHandle;
Rect aRct; Size aSize;

SetRect(& aRct,0,0,640,480); aSize = 640 * 480 * 8;
offColors = GetCTable( rColorClut );
error = CreateOffScreen(&aRct,kOffDepth,offColors,&colorPort,&colorDevice);
if (error == noErr)
{
GetPort( &savedPort );
savedDevice = GetGDevice();
SetPort( (GrafPtr)colorPort );
SetGDevice( colorDevice );
LockOffScreen( colorPort );
HNoPurge((Handle)(**colorPort->portPixMap).baseAddr);

aColor.red = 65532; aColor.green = 32967; aColor.blue = 4567;
RGBForeColor( &aColor );
::PaintRect(& aRct);
PtrToHand((**colorPort->portPixMap).baseAddr,&myHandle,aSize);
//TurnPictureToLWindowResouce(myHandle, 147);
HPurge((Handle)(**colorPort->portPixMap).baseAddr);
UnlockOffScreen( colorPort );

SetPort( savedPort );
SetGDevice( savedDevice );
CopyBits( &((GrafPtr)colorPort)->portBits, &savedPort->portBits,
&colorPort->portRect, &savedPort->portRect,
srcCopy, nil );
DisposeOffScreen( colorPort, colorDevice );
}else{ExitToShell();}


either the drawing commands are not getting into offscreen PixMap
or I am copying an arbitrary portin of memory
or both.....ANY IDEAS?

Thanks
RICK T.

--
 
 
 

offscreen drawing and saving...

Post by James W. W » Sun, 17 Aug 2003 14:53:54

In article <BB627001.CCA% XXXX@XXXXX.COM >, Rick Tschudin



I'm pretty sure that's an ancient tech note that precedes the GWorld
APIs. You're making things harder than necessary. See NewGWorld etc.
in QDOffscreen.h, or see UGWorld in PowerPlant.