|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ach.image.EMemImageSource
EMemImageSource.java
Copyright (c) 1997-2003 Helge Hackbarth, All Rights Reserved.
EMemImageSource extends MemoryImageSource to allow direct access to
pixels and colormodel. The class offers several methods to extract
and scale regions of a memory image very fast.
Depending on the colormodel the image data will be stored either
in an integer array or a byte array. If the mapsize of the colormodel
is equal or less 16 (4 bit or less), the image data will be stored
as packed bytes (4 or 1 bit per pixel) to reduce memory consumption.
THE AUTHOR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY
OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE, OR NON-INFRINGEMENT. THE AUTHOR SHALL NOT BE LIABLE FOR ANY
DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
Field Summary | |
byte[] |
bytePixels
Array containing the image data if created for a palette image with 8 bits per pixel (256 colors or gray levels) |
java.awt.image.ColorModel |
colorModel
The colormodel of the image represented by this ImageProducer |
java.lang.String |
errorMsg
The only way to communicate the last error to the rest of the world when this EMemImageSource consumed its image data from an ImageProducer. |
int |
height
vertical number of pixels of the image represented by this ImageProducer |
int |
horizDpi
Horizontal resolution in pixels per inch. |
int[] |
intPixels
Array containing the image data if created for a true color image |
int |
numPages
Indicates the number of pages of the image file that was producing this EMemImageSource (default = 1). |
java.awt.image.ColorModel |
origColorModel
The colormodel used at consumer initialization (might be changed during pixel consumption due to memory optimization) |
byte[] |
packedPixels
Array containing the packed image data if created for a palette image with 1 or 4 bits per pixel (2 or 16 colors or gray levels) |
int |
page
Indicating current page of a multi document image file kept in memory by this instance of EMemImageSource (default = 1). |
int |
pixeloffset
Offset to first valid pixel in the array |
int |
pixelscan
Number of elements per row. |
java.awt.Rectangle |
printArea
Rectangle to store parameters of last print operation |
boolean |
useProdGauge
Flag if producer shall show a gauge during image production |
int |
vertDpi
Vertical resolution in pixels per inch. |
int |
width
horizontal number of pixels of the image represented by this ImageProducer |
Fields inherited from interface java.awt.image.ImageConsumer |
COMPLETESCANLINES, IMAGEABORTED, IMAGEERROR, RANDOMPIXELORDER, SINGLEFRAME, SINGLEFRAMEDONE, SINGLEPASS, STATICIMAGEDONE, TOPDOWNLEFTRIGHT |
Constructor Summary | |
EMemImageSource(java.awt.image.ImageProducer producer,
boolean useGauge)
Constructor to be used if image will be created from ImageProducer through ImageConsumer interface. |
|
EMemImageSource(java.awt.image.ImageProducer producer,
ImgComponentIntf imgComponent,
java.awt.Toolkit toolkit,
int scaleHint)
Constructor to be used if image will be created from ImageProducer through ImageConsumer interface. |
|
EMemImageSource(int w,
int h,
java.awt.image.ColorModel cm,
byte[] pixels,
int off,
int scan,
int hDpi,
int vDpi)
Constructor to create a memory image for palette image data with byte pixels (8 bits per pixel). |
|
EMemImageSource(int w,
int h,
java.awt.image.ColorModel cm,
byte[] pPixels,
int bpp,
int off,
int scan,
int hDpi,
int vDpi)
Constructor to create a memory image for packed image data where pixels are stored in bytes packed on bit level (1 or 4 bits per pixel). |
|
EMemImageSource(int w,
int h,
java.awt.image.ColorModel cm,
int[] pixels,
int off,
int scan,
int hDpi,
int vDpi)
Constructor to create a memory image for true color image data with int pixels (32 bits per pixel). |
Method Summary | |
void |
abort()
Image consumption will abort at next call to setpixels |
void |
addConsumer(java.awt.image.ImageConsumer ic)
Adds an ImageConsumer to the list of consumers interested in data for this image. |
int |
calcPixelSize()
Calculate number of bits per pixel according to mapSize of ColorModel For IndexColorModels this will be 2 ^ getMapSize(), for other ColorModels this will be equal to ColorModel.getPixelSize() |
EMemImageSource |
extractMemImgRegion(int x,
int y,
int w,
int h)
Extract memory image region as a new ImageProducer from an EMemImageSource without scaling. |
java.awt.image.ImageProducer |
extractMemImgRegion(int x,
int y,
int w,
int h,
int wNew,
int hNew)
Extract memory image region as a new ImageProducer from an EMemImageSource and scale to new dimension (with automatic gray scaling (antialiasing) for bilevel images). |
void |
flipVertical()
flip image vertical (self-inverse) |
EMemImageSource |
getRotated090()
Rotate image by 90 degree and return a instance of EMemImageSource; for 180 degree rotation see self inverse method rotate180() |
EMemImageSource |
getRotated270()
Rotate image by 270 degree and return a instance of EMemImageSource; for 180 degree rotation see self inverse method rotate180() |
void |
imageComplete(int status)
ImageConsumers call back method to be informed about ImageProducers completion status. |
void |
invert()
invert image (if palette bitmap: invert colormap, else: invert each pixel) |
boolean |
isComplete()
Determine whether consumption of an image from an ImageProducer to memory is completed as this is carried out asynchronously in an independent thread. |
boolean |
isConsumer(java.awt.image.ImageConsumer ic)
Determine if an ImageConsumer is on the list of consumers currently interested in data for this image. |
boolean |
isInitialized()
Determine whether initialization of memory image is completed |
void |
mirrorHorizontal()
mirror image horizontal (self-inverse) |
void |
removeConsumer(java.awt.image.ImageConsumer ic)
Remove an ImageConsumer from the list of consumers interested in data for this image. |
void |
requestTopDownLeftRightResend(java.awt.image.ImageConsumer ic)
Requests that a given ImageConsumer have the image data delivered * one more time in top-down, left-right order. |
void |
rotate180()
rotate image by 180 degree (self-inverse function); see also getRotated090() and getRotated270() |
void |
run()
Can be used to call an ImageProducers startProduction method via an asynchronous thread. |
void |
setColorModel(java.awt.image.ColorModel model)
The ColorModel object used for the majority of the pixels reported using the setPixels method calls. |
void |
setDimensions(int width,
int height)
The dimensions of the source image are reported using the setDimensions method call. |
void |
setHints(int hints)
The ImageProducer can deliver the pixels in any order, but * the ImageConsumer may be able to scale or convert the pixels * to the destination ColorModel more efficiently or with higher * quality if it knows some information about how the pixels will * be delivered up front. |
void |
setPixels(int x,
int y,
int w,
int h,
java.awt.image.ColorModel model,
byte[] pixels,
int off,
int scansize)
Set an array of bytes. |
void |
setPixels(int x,
int y,
int w,
int h,
java.awt.image.ColorModel model,
int[] pixels,
int off,
int scansize)
Set an array of integers. |
void |
setProperties(java.util.Hashtable props)
Sets the extensible list of properties associated with this image. |
void |
startProduction(java.awt.image.ImageConsumer ic)
Adds an ImageConsumer to the list of consumers interested in data for this image, and immediately start delivery of the image data through the ImageConsumer interface. |
java.lang.String |
toString()
|
EMemImageSource |
unskew()
unskew image if horizontal and vertical resolution is different image will be scaled so that both resolutions are equal to the higher resolution. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public int width
public int height
public java.awt.image.ColorModel colorModel
ColorModel
public java.awt.image.ColorModel origColorModel
ColorModel
public int[] intPixels
public byte[] bytePixels
public byte[] packedPixels
public int pixeloffset
public int pixelscan
public int horizDpi
public int vertDpi
public int numPages
public int page
public java.awt.Rectangle printArea
public java.lang.String errorMsg
public boolean useProdGauge
Constructor Detail |
public EMemImageSource(java.awt.image.ImageProducer producer, boolean useGauge)
producer
- an ImageProduceruseGauge
- set true, if a gauge should be displayed during image consumptionpublic EMemImageSource(java.awt.image.ImageProducer producer, ImgComponentIntf imgComponent, java.awt.Toolkit toolkit, int scaleHint)
producer
- an ImageProducerimgComponent
- implementing ImgComponentIntf to display image during loading processtoolkit
- to provide an awt.image.Toolkit to load imagesscaleHint
- to conrol scaling behavior (e.g. Image.SCALE_FAST or Image.SCALE_SMOOTH)ImgCanvas
public EMemImageSource(int w, int h, java.awt.image.ColorModel cm, byte[] pixels, int off, int scan, int hDpi, int vDpi)
w
- width of the imageh
- height of the imagecm
- ColorModel for this imagepixels
- byte-array containing the image dataoff
- offset to the first valid pixel in the arrayscan
- number of elements per rowhDpi
- horizontal resolution in pixels per inchvDpi
- vertical resolution in pixels per inchpublic EMemImageSource(int w, int h, java.awt.image.ColorModel cm, int[] pixels, int off, int scan, int hDpi, int vDpi)
w
- width of the imageh
- height of the imagecm
- ColorModel for this imagepixels
- int-array containing the image dataoff
- offset to the first valid pixel in the arrayscan
- number of elements per rowhDpi
- horizontal resolution in pixels per inchvDpi
- vertical resolution in pixels per inchpublic EMemImageSource(int w, int h, java.awt.image.ColorModel cm, byte[] pPixels, int bpp, int off, int scan, int hDpi, int vDpi)
w
- width of the imageh
- height of the imagecm
- ColorModel for this imagepPixels
- byte-array containing packed image databpp
- bits per pixel (supported values: 1 or 4)off
- offset to the first valid pixel in the array (counted in bytes)scan
- number of elements per rowhDpi
- horizontal resolution in pixels per inchvDpi
- vertical resolution in pixels per inchMethod Detail |
public void run()
run
in interface java.lang.Runnable
public void addConsumer(java.awt.image.ImageConsumer ic)
addConsumer
in interface java.awt.image.ImageProducer
ImageConsumer
public boolean isConsumer(java.awt.image.ImageConsumer ic)
isConsumer
in interface java.awt.image.ImageProducer
ImageConsumer
public void removeConsumer(java.awt.image.ImageConsumer ic)
removeConsumer
in interface java.awt.image.ImageProducer
ImageConsumer
public void startProduction(java.awt.image.ImageConsumer ic)
startProduction
in interface java.awt.image.ImageProducer
ImageConsumer
public void requestTopDownLeftRightResend(java.awt.image.ImageConsumer ic)
requestTopDownLeftRightResend
in interface java.awt.image.ImageProducer
public void setDimensions(int width, int height)
setDimensions
in interface java.awt.image.ImageConsumer
public void setProperties(java.util.Hashtable props)
setProperties
in interface java.awt.image.ImageConsumer
public void setColorModel(java.awt.image.ColorModel model)
setColorModel
in interface java.awt.image.ImageConsumer
ColorModel
public void setHints(int hints)
setHints
in interface java.awt.image.ImageConsumer
public void setPixels(int x, int y, int w, int h, java.awt.image.ColorModel model, byte[] pixels, int off, int scansize)
setPixels
in interface java.awt.image.ImageConsumer
ImageConsumer.setPixels(int, int, int, int, java.awt.image.ColorModel, byte[], int, int)
public void setPixels(int x, int y, int w, int h, java.awt.image.ColorModel model, int[] pixels, int off, int scansize)
setPixels
in interface java.awt.image.ImageConsumer
ImageConsumer.setPixels(int, int, int, int, java.awt.image.ColorModel, byte[], int, int)
public void imageComplete(int status)
imageComplete
in interface java.awt.image.ImageConsumer
ImageConsumer.imageComplete(int)
public void abort()
public boolean isInitialized()
public boolean isComplete()
public int calcPixelSize()
public java.lang.String toString()
toString
in class java.lang.Object
public EMemImageSource extractMemImgRegion(int x, int y, int w, int h)
x
- horizontal offset of extracted image relative to source imagey
- vertical offset of extracted image relative to source imagew
- width of extracted imageh
- height of extracted imagepublic java.awt.image.ImageProducer extractMemImgRegion(int x, int y, int w, int h, int wNew, int hNew)
x
- horizontal offset of extracted image relative to source imagey
- vertical offset of extracted image relative to source imagew
- horizontal number of pixels extracted from source imageh
- vertical number of pixels extracted from source imagewNew
- scaled width of extracted imagehNew
- scaled height of extracted imagepublic EMemImageSource unskew()
public void invert()
public void rotate180()
public EMemImageSource getRotated090()
public EMemImageSource getRotated270()
public void flipVertical()
public void mirrorHorizontal()
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |