Class GrafixTools

Class GrafixTools

java.lang.Object
   |
   +----GrafixTools

public class GrafixTools
extends Object
GraphixTools - A collection of handy graphics functions

This is a collection of graphics mundanes that I had to cut and paste one too many times. While laziness on my part I think that I was doing this stuff enough to warrant packaging up these goodies into their own proper class. Hopefully this will evolve into something that's worth releasing.

Feature list:
Array returns (R,G,B).
E-Z Image Producing.
RGB to YUV colorspace conversion.
YUV to RGB colorspave conversion.
Filesize and other information
Free & Used VM Machine Memory Info


You can get the source code here.
Version:
0.9.7 August 20th 1996
Author:
Stephen Manley (smanley@nyx.net)

Variable Index

 o imageHeight
Image height.
 o imageobj
Here lieth an image.
 o imageWidth
Image width.

Constructor Index

 o GrafixTools(Image)
Gives GraphixTools a preloaded image object.

Method Index

 o convertGrayToArray(int[][], boolean)
This method converts a single array 0..255 range pixel matrix to a java-compatible array of 32 bit integers.
 o convertRGBtoArray(int[][], int[][], int[][], boolean)
This method converts a 0..255 range pixel matrix to a java-compatible array of 32 bit integers.
 o convertRGBtoCb(int[][], int[][], int[][])
This method converts an RGB colorspace to a YUV colorspace.
 o convertRGBtoCr(int[][], int[][], int[][])
This method converts an RGB colorspace to a YUV colorspace.
 o convertRGBtoY(int[][], int[][], int[][])
This method converts an RGB colorspace to a YUV colorspace.
 o convertYCbCrtoB(int[][], int[][], int[][])
This method converts a YUV (aka YCbCr) colorspace to a RGB colorspace.
 o convertYCbCrtoG(int[][], int[][], int[][])
This method converts a YUV (aka YCbCr) colorspace to a RGB colorspace.
 o convertYCbCrtoR(int[][], int[][], int[][])
This method converts a YUV (aka YCbCr) colorspace to a RGB colorspace.
 o getBlueArray()
This method returns an array[][] of 8-bit blue values.
 o getGreenArray()
This method returns an array[][] of 8-bit green values.
 o getRedArray()
This method returns an array[][] of 8-bit red values.

Variables

 o imageobj
  public Image imageobj
Here lieth an image.
 o imageHeight
  public int imageHeight
Image height.
 o imageWidth
  public int imageWidth
Image width.

Constructors

 o GrafixTools
  public GrafixTools(Image image)
Gives GraphixTools a preloaded image object. Image must be pre-loaded with the MediaTracker or bad things will happen. The constructor calculates all the image parameters from this passed image. (Dimensions, size, etc.)
Parameters:
image - The 100% loaded image

Methods

 o getRedArray
  public int[][] getRedArray()
This method returns an array[][] of 8-bit red values. The dimensions are the array bounds ex. (320 x 200).
Returns:
s An array[][] of red pixel values
 o getGreenArray
  public int[][] getGreenArray()
This method returns an array[][] of 8-bit green values. The dimensions are the array bounds ex. (320 x 200).
Returns:
s An array[][] of green pixel values.
 o getBlueArray
  public int[][] getBlueArray()
This method returns an array[][] of 8-bit blue values. The dimensions are the array bounds, ex. (320 x 200).
Returns:
s An array[][] of blue pixel values.
 o convertRGBtoY
  public int[][] convertRGBtoY(int redArray[][],
                               int greenArray[][],
                               int blueArray[][])
This method converts an RGB colorspace to a YUV colorspace. (YUV is more technically correct when referred to a YCbCr colorspace.) YCbCr was developed according to recommondation ITU-R BT.601 (Formerly: CCIR 601) to develop a world-wide digital video standard. It is commonly used in many streaming video and compression routines, such as MPEG and H.263.

This routine handles dealing with 0..255 values per pixel, the more common PC format. The passed arrays should all have the same bounds, corresponding to the image dimensions.
Parameters:
redArray - An array of 0..255 red pixel values.
greenArray - An array of 0..255 green pixel values.
blueArray - An array of 0..255 blue pixel values.
Returns:
s Y The Y component
 o convertRGBtoCb
  public int[][] convertRGBtoCb(int redArray[][],
                                int greenArray[][],
                                int blueArray[][])
This method converts an RGB colorspace to a YUV colorspace. (YUV is more technically correct when referred to a YCbCr colorspace.) YCbCr was developed according to recommondation ITU-R BT.601 (Formerly: CCIR 601) to develop a world-wide digital video standard. It is commonly used in many streaming video and compression routines, such as MPEG and H.263.

This routine handles dealing with 0..255 values per pixel, the more common PC format. The passed arrays should all have the same bounds, corresponding to the image dimensions.
Parameters:
redArray - An array of 0..255 red pixel values.
greenArray - An array of 0..255 green pixel values.
blueArray - An array of 0..255 blue pixel values.
Returns:
s Cb The Cb component.
 o convertRGBtoCr
  public int[][] convertRGBtoCr(int redArray[][],
                                int greenArray[][],
                                int blueArray[][])
This method converts an RGB colorspace to a YUV colorspace. (YUV is more technically correct when referred to a YCbCr colorspace.) YCbCr was developed according to recommondation ITU-R BT.601 (Formerly: CCIR 601) to develop a world-wide digital video standard. It is commonly used in many streaming video and compression routines, such as MPEG and H.263.

This routine handles dealing with 0..255 values per pixel, the more common PC format. The passed arrays should all have the same bounds, corresponding to the image dimensions.
Parameters:
redArray - An array of 0..255 red pixel values.
greenArray - An array of 0..255 green pixel values.
blueArray - An array of 0..255 blue pixel values.
Returns:
s Cr The Cr component.
 o convertYCbCrtoR
  public int[][] convertYCbCrtoR(int Y[][],
                                 int Cb[][],
                                 int Cr[][])
This method converts a YUV (aka YCbCr) colorspace to a RGB colorspace. This is handy when trying to reconstruct an image in Java from YCbCr transmitted data. This routine expects the data to fall in the standard PC 0..255 range per pixel, with the array dimensions corresponding to the imageWidth and imageHeight. These variables are either set manually in the case of a null constructor, or they are automatically calculated from the image parameter constructor.
Parameters:
Y - The Y component set.
Cb - The Cb component set.
Cr - The Cr component set.
Returns:
s R The R component.
 o convertYCbCrtoG
  public int[][] convertYCbCrtoG(int Y[][],
                                 int Cb[][],
                                 int Cr[][])
This method converts a YUV (aka YCbCr) colorspace to a RGB colorspace. This is handy when trying to reconstruct an image in Java from YCbCr transmitted data. This routine expects the data to fall in the standard PC 0..255 range per pixel, with the array dimensions corresponding to the imageWidth and imageHeight. These variables are either set manually in the case of a null constructor, or they are automatically calculated from the image parameter constructor.
Parameters:
Y - The Y component set.
Cb - The Cb component set.
Cr - The Cr component set.
Returns:
s G The G component.
 o convertYCbCrtoB
  public int[][] convertYCbCrtoB(int Y[][],
                                 int Cb[][],
                                 int Cr[][])
This method converts a YUV (aka YCbCr) colorspace to a RGB colorspace. This is handy when trying to reconstruct an image in Java from YCbCr transmitted data. This routine expects the data to fall in the standard PC 0..255 range per pixel, with the array dimensions corresponding to the imageWidth and imageHeight. These variables are either set manually in the case of a null constructor, or they are automatically calculated from the image parameter constructor.
Parameters:
Y - The Y component set.
Cb - The Cb component set.
Cr - The Cr component set.
Returns:
s B The B component.
 o convertRGBtoArray
  public int[] convertRGBtoArray(int R[][],
                                 int G[][],
                                 int B[][],
                                 boolean log)
This method converts a 0..255 range pixel matrix to a java-compatible array of 32 bit integers. This method can take a long time to complete so a reporting feature has been added. The arrays should be the same dimensions as imageWidth and imageHeight. This array can then be converted to an image with:
newimage = comp.createImage(new MemoryImageSource(imageWidth,imageHeight,imageArray,0,imageWidth));
Parameters:
R - The Red Values.
G - The Green Values.
B - The Blue Values.
log - Enable/disable progress reporting.
Returns:
s array A one dimensional image array.
 o convertGrayToArray
  public int[] convertGrayToArray(int R[][],
                                  boolean log)
This method converts a single array 0..255 range pixel matrix to a java-compatible array of 32 bit integers. This method can take a long time to complete so a reporting feature has been added. The arrays should be the same dimensions as imageWidth and imageHeight. This array can then be converted to an image with:
newimage = comp.createImage(new MemoryImageSource(imageWidth,imageHeight,imageArray,0,imageWidth));
Parameters:
Array - The pixel values
log - Enable/Disable progress reporting.
Returns:
s array A one dimensional image array.