Valeriy Zamarayev wrote:
I'm doing an WinCreateOffscreenWindow with native coordinate system,
then I draw bitmap to it, which is an array many single sprites, then
when I need to output a bitmap, I calculate the rectangle which
corresponds to the bitmap needed, and do a WinCopyRectangle from
this window to the buffer offscreen window.

That seems like a good enough solution.

The only potential problem I see with it is that I think there may be
a limit to how big a window that WinCreateOffscreenWindow() can create
on some devices.  This could be an issue if you're creating a really
big offscreen window, like bigger than 64kB total pixel data.

But either way, it doesn't sound like it should cause the problems
you're seeing.

I did not find a way to handle transparency correctly with this apprioach,
so when I need transparency, I just do a WinDrawBitmap from a pre-locked bitmap from resources.

Doing transparency works for me if I use the following sequence:

1.  Create a bitmap with BmpRsrcV3Create() or BmpRsrcV2Create(),
    depending on whether you're on a high-density device or not.

2.  Wrap that bitmap with an offscreen window, using WinCreateBitmapWindow().

3.  Pick a transparent color.  Either an RGB color or an index, depending
    how many bits your offscreen window is.

4.  Set the draw window to your offscreen with WinDrawWindow().

5.  Set the foreground color with WinSetForeColorRGB() or WinSetForeColor()
    (depending on whether you do RGB or indexed color).

6.  Use WinDrawRectangle() to fill in the bitmap with your transparent
    color.

7.  Call BmpRsrcSetFlag (bitmapptr, kHasTransparencyFlag, true);

8.  Call BmpRsrcSetTransparentValue() to set the transparent color.
    If using RGB color, I pass BmpRsrcGetPixel (bitmapptr, 0, 0)
    as the transparent color.  (This will be the same as the
    transparent color since I just filled it with that.)
    If using indexed color, I just pass the color index I filled with.

9.  Draw whatever you want into the offscreen window that wraps
    the bitmap.

10. Now you have a bitmap with the proper transparency set, and you
    can do WinDrawBitmap() to put it onscreen.  It's a little tough
    if you want to copy only part of the bitmap.  You could set
    clipping and then adjust the position you draw (seems to work
    on all devices OS 4 or newer, but might not be legal to draw to
    negative coordinates on some older devices).  Or, you could
    do WinCopyRectangle() to copy it back, although I haven't tried
    that personally and can't say for sure whether it supports
    transparency properly.

Hope that helps...

  - Logan

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

Reply via email to