APIdia Launch Partner
Top Description Constructors Methods
javax.swing.plaf.nimbus

pack-priv Class EffectUtils

extends Object
Class Inheritance
Imports
java.awt.AlphaComposite, .Graphics2D, .Transparency, .GraphicsConfiguration, .GraphicsEnvironment, java.awt.image.BufferedImage, .Raster, .WritableRaster, .ColorModel

EffectUtils
Author
Created by Jasper Potts (Jun 18, 2007)

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private static void
blur(int[]
the source pixels
srcPixels
,
int[]
the destination pixels
dstPixels
,
int
the width of the source picture
width
,
int
the height of the source picture
height
,
float[]
the kernel of the blur effect
kernel
,
int
the radius of the blur effect
radius
)

Blurs the source pixels into the destination pixels.

pack-priv static void
blur(byte[]
the source pixels
srcPixels
,
byte[]
the destination pixels
dstPixels
,
int
the width of the source picture
width
,
int
the height of the source picture
height
,
float[]
the kernel of the blur effect
kernel
,
int
the radius of the blur effect
radius
)

Blurs the source pixels into the destination pixels.

pack-priv static void
clearImage(BufferedImage
The image to clear
img
)

Clear a transparent image to 100% transparent

public static BufferedImage

Returns:

a new BufferedImage, compatible with the color model of image
createColorModelCompatibleImage
(BufferedImage
the reference image from which the color model of the new image is obtained
image
)

Returns a new BufferedImage using the same color model as the image passed as a parameter.

public static BufferedImage

Returns:

a new translucent compatible BufferedImage of the specified width and height
createCompatibleTranslucentImage
(int
the width of the new image
width
,
int
the height of the new image
height
)

Returns a new translucent compatible image of the specified width and height.

pack-priv static float[]
pack-priv static BufferedImage

Returns:

The blurred image
gaussianBlur
(BufferedImage
The image tp
src
,
BufferedImage
The destination image to draw blurred src image into, null if you want a new one created
dst
,
int
The blur kernel radius
radius
)

Apply Gaussian Blur to Image

private static GraphicsConfiguration
pack-priv static byte[]

Returns:

pixels if non-null, a new array of integers otherwise
getPixels
(BufferedImage
the source image
img
,
int
the x location at which to start grabbing pixels
x
,
int
the y location at which to start grabbing pixels
y
,
int
the width of the rectangle of pixels to grab
w
,
int
the height of the rectangle of pixels to grab
h
,
byte[]
a pre-allocated array of pixels of size w*h; can be null
pixels
)

Returns an array of pixels, stored as integers, from a BufferedImage.

public static int[]

Returns:

pixels if non-null, a new array of integers otherwise
getPixels
(BufferedImage
the source image
img
,
int
the x location at which to start grabbing pixels
x
,
int
the y location at which to start grabbing pixels
y
,
int
the width of the rectangle of pixels to grab
w
,
int
the height of the rectangle of pixels to grab
h
,
int[]
a pre-allocated array of pixels of size w*h; can be null
pixels
)

Returns an array of pixels, stored as integers, from a BufferedImage.

private static boolean
pack-priv static void
setPixels(BufferedImage
the destination image
img
,
int
the x location at which to start storing pixels
x
,
int
the y location at which to start storing pixels
y
,
int
the width of the rectangle of pixels to store
w
,
int
the height of the rectangle of pixels to store
h
,
byte[]
an array of pixels, stored as integers
pixels
)

Writes a rectangular area of pixels in the destination BufferedImage.

public static void
setPixels(BufferedImage
the destination image
img
,
int
the x location at which to start storing pixels
x
,
int
the y location at which to start storing pixels
y
,
int
the width of the rectangle of pixels to store
w
,
int
the height of the rectangle of pixels to store
h
,
int[]
an array of pixels, stored as integers
pixels
)

Writes a rectangular area of pixels in the destination BufferedImage.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

EffectUtilsback to summary
pack-priv EffectUtils()

Method Detail

blurback to summary
private static void blur(int[] srcPixels, int[] dstPixels, int width, int height, float[] kernel, int radius)

Blurs the source pixels into the destination pixels. The force of the blur is specified by the radius which must be greater than 0.

The source and destination pixels arrays are expected to be in the INT_ARGB format.

After this method is executed, dstPixels contains a transposed and filtered copy of srcPixels.

Parameters
srcPixels:int[]

the source pixels

dstPixels:int[]

the destination pixels

width:int

the width of the source picture

height:int

the height of the source picture

kernel:float[]

the kernel of the blur effect

radius:int

the radius of the blur effect

blurback to summary
pack-priv static void blur(byte[] srcPixels, byte[] dstPixels, int width, int height, float[] kernel, int radius)

Blurs the source pixels into the destination pixels. The force of the blur is specified by the radius which must be greater than 0.

The source and destination pixels arrays are expected to be in the BYTE_GREY format.

After this method is executed, dstPixels contains a transposed and filtered copy of srcPixels.

Parameters
srcPixels:byte[]

the source pixels

dstPixels:byte[]

the destination pixels

width:int

the width of the source picture

height:int

the height of the source picture

kernel:float[]

the kernel of the blur effect

radius:int

the radius of the blur effect

clearImageback to summary
pack-priv static void clearImage(BufferedImage img)

Clear a transparent image to 100% transparent

Parameters
img:BufferedImage

The image to clear

createColorModelCompatibleImageback to summary
public static BufferedImage createColorModelCompatibleImage(BufferedImage image)

Returns a new BufferedImage using the same color model as the image passed as a parameter. The returned image is only compatible with the image passed as a parameter. This does not mean the returned image is compatible with the hardware.

Parameters
image:BufferedImage

the reference image from which the color model of the new image is obtained

Returns:BufferedImage

a new BufferedImage, compatible with the color model of image

createCompatibleTranslucentImageback to summary
public static BufferedImage createCompatibleTranslucentImage(int width, int height)

Returns a new translucent compatible image of the specified width and height. That is, the returned BufferedImage is compatible with the graphics hardware. If the method is called in a headless environment, then the returned BufferedImage will be compatible with the source image.

Parameters
width:int

the width of the new image

height:int

the height of the new image

Returns:BufferedImage

a new translucent compatible BufferedImage of the specified width and height

createGaussianKernelback to summary
pack-priv static float[] createGaussianKernel(int radius)
gaussianBlurback to summary
pack-priv static BufferedImage gaussianBlur(BufferedImage src, BufferedImage dst, int radius)

Apply Gaussian Blur to Image

Parameters
src:BufferedImage

The image tp

dst:BufferedImage

The destination image to draw blurred src image into, null if you want a new one created

radius:int

The blur kernel radius

Returns:BufferedImage

The blurred image

getGraphicsConfigurationback to summary
private static GraphicsConfiguration getGraphicsConfiguration()
getPixelsback to summary
pack-priv static byte[] getPixels(BufferedImage img, int x, int y, int w, int h, byte[] pixels)

Returns an array of pixels, stored as integers, from a BufferedImage. The pixels are grabbed from a rectangular area defined by a location and two dimensions. Calling this method on an image of type different from BufferedImage.TYPE_INT_ARGB and BufferedImage.TYPE_INT_RGB will unmanage the image.

Parameters
img:BufferedImage

the source image

x:int

the x location at which to start grabbing pixels

y:int

the y location at which to start grabbing pixels

w:int

the width of the rectangle of pixels to grab

h:int

the height of the rectangle of pixels to grab

pixels:byte[]

a pre-allocated array of pixels of size w*h; can be null

Returns:byte[]

pixels if non-null, a new array of integers otherwise

Exceptions
IllegalArgumentException:
is pixels is non-null and of length < w*h
getPixelsback to summary
public static int[] getPixels(BufferedImage img, int x, int y, int w, int h, int[] pixels)

Returns an array of pixels, stored as integers, from a BufferedImage. The pixels are grabbed from a rectangular area defined by a location and two dimensions. Calling this method on an image of type different from BufferedImage.TYPE_INT_ARGB and BufferedImage.TYPE_INT_RGB will unmanage the image.

Parameters
img:BufferedImage

the source image

x:int

the x location at which to start grabbing pixels

y:int

the y location at which to start grabbing pixels

w:int

the width of the rectangle of pixels to grab

h:int

the height of the rectangle of pixels to grab

pixels:int[]

a pre-allocated array of pixels of size w*h; can be null

Returns:int[]

pixels if non-null, a new array of integers otherwise

Exceptions
IllegalArgumentException:
is pixels is non-null and of length < w*h
isHeadlessback to summary
private static boolean isHeadless()
setPixelsback to summary
pack-priv static void setPixels(BufferedImage img, int x, int y, int w, int h, byte[] pixels)

Writes a rectangular area of pixels in the destination BufferedImage. Calling this method on an image of type different from BufferedImage.TYPE_INT_ARGB and BufferedImage.TYPE_INT_RGB will unmanage the image.

Parameters
img:BufferedImage

the destination image

x:int

the x location at which to start storing pixels

y:int

the y location at which to start storing pixels

w:int

the width of the rectangle of pixels to store

h:int

the height of the rectangle of pixels to store

pixels:byte[]

an array of pixels, stored as integers

Exceptions
IllegalArgumentException:
is pixels is non-null and of length < w*h
setPixelsback to summary
public static void setPixels(BufferedImage img, int x, int y, int w, int h, int[] pixels)

Writes a rectangular area of pixels in the destination BufferedImage. Calling this method on an image of type different from BufferedImage.TYPE_INT_ARGB and BufferedImage.TYPE_INT_RGB will unmanage the image.

Parameters
img:BufferedImage

the destination image

x:int

the x location at which to start storing pixels

y:int

the y location at which to start storing pixels

w:int

the width of the rectangle of pixels to store

h:int

the height of the rectangle of pixels to store

pixels:int[]

an array of pixels, stored as integers

Exceptions
IllegalArgumentException:
is pixels is non-null and of length < w*h