Tuesday, May 9, 2017

Why does my ImageBitmap get squished if I resize the Canvas to the size of the bitmap

As far as I can judge this is more a cosmetic issue but it might have implications that I don't understand/see yet.

I have a vertical panel that serves as a container for a small image and a number label.

As member I have a 

private Canvas thumbnailCanvas;
private ResizeLayoutPanel rlp = new ResizeLayoutPanel();

and in the constructor I create the canvas with and add both the canvas and the label to the vertical panel

this.add(rlp); // this is the vertical panel

JavaScriptObject imageBitmap = image.getImageBitmap();
Context2d ctx = thumbnailCanvas.getContext2d();
ctx.drawImage((ImageElement)imageBitmap, 0, 0);

this works fine BUT when inspecting the HTML elements the canvas has a dimension of 300x150 and if I resize the canvas before I draw the bitmap to it, the bitmap dimension it gets squished as if I squished the canvas instead of resized it.

You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment