Class BufferedDynamicImageResource

  • All Implemented Interfaces:
    Serializable, IResource, org.apache.wicket.util.io.IClusterable

    public class BufferedDynamicImageResource
    extends DynamicImageResource
    A DynamicImageResource subclass that holds a BufferedImage generated by code elsewhere. The image is held in a non-transient field, and so if this resource is clustered, the entire image will be serialized and copied. If you can regenerate your image by drawing on a Graphics2D, you should prefer the RenderedDynamicImageResource class instead since its image data is transient and therefore it is very lightweight when clustered.

    The format of the image (and therefore the resource's extension) can be specified with setFormat(String). The default format is "PNG" because JPEG is lossy and makes generated images look bad and GIF has patent issues.

    Author:
    Jonathan Locke
    See Also:
    RenderedDynamicImageResource, Serialized Form
    • Constructor Detail

      • BufferedDynamicImageResource

        public BufferedDynamicImageResource()
        Construct.
      • BufferedDynamicImageResource

        public BufferedDynamicImageResource​(String format)
        Construct.
        Parameters:
        format -
    • Method Detail

      • setImage

        public void setImage​(BufferedImage image)
        Parameters:
        image - The image to set
      • getImageData

        protected byte[] getImageData​(IResource.Attributes attributes)
        Description copied from class: DynamicImageResource
        Get image data for our dynamic image resource. If the subclass regenerates the data, it should set the DynamicImageResource#setLastModifiedTime(Time) when it does so. This ensures that image caching works correctly.
        Specified by:
        getImageData in class DynamicImageResource
        Parameters:
        attributes - the context bringing the request, response and the parameters
        Returns:
        The image data for this dynamic image. null means there is no image and 404 (Not found) response will be return.