OK, here is the source for the main module:
void capture(Char *buf){
MemHandle h;
WinHandle w1, w2;
FileRef f;
void *p;
UInt32 n, depth;
BitmapType *bmap;
Err err;
RectangleType r;
Int16 i;
UInt8 *q;
// check color depth
WinScreenMode(winScreenModeGet, 0, 0, &depth, 0);
if(depth != 8){
SndPlaySystemSound(sndError);
return;
}
// open bitmap file
f = openFile(buf);
if(f == vfsInvalidFileRef)
return;
// create bitmap
bmap = BmpCreate(160, 160, 8, 0, &err);
if(err){
SndPlaySystemSound(sndError);
VFSFileClose(f);
return;
}
// copy bitmap header
h = DmGetResource('tbin', 1000);
p = MemHandleLock(h);
VFSFileWrite(f, 1078, p, &n);
DmReleaseResource(h);
// set up rectangle
r.topLeft.x = 0;
r.topLeft.y = 0;
r.extent.x = 160;
r.extent.y = 160;
// copy screen image
w1 = WinGetDrawWindow();
w2 = WinCreateBitmapWindow(bmap, &err);
WinCopyRectangle(w1, w2, &r, 0, 0, winPaint);
q = BmpGetBits(bmap);
for(i = 0; i < 160; i++)
VFSFileWrite(f, 160, q + 160 * (159 - i), &n);
// epilog
WinDeleteWindow(w2, false);
MemPtrFree(bmap);
VFSFileClose(f);
SndPlaySystemSound(sndConfirmation);
}
The openFile function just opens a named file for output, and returns the
handle.
The resource it uses is the first 1078 bytes of another bitmap, that you can
create using POSE. Just include it in your application, as custom data.
Note that the Windows bitmap is flipped horizontally, relative to the Palm
bitmap. My method is not the quickest, but it is probably the simplest.
--
For information on using the ACCESS Developer Forums, or to unsubscribe, please
see http://www.access-company.com/developers/forums/