java - Checking the size of an Image with GWT -


i have gwt application generates svg files.

i want embed image url svg, want resized keeping correct aspect ratio.

i loading image using image class in gwt, , check height width, sums find height , width need in svg.

i embed image svg follows:

<image href="http://some.image/url.png" height="100" x="50" width="150" y="50"></image> 

the issue have when following:

image image = new image(sourceurl); int width = image.getwidth(); int height = image.getheight(); .... 

the first time particular url value of width or height comes 0. unfortunately retrying in loop doesn't seem fix problem, if ask application generate svg again, works.

any ideas?

ok, sorry not answer, comments small put code.

i tried following , worked perfectly. should try isolate issue in smaller piece of code:

    @override     public void onmoduleload() {      final image image = new image("https://www.google.com/images/srpr/logo3w.png");     image.addloadhandler(new loadhandler() {          @override         public void onload(loadevent event) {             window.alert(image.getwidth() + " " + image.getheight());         }     });     rootlayoutpanel.get().add(image);     } 

Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -