Horus Doc || Java GUI Reference || Doxygen's quick Index  

ImageBuffer Class Reference

List of all members.

Public Methods

 ImageBuffer (int[] pixels, int w, int h)
 ImageBuffer (Image img, int w, int h)
int[] getPixels ()
int getWidth ()
int getHeight ()
void fill (int[] pixels, int width, int height)
void fill (Image img, int width, int height)
Image toImage ()
int getPixelIntValue (int x, int y)
int[] getPixelARGBValue (int x, int y)

Constructor & Destructor Documentation

ImageBuffer::ImageBuffer int    pixels[],
int    w,
int    h
[inline]
 

00031     {
00032         fill(pixels, w, h);
00033     }

ImageBuffer::ImageBuffer Image    img,
int    w,
int    h
[inline]
 

00037     {
00038         fill(img, w, h);
00039     }


Member Function Documentation

int [] ImageBuffer::getPixels   [inline]
 

00046     {
00047         return pixels;
00048     }

int ImageBuffer::getWidth   [inline]
 

00052     {
00053         return width;
00054     }

int ImageBuffer::getHeight   [inline]
 

00058     {
00059         return height;
00060     }

void ImageBuffer::fill int    pixels[],
int    width,
int    height
[inline]
 

00064     {
00065         this.pixels = pixels;
00066         this.width  = width;
00067         this.height = height;
00068     }

void ImageBuffer::fill Image    img,
int    width,
int    height
[inline]
 

00072     {
00073         this.width  = width;
00074         this.height = height;
00075         pixels = new int[width * height];
00076 
00077         PixelGrabber pg =
00078             new PixelGrabber(img, 0, 0, width, height, pixels, 0, width);
00079 
00080         try {
00081             pg.grabPixels();
00082         } catch (InterruptedException e) {
00083             pixels = null;
00084             return;
00085         }
00086 
00087         if ((pg.getStatus() & ImageObserver.ABORT) != 0) {
00088             pixels = null;
00089         }
00090     }

Image ImageBuffer::toImage   [inline]
 

00094     {
00095         return createImage(new MemoryImageSource(width, height,
00096                                                  pixels, 0, width));
00097     }

int ImageBuffer::getPixelIntValue int    x,
int    y
[inline]
 

00101     {
00102         if (pixels == null || x < 0
00103                            || y < 0 || x >= width || y >= height ) {
00104             return -1;
00105         }
00106         return (pixels[width*y + x]);
00107     }

int [] ImageBuffer::getPixelARGBValue int    x,
int    y
[inline]
 

00111     {
00112         if (pixels == null || x < 0
00113                            || y < 0 || x >= width || y >= height ) {
00114             return null;
00115         }
00116 
00117         int[] value = new int[4];
00118 
00119         value[0] = (pixels[width*y + x] >> 24) & 0xff;
00120         value[1] = (pixels[width*y + x] >> 16) & 0xff;
00121         value[2] = (pixels[width*y + x] >>  8) & 0xff;
00122         value[3] = (pixels[width*y + x]      ) & 0xff;
00123         return value;
00124     }


The documentation for this class was generated from the following file:
Generated on Tue Feb 3 14:19:45 2004 for JavaReference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001