Package com.day.image

Class AbstractBufferedImageOp

  • All Implemented Interfaces:
    java.awt.image.BufferedImageOp
    Direct Known Subclasses:
    DistortOp, DitherOp, EmbossOp, MultitoneOp, ResizeOp, StampOp

    public abstract class AbstractBufferedImageOp
    extends java.lang.Object
    implements java.awt.image.BufferedImageOp
    The AbstractBufferedImageOp provides a basic implementation to implement the BufferedImageOp interface. Basically this abstract class deals with all the intricacies of make the images compatible with operations on each other.

    The most easy use of this class is to simply implement an appropriate constructor and doFilter(BufferedImage, BufferedImage) method. Other methods need not be overwritten unless special needs arise. See the method's documentations for more information.

    Since:
    coati
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.awt.image.BufferedImage createCompatibleDestImage​(java.awt.image.BufferedImage src, java.awt.image.ColorModel destCM)
      Creates a zeroed destination image with the correct size and number of bands.
      java.awt.image.BufferedImage filter​(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dst)
      Performs the operation on a BufferedImage.
      java.awt.geom.Rectangle2D getBounds2D​(java.awt.image.BufferedImage src)
      Returns the bounding box of the filtered destination image.
      java.awt.geom.Point2D getPoint2D​(java.awt.geom.Point2D srcPt, java.awt.geom.Point2D dstPt)
      Returns the location of the destination point given a point in the source image.
      java.awt.RenderingHints getRenderingHints()
      Returns a copy of the rendering hints for this BufferedImageOp.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • filter

        public java.awt.image.BufferedImage filter​(java.awt.image.BufferedImage src,
                                                   java.awt.image.BufferedImage dst)
        Performs the operation on a BufferedImage. This implementation only cares to make the images compatible and calls the doFilter(BufferedImage, BufferedImage) to do the actual filtering operation.

        If the color models for the two images do not match, a color conversion into the destination color model will be performed. If the destination image is null, a BufferedImage with an appropriate ColorModel will be created.

        Note: The dest image might be clipped if it is not big enough to take the complete resized image.

        Note: Extensions to this class should not need to overwrite this method.

        Specified by:
        filter in interface java.awt.image.BufferedImageOp
        Parameters:
        src - The src image to be operated upon.
        dst - The dest image into which to place the modified image. This may be null in which case a new image with the correct size will be created.
        Returns:
        The newly created image (if dest was null) or dest into which the resized src image has been drawn.
        Throws:
        java.lang.IllegalArgumentException - if the dest image is the same as the src image.
        java.lang.NullPointerException - if the src image is null.
      • getBounds2D

        public java.awt.geom.Rectangle2D getBounds2D​(java.awt.image.BufferedImage src)
        Returns the bounding box of the filtered destination image. This implementation returns the bounding box of the source image given. This method is likely to be overwritten by extending classes which implement filtering operation resulting in the change of the image size.

        The IllegalArgumentException may be thrown if the source image is incompatible with the types of images allowed by the class implementing this filter.

        Specified by:
        getBounds2D in interface java.awt.image.BufferedImageOp
      • createCompatibleDestImage

        public java.awt.image.BufferedImage createCompatibleDestImage​(java.awt.image.BufferedImage src,
                                                                      java.awt.image.ColorModel destCM)
        Creates a zeroed destination image with the correct size and number of bands. This calls getBounds2D(BufferedImage) to decide on the size of the new image. So this method needs only be overwritten by extending class, which need more specialized operations than just to create a new image with the correct size and color model.

        The IllegalArgumentException may be thrown if the source image is incompatible with the types of images allowed by the class implementing this filter.

        Specified by:
        createCompatibleDestImage in interface java.awt.image.BufferedImageOp
        Parameters:
        src - Source image for the filter operation.
        destCM - ColorModel of the destination. If null, the ColorModel of the source will be used.
      • getPoint2D

        public java.awt.geom.Point2D getPoint2D​(java.awt.geom.Point2D srcPt,
                                                java.awt.geom.Point2D dstPt)
        Returns the location of the destination point given a point in the source image. If dstPt is non-null, it will be used to hold the return value. This method is likely to be overwritten by extending classes which implement filtering operation resulting in the change of the image size or in rotated images.
        Specified by:
        getPoint2D in interface java.awt.image.BufferedImageOp
      • getRenderingHints

        public final java.awt.RenderingHints getRenderingHints()
        Returns a copy of the rendering hints for this BufferedImageOp. Returns null if no hints have been set. Modyfing the object returned does not modify the rendering hints set on this.
        Specified by:
        getRenderingHints in interface java.awt.image.BufferedImageOp
        Returns:
        The rendering hints of this or null if none are defined.