Package snap.swing

Class AWTImageUtils

java.lang.Object
snap.swing.AWTImageUtils

public class AWTImageUtils extends Object
Utility methods for AWT Images.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    convolve(int[] srcPix, int[] destPix, int srcW, int srcH, float[] kern, int kernW)
    Convolves given source image into dest image.
    static void
    emboss(int[] srcPix, int[] bumpPix, int srcW, int srcH, int radius, double azimuth, double altitude)
    Emboss a source image according to a bump map, both in ARGB integer array form.
    getBufferedImage(int aWidth, int aHeight, boolean withAlpha)
    Returns a compatible buffered image for width and height with given transparency.
    Returns a buffered image for an AWT image with transparency.
    getBufferedImage(Image anImage, boolean withAlpha)
    Returns a buffered image for an AWT image.
    static byte[]
    Returns a JPeg byte array for the given buffered image.
    static byte[]
    getBytesPNG(Image anImage)
    Returns a PNG byte array for the given buffered image.
    static float[]
    getGaussianKernel(int rx, int ry)
    Returns kernel for a Gaussian blur convolve.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AWTImageUtils

      public AWTImageUtils()
  • Method Details

    • getBytesJPEG

      public static byte[] getBytesJPEG(Image anImage)
      Returns a JPeg byte array for the given buffered image.
    • getBytesPNG

      public static byte[] getBytesPNG(Image anImage)
      Returns a PNG byte array for the given buffered image.
    • getBufferedImage

      public static BufferedImage getBufferedImage(Image anImage)
      Returns a buffered image for an AWT image with transparency.
    • getBufferedImage

      public static BufferedImage getBufferedImage(Image anImage, boolean withAlpha)
      Returns a buffered image for an AWT image.
    • getBufferedImage

      public static BufferedImage getBufferedImage(int aWidth, int aHeight, boolean withAlpha)
      Returns a compatible buffered image for width and height with given transparency.
    • emboss

      public static void emboss(int[] srcPix, int[] bumpPix, int srcW, int srcH, int radius, double azimuth, double altitude)
      Emboss a source image according to a bump map, both in ARGB integer array form. Bump map is assumed to to be (2*radius x 2*radius) pixels larger than the source to compensate for edge conditions of both the blur and the emboss convolutions. Code adapted from Graphics Gems IV - Fast Embossing Effects on Raster Image Data (by John Schlag)
    • convolve

      public static void convolve(int[] srcPix, int[] destPix, int srcW, int srcH, float[] kern, int kernW)
      Convolves given source image into dest image.
    • getGaussianKernel

      public static float[] getGaussianKernel(int rx, int ry)
      Returns kernel for a Gaussian blur convolve.