Reputation: 4380
I'm using gwt 2.6.0 and add an image to a canvas like so:
Image image = new Image("url");
Element element = image.getElement();
canvas.getContext2d().drawImage(ImageElement.as(element), 0, 0);
However, I want to set the opacity of the image to 0.5.
If I do the following to the element of the original image:
element.getStyle().setOpacity(0.5);
and add the image to the page (not the canvas) it works fine, but the image on the canvas is still displayed as normal.
How do I set the opacity of an image on a canvas?
Upvotes: 0
Views: 271
Reputation: 36884
Context2d
has a method called setGlobalAlpha(double)
that should be able to help you.
Upvotes: 1