Class Thumbnail

  • Direct Known Subclasses:
    BasicThumbnail


    public abstract class Thumbnail
    extends Object
    This is an abstract model to format thumbnails.

    Here "format thumbnails" refers to adding small tasteful decorations to a scaled image to make a professional looking graphic. This class uses the Scaling class to implement the actual scaling. (If all you're interested in in scaling a large image, then please refer to that class, at the accompanying discussion.)

    • Field Detail

      • Plain

        public static Thumbnail Plain
        A thumbnail format with no decorations.
      • qualityHints

        protected static final RenderingHints qualityHints
        A set of high-quality rendering hints for the keys ANTIALIASING, INTERPOLATION, COLOR_RENDER, STROKE, and RENDER.
    • Constructor Detail

      • Thumbnail

        public Thumbnail()
    • Method Detail

      • create

        public BufferedImage create(URL source,
                                    Dimension maxSize)
        Create a thumbnail from a URL.
        Parameters:
        source - a url for a PNG, JPG, GIF, or BMP image.
        maxSize - the maximum dimensions of the thumbnail. Note the returned thumbnail may be smaller than these bounds. For example: if you have a 4:3 landscape-oriented picture and the maximum size is 64x64 pixels, then the return image will be 64 pixels wide and approximately 48 pixels tall. (It may not be exactly 48 pixels tall, depending on the decorations this thumbnail format may add.)

        If the source image is already smaller than the maxSize, then the source image is not scaled to create this thumbnail.

        Returns:
        an image that is at most maxSize dimensions.
      • create

        public BufferedImage create(Image source,
                                    Dimension maxSize)
        Create a thumbnail from an image.
        Parameters:
        source - an image to create a thumbnail for.
        maxSize - the maximum dimensions of the thumbnail. Note the returned thumbnail may be smaller than these bounds. For example: if you have a 4:3 landscape-oriented picture and the maximum size is 64x64 pixels, then the return image will be 64 pixels wide and approximately 48 pixels tall. (It may not be exactly 48 pixels tall, depending on the decorations this thumbnail format may add.)

        If the source image is already smaller than the maxSize, then the source image is not scaled to create this thumbnail.

        Returns:
        an image that is at most maxSize dimensions.
      • create

        public BufferedImage create(File source,
                                    Dimension maxSize)
        Create a thumbnail from a file.
        Parameters:
        source - a file for a PNG, JPG, GIF, or BMP image.
        maxSize - the maximum dimensions of the thumbnail. Note the returned thumbnail may be smaller than these bounds. For example: if you have a 4:3 landscape-oriented picture and the maximum size is 64x64 pixels, then the return image will be 64 pixels wide and approximately 48 pixels tall. (It may not be exactly 48 pixels tall, depending on the decorations this thumbnail format may add.)

        If the source image is already smaller than the maxSize, then the source image is not scaled to create this thumbnail.

        Returns:
        an image that is at most maxSize dimensions.
      • create

        public BufferedImage create(BufferedImage source,
                                    Dimension maxSize)
        Create a thumbnail from a BufferedImage.
        Parameters:
        source - an image to create a thumbnail for.
        maxSize - the maximum dimensions of the thumbnail. Note the returned thumbnail may be smaller than these bounds. For example: if you have a 4:3 landscape-oriented picture and the maximum size is 64x64 pixels, then the return image will be 64 pixels wide and approximately 48 pixels tall. (It may not be exactly 48 pixels tall, depending on the decorations this thumbnail format may add.)

        If the source image is already smaller than the maxSize, then the source image is not scaled to create this thumbnail.

        Returns:
        an image that is at most maxSize dimensions.
      • create

        protected abstract BufferedImage create(Thumbnail.ImageSource source,
                                                Dimension maxSize)
        Create a thumbnail from an ImageSource.
        Parameters:
        source - the image source.
        maxSize - the maximum dimensions of the thumbnail. Note the returned thumbnail may be smaller than these bounds. For example: if you have a 4:3 landscape-oriented picture and the maximum size is 64x64 pixels, then the return image will be 64 pixels wide and approximately 48 pixels tall. (It may not be exactly 48 pixels tall, depending on the decorations this thumbnail format may add.)

        If the source image is already smaller than the maxSize, then the source image is not scaled to create this thumbnail.

        Returns:
        an image that is at most maxSize dimensions.