Goal
- Provide access to image data at runtime in the most efficient way possible
- Do not bind the ImageResource API to a particular widget framework
Non-goals
- To provide a general-purpose image manipulation framework.
Overview
- Define a ClientBundle with one or more ImageResource accessors:
interface Resources extends ClientBundle {
@Source("logo.png")
ImageResource logo();
@Source("arrow.png")
@ImageOptions(flipRtl = true)
ImageResource pointer();
}- Instantiate the ClientBundle via a call to GWT.create().
- Instantiate one or more Image widget or use with the CssResource @sprite directive.
ImageOptions
The @ImageOptions annotation can be applied to the ImageResource accessor method in order to tune the compile-time processing of the image data
- flipRtl is a boolean value that will cause the image to be mirrored about its Y-axis when LocaleInfo.isRTL() returns true.
- repeatStyle is an enumerated value that is used in combination with the@sprite directive to indicate that the image is intended to be tiled.
- One or both of the height and width properties can be set to have the source image scaled at compile-time. If only one of the scaling properties are set, the image will be scaled so as to maintain the original aspect ratio.
Supported formats
ImageBundleBuilder uses the Java ImageIO framework to read image data. This includes support for all common web image formats.
Animated GIF files are supported by ImageResource. While the image data will not be incorporated into an image strip, the resource is still served in a browser-optimal fashion by the larger ClientBundle framework.
Converting from ImageBundle
Only minimal changes are required to convert existing code to use ImageResource.
- ImageBundle becomes ClientBundle
- AbstractImageProtoype becomes ImageResource
- AbstractImagePrototype.createImage() becomes new Image(imageResource)
- Other methods on AbstractImagePrototype can continue to be used by calling AbstractImagePrototype.create(imageResource) to provide an API wrapper.
Crop and scale images in high resolution at compile time is a very useful feature. Thanks in advance.
Indeed scaling would be awesome. Actually I just tested @Source annotation and I couldn't imagine this option would not be available.
Keep up the great work!
Not able to re-size the image with ClientBundle. Can you help me? Thanks in advance AK (kondalar9@gmail.com)
Hey guys! Thx for this great work!
Im not beeing able to link my imageresources with my widget (MVP). ImageResource does not have applyTo() Method which i need... http://www.gwtapps.com/doc/html/com.google.gwt.user.client.ui.AbstractImagePrototype.html
/** * Transforms an existing {@link Image} into the image represented by this * prototype. * * @param image the instance to be transformed to match this prototype */ public abstract void applyTo(Image image);It looks like the applyTo() method has been replaced with Image.setResource()
http://google-web-toolkit.googlecode.com/svn/javadoc/2.0/com/google/gwt/user/client/ui/Image.html#setResource(com.google.gwt.resources.client.ImageResource)
When I use Image.setResource() or new Image(ImageResource resource).
The image become to <img src="http://localhost:8888/xx.xx.xx.xx.Application/clear.cache.gif" style="background: transparent url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACiUlEQVR42o3SW0iTYRgH8DcqSrEiS1MIL7qsi4oIAonopjv1piARpboQzJLKGyMSCjoIZoimmyYZ3yZ5QLTSPDEPk9Sstn1zcwedc5tuzqnt0Db3be+/b+YsM1oP/Hm/m+f3fjzPS1iVEVMz1k1RaU2QsQYM9g3CWn8Mhpoc18id9ArmFEkmf1a44feilMLrD8Dp8sPS/wShr7Ggkgtwv77sbTu9+2pUIFwBLgiPzQDPWCpoFwGt3IGF/APOprST5/4L4DgO3zVCcLK9oMx2BB/GYLgwA/XizuGyMvGR6IB7Ab4vGQhJd4HWx8JWkICeOiFeMW9R/KA8Ozpg7QE3Gg/aG49ARRK0JVkYH5Ghpa0PhXcf/xugfFbHM0HZFNDOFKyUnIC8sRZqrQXtHYPRgaBdiaD6DOjYUdDW45h9fhE6pQbTRjs6uocjwDY+O9fOCBC+ORTwIqC5B6o/DzqUCj9zFuybOljmVzBrdqCjS4rcvKJcQuISCUlIIuTgnjUgGAphlV+dn7+dM+SBTqTxQDpM5RmYM9n45kVM8o+rubUbmTk3bvKNyT+TeGgN4LgQfH4OXqscnL6YB67B1X4JqoZn0OrNUKoNkCl0aGzuRGZWBAj/QVzCJsBtVsKneQefkoGy+jYUUilUkzNgJ6YhZ/VoavmA7OyCfEL27SfkcMzGDCKAkf2EAaYMrKgUigEJ1JqZDSCc9vcSXL91/8r6EH9tIbAO6D+Pou1RESYVLPTTZmh0JuimLDAYbfwgl9ErGf37GrlgCP5VDs7FRTjm5rG04oJjyQWb/Rscyx7YHW7+24m+/rGtwNBHOYQvGzYiqBWjOpwaMapqRKgSivBCIEKlgMHTUsEW4AfI56FOJICb0wAAAABJRU5ErkJggg==) no-repeat scroll 0px 0px; width: 16px; height: 16px; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" border="0">
How to resolve this problem? Thanks
Sorry. I made a mistake. That problem has been resolved.
Is there a working example of the @ImageOptions? height and width properties? My code will not compile when specifying those options and the JavaDoc? does not seem to indicate that these are valid. Is this a dropped feature, or perhaps, a future enhancement?
can u give me complete example of resourcebundeling in eclips and also liker concept
No update on the resizing issue?