However I'll let folks know in case they want to venture down this
road.
The Context2d scaling methods are broke in IE9. Using GWT 2.3, I'm
drawing an Image into a Canvas widget. The image is larger than the
target, so I'm scaling it. With either of the approaches below, the
image displays in Firefox 7.0.1, Safari 5, and Chrome 13. The image
does **not** display in IE9.
void drawImage(Context2d context) {
context.save();
context.scale(scale, scale);
context.restore();
}
or
void drawImage(Context2d context) {
context.save();
context.drawImage(imageElement, 0, 0,
scale*(double)image.getWidth()-10,
scale*(double)image.getHeight()-10);
context.restore();
}
scale was computed as
image = new Image(...
image.addLoadHandler(new LoadHandler() {
public void onLoad(LoadEvent event) {
imageElement = (ImageElement)image.getElement().cast();
scale = Math.min((double)width/(double)image.getWidth(),
(double)height/(double)image.getHeight());
scale = Math.min(scale, 1.0);
drawImage(imageContext);
}
});
I'll add that context.drawImage(imageElement, 0, 0, width, height)
does work in IE, but of course depending on my image I may get a
distorted width:height ratio.
SVG is a new thing with IE9. Hopefully it will be right in IE10.
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
No comments:
Post a Comment