类 ImageUtils


  • public abstract class ImageUtils
    extends Object
    A class containing some static utility methods for dealing with BufferedImages.
    • 构造器详细资料

      • ImageUtils

        public ImageUtils()
    • 方法详细资料

      • createImage

        public static BufferedImage createImage​(ImageProducer producer)
        Cretae a BufferedImage from an ImageProducer.
        参数:
        producer - the ImageProducer
        返回:
        a new TYPE_INT_ARGB BufferedImage
      • convertImageToARGB

        public static BufferedImage convertImageToARGB​(Image image)
        Convert an Image into a TYPE_INT_ARGB BufferedImage. If the image is already of this type, the original image is returned unchanged.
        参数:
        image - the image to convert
        返回:
        the converted image
      • getSubimage

        public static BufferedImage getSubimage​(BufferedImage image,
                                                int x,
                                                int y,
                                                int w,
                                                int h)
        Returns a *copy* of a subimage of image. This avoids the performance problems associated with BufferedImage.getSubimage.
        参数:
        image - the image
        x - the x position
        y - the y position
        w - the width
        h - the height
        返回:
        the subimage
      • cloneImage

        public static BufferedImage cloneImage​(BufferedImage image)
        Clones a BufferedImage.
        参数:
        image - the image to clone
        返回:
        the cloned image
      • paintCheckedBackground

        public static void paintCheckedBackground​(Component c,
                                                  Graphics g,
                                                  int x,
                                                  int y,
                                                  int width,
                                                  int height)
        Paint a check pattern, used for a background to indicate image transparency.
        参数:
        c - the component to draw into
        g - the Graphics objects
        x - the x position
        y - the y position
        width - the width
        height - the height
      • getSelectedBounds

        public static Rectangle getSelectedBounds​(BufferedImage p)
        Calculates the bounds of the non-transparent parts of the given image.
        参数:
        p - the image
        返回:
        the bounds of the non-transparent area
      • composeThroughMask

        public static void composeThroughMask​(Raster src,
                                              WritableRaster dst,
                                              Raster sel)
        Compose src onto dst using the alpha of sel to interpolate between the two. I can't think of a way to do this using AlphaComposite.
        参数:
        src - the source raster
        dst - the destination raster
        sel - the mask raster
      • getRGB

        public static int[] getRGB​(BufferedImage image,
                                   int x,
                                   int y,
                                   int width,
                                   int height,
                                   int[] pixels)
        A convenience method for getting ARGB pixels from an image. This tries to avoid the performance penalty of BufferedImage.getRGB unmanaging the image.
        参数:
        image - a BufferedImage object
        x - the left edge of the pixel block
        y - the right edge of the pixel block
        width - the width of the pixel arry
        height - the height of the pixel arry
        pixels - the array to hold the returned pixels. May be null.
        返回:
        the pixels
        另请参阅:
        setRGB(java.awt.image.BufferedImage, int, int, int, int, int[])
      • setRGB

        public static void setRGB​(BufferedImage image,
                                  int x,
                                  int y,
                                  int width,
                                  int height,
                                  int[] pixels)
        A convenience method for setting ARGB pixels in an image. This tries to avoid the performance penalty of BufferedImage.setRGB unmanaging the image.
        参数:
        image - a BufferedImage object
        x - the left edge of the pixel block
        y - the right edge of the pixel block
        width - the width of the pixel arry
        height - the height of the pixel arry
        pixels - the array of pixels to set
        另请参阅:
        getRGB(java.awt.image.BufferedImage, int, int, int, int, int[])