Is there any GWT widget which allows me to:
The above should be reflected in the browser as well.
As far as I know, GWT client-side code cannot directly modify images, but the Image widget can be set to display only a portion of an image. You can do this using the constructor Image(java.lang.String url, int left, int top, int width, int height)
, where width
and height
are the dimensions of the visible box and not the image itself.
However this does not allow you to resize and then crop. In order to do this you could first resize the image then put it in an absolute panel to crop it.
AbsolutePanel testPanel = new AbsolutePanel();
Image image = new Image("path/image.jpg");
image.setWidth("1000px");
testPanel.add(image,-100,-100);
testPanel.setPixelSize(300,300);
I apologize if this isn't exactly what you're looking for, but it's the best answer I have.
You can also load the image type as a DataResource instead of ImageResource if you want it to scale with setPixelsSize()
e.g.
...
@Source("uploading.gif")
DataResource uploadingIcon();
...
Image uploadingGif = new Image(RESOURCE.uploadingIcon().getUrl());
uploadingGif.setPixelSize(25, 25);
Here is how I use the canvas element to scale images using HTML5.
Thanks ImageResource have same method getURL() i used it worked for me.. try this it will work we can use now Images in both ways either as URL path or ImageResource..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With