|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ccg.awt.RGBPixels
public class RGBPixels
Manipulate integer array representations of images. This class was created to allow one to manipulate integer arrays which represented RGB values of a image. Methods to create, fill and manipulate these images. Some of the basic transformations are based from code snippets out of "Kick Ass Java Programming" by Tonny Espeset.
It should be noted that the integer array representation is treated in the following manner:
ImageUtility,
Serialized Form| Constructor Summary | |
|---|---|
RGBPixels()
Construct a empty RGBPixel map. |
|
RGBPixels(int w,
int h,
Color c)
Construct a new pixel area and fill with an optional color. |
|
| Method Summary | |
|---|---|
void |
adjustBrightness(int percent)
Adjust the brightness This filter allows one to adjust the brightness of the pixels making up the bitmap by a specific percentage. |
void |
adjustContrast(int percent)
Adjust the contrast This filter allows one to adjust the contrast of the pixels making up the bitmap by a specific percentage. |
void |
adjustContrast(int ra,
int rp,
int ga,
int gp,
int ba,
int bp)
Adjust the contrast on each color channel This filter allows one to adjust the contrast of the pixels making up the bitmap by a specific percentage. |
void |
button3D(int bsize,
int strength)
Turn the pixel map into a 3D button. |
RGBPixels |
getArea(int x,
int y,
int w,
int h)
Extract a rectangular area from this object. |
int |
getHeight()
Get height of the image in pixels |
Image |
getImage()
Get a Image representation. |
ImageProducer |
getImageProducer()
Get a ImageProducer representation. |
int[] |
getPixels()
Get the RGB pixel data as a linear array. |
int |
getWidth()
Get width of the pixel images |
void |
grayScale()
Convert to gray scale. |
void |
initialize(int[] pixels,
int width)
Associate a previously allocated pixel area with this object. |
void |
initialize(int w,
int h,
Color c)
Create a new pixel area and fill with an optional color. |
void |
noise(int minPercentAdj,
int maxPercentAdj)
Randomly adjust the brightness of each pixel This method allows one to randomly adjust the brightness of each pixel. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public RGBPixels()
RGBPixels(int,int,Color)
public RGBPixels(int w,
int h,
Color c)
width - Width of your desired pixmap.height - Height of your desired pixmap.color - Optional Color to initialize the RGB
array with (if you pass null - the array won't be filled).initialize(int,int,Color)| Method Detail |
|---|
public void initialize(int[] pixels,
int width)
This method is primarily useful if you find yourself wanting to apply an affect to an existing array of pixel data you have available. For example the following applies a 3D button edge to an existing pixel array:
public static void make3DEdges(int[] pixels, int w, boolean pressed) {
RGBPixels rp = new RGBPixels();
rp.initialize(pixels,w);
rp.button3D(8,pressed ? -20 : +20);
}
pixels - The data for the RGB pixels. Please note, a duplicate is not
made, so, if you don't want to share your pixel data, you
should make a copy prior to using this method.width - The width of one row of pixels. This value must be less than
or equal to the length of the pixel array.initialize(int,int,java.awt.Color)
public void initialize(int w,
int h,
Color c)
width - Width of your desired pixmap.height - Height of your desired pixmap.color - Optional Color to initialize the RGB
array with (if you pass null or the color you pass has a RGB
value of 0, then the extra step of filling the array will be
skipped - and all values in the array will be set to 0).initialize(int[],int)public RGBPixels getArea(int x, int y, int w, int h)
RGBPixels object. This method
allows one to do that. You specify the top left corner and the
width and height of the pixels you want, and they will be
returned as a new RGBPixel object.
Here is an example of how one might use this. Pretend you just want the upper left corner look of a 3D button. Step 1, create a large 3D Button. Step 2, extract the rectangular region in the upper left corner.
x - Left edge of the rectangular area to extract from the object.y - Top edge of the rectangular are to extract from the object.w - Width of the rectangular area to extract from the object.h - Height of the rectangular are to extract from the object.
initialize(int[],int)public ImageProducer getImageProducer()
ImageProducer representation.
ImageProducer of the pixels.getImage()public Image getImage()
Image representation.
Image of the pixels.getImageProducer()public int getWidth()
initialize(int,int,Color)public int getHeight()
initialize(int,int,Color)public int[] getPixels()
initialize(int,int,Color)public void adjustBrightness(int percent)
percent - How much (percentage wise) you want to adjust the brightness
by values from [0,99] will darken the image, values larger
than 100 will brighten the imagepublic void adjustContrast(int percent)
percent - How much (percentage wise) you want to adjust the contrast
by. Values from [0,99] will reduce the contrast, values larger
than 100 will increase the constrast.
public void adjustContrast(int ra,
int rp,
int ga,
int gp,
int ba,
int bp)
ra - The "average" (or normalized) value for red which we will move
the color towards or away from.rp - The percentage which dictates how much movement should
occur. Specified as a integer percentage. Values from [0,99]
will reduce the contrast (move towards 'ra'), values larger
than 100 will increase the constrast (move away from 'ra').ga - The "average" (or normalized) value for green which we will move
the color towards or away from.gp - The percentage which dictates how much movement should
occur. Specified as a integer percentage. Values from [0,99]
will reduce the contrast (move towards 'ga'), values larger
than 100 will increase the constrast (move away from 'ga').ba - The "average" (or normalized) value for blue which we will move
the color towards or away from.bp - The percentage which dictates how much movement should
occur. Specified as a integer percentage. Values from [0,99]
will reduce the contrast (move towards 'ba'), values larger
than 100 will increase the constrast (move away from 'ba').public void grayScale()
public void noise(int minPercentAdj,
int maxPercentAdj)
minPercent - The minimum percentage change to adjust the brightness
by. Values from [0,99] will darken the image, values larger
than 100 will brighten the imagemaxPercent - The maximum percentage change to adjust the brightness
by. Values from [0,99] will darken the image, values larger
than 100 will brighten the image
public void button3D(int bsize,
int strength)
border - How many pixels to use for the rounded edge.strength - How much brightness should vary as we go from light to
dark. Negative for pressed in state, positive for released
(out) state. Values should always probably be in the range of
(-64/+64) - if you go too big, you will "peak" on the
brightness of the individual RGB values as they are adjusted.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||