Package snap.swing
Class AWTImageUtils
java.lang.Object
snap.swing.AWTImageUtils
Utility methods for AWT Images.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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.static BufferedImage
getBufferedImage
(int aWidth, int aHeight, boolean withAlpha) Returns a compatible buffered image for width and height with given transparency.static BufferedImage
getBufferedImage
(Image anImage) Returns a buffered image for an AWT image with transparency.static BufferedImage
getBufferedImage
(Image anImage, boolean withAlpha) Returns a buffered image for an AWT image.static byte[]
getBytesJPEG
(Image anImage) 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.
-
Constructor Details
-
AWTImageUtils
public AWTImageUtils()
-
-
Method Details
-
getBytesJPEG
Returns a JPeg byte array for the given buffered image. -
getBytesPNG
Returns a PNG byte array for the given buffered image. -
getBufferedImage
Returns a buffered image for an AWT image with transparency. -
getBufferedImage
Returns a buffered image for an AWT image. -
getBufferedImage
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.
-