1

I looked into this thread but the methods are deprecated and for me doesn't even work. I tried to do something similiar but failed. My sample code:

public interface Resources extends ClientBundle{
    @Source("images/castle.png")
    ImageResource castleIcon();

And the class that draws the image:

private void drawImage() {

        Resources res = GWT.create(Resources.class);
        final Image icon = new Image(res.castleIcon().getSafeUri());
        icon.addLoadHandler(new LoadHandler() {

            @Override
            public void onLoad(LoadEvent event) {
                icon.setPixelSize(100, 80);                 
            }
        });

        context.drawImage(createImageElement(icon), x - 65, y - 20);
    }


private ImageElement createImageElement(Image image) {
    return ImageElement.as(image.getElement());
}

I've tried this approach but it fails to render transparent background

Community
  • 1
  • 1
Jacek Kwiecień
  • 12,397
  • 20
  • 85
  • 157

1 Answers1

0

Transparency should work fine with PNG on a canvas. Are you sure your image is really transparent? Maybe your PNG is somehow incompatibly with the canvas implementation. Try a proper 24-bit PNG with alpha transparency...

Adrian B.
  • 4,333
  • 1
  • 24
  • 38