views:

482

answers:

1

I have a very simple application that has one screen and one button. The main screen has a verticalFieldManager with a BitmapField inside it, and one button beneath the bitmap. I want to be able to overlay another image on top of this when the user clicks a button. The overlay image is a PNG with transparent background, and this is important for design, so I can't use popupscreen or a new screen because the backgrounds are always white by default, and I've heard alpha doesn't really do the trick.

I guess what I'm asking is if anyone knows a simple way to...

A) take a standard verticalFieldManager and overlay a PNG on top of the inner contents

B) overlay a PNG over the screen, no matter the contents

The basic functionality of this app was intended to be - show an image. on click, show another overlaid on top. on click again, remove the popup image.

I haven't found anything that addresses something like this online, but I have read of people doing similar things that utilize popupscreen and new screens in a way I don't need to do.

Hopefully this makes sense. Thanks

A: 

Have you tried something like this in your custom class that overrides a screen?

EncodedImage _overlayImage;
boolean _overlay = false;

// this is to catch the click, you might do it different
public void fieldChanged(Field field, int context)
{
    if (field == _imgChangeButton) {
        // get the overlay image here, however you want
        _overlayImage = getEncodedImageResource(blah);
        _overlay = true;
        invalidate();
    }
}

protected void paint(Graphics graphics) {
    super.paint(graphics);

    if (_overlay) {
        graphics.drawImage(...);
    }
}

If the PNG has transparency in it the bb drawImage stuff should deal with it ok. In the drawImage call obviously you can mess around with finding the existing image and setting the x,y right on top of it.

In general I would say do a lot of testing with paint() and messing with the graphics directly before you try to do anything with another screen. You can do a lot overriding paint() for the screen... you get the whole graphics.

cjp