What is the proper way of saving a Bitmap to a resource?  I remember
someone from PalmSource mentioning that one can't copy the Bitmap directly,
because the bitmap header and the bitmap data may not be contiguous in
memory.  I've looked in the eScribe archives, but I guess my search-fu
is lacking.

My guess is that I should do something like:

    UInt32 dataSize;
    UInt32 headerSize;

    BmpGetSizes(bmpP, &dataSize, &headerSize);

    resH = DmNewResource(dbP, bitmapRsc, id, dataSize + headerSize);
    resP = MemHandleLock(resH);

    DmWrite(resP, 0, bmpP, headerSize);
    DmWrite(resP, headerSize, BmpGetBits(bmpP), dataSize);

(I haven't tested the above code, and it obviously skips a lot of steps.)

One problem I foresee with the above, however, is that if the header and
data are not contiguous in memory, then the bitmap will have the indirect
bit set in the bitmap header.  After I copy the data into a resource,
however, the header and data WILL be contiguous.  How can I turn off the
indirect bit?  The SDK reference discourages changing the bit manually, and
it's inaccessible without diving into the Bitmap internals anyway.

If I create a new bitmap with BmpCreate or WinCreateOffscreenWindow, is
there any guarantee that the header and data will be contiguous?

Thanks,

- James



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to