My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
ImageResource  
Compile-time image processing
Updated Jun 7, 2010 by bobv%google.com@gtempaccount.com

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

  1. Define a ClientBundle with one or more ImageResource accessors:
  2. interface Resources extends ClientBundle {
      @Source("logo.png")
      ImageResource logo();
    
      @Source("arrow.png")
      @ImageOptions(flipRtl = true)
      ImageResource pointer();
    }
  3. Instantiate the ClientBundle via a call to GWT.create().
  4. 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.

Comment by nkre...@gmail.com, Aug 13, 2009

Crop and scale images in high resolution at compile time is a very useful feature. Thanks in advance.

Comment by alex.dob...@gmail.com, Sep 19, 2009

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!

Comment by kondal...@gmail.com, Dec 21, 2009

Not able to re-size the image with ClientBundle. Can you help me? Thanks in advance AK (kondalar9@gmail.com)

Comment by OsorioJa...@gmail.com, Jan 4, 2010

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);
Comment by Cray.Hu...@gmail.com, Jan 11, 2010

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

Comment by Cray.Hu...@gmail.com, Jan 11, 2010

Sorry. I made a mistake. That problem has been resolved.

Comment by cmcguir...@gmail.com, Jul 12, 2010

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?

Comment by asinghja...@gmail.com, Sep 8, 2010

can u give me complete example of resourcebundeling in eclips and also liker concept

Comment by alex.dob...@gmail.com, Oct 27, 2010

No update on the resizing issue?


Sign in to add a comment
Powered by Google Project Hosting