com.lizardtech.djvu
Class GPixmap

java.lang.Object
  extended by com.lizardtech.djvu.DjVuObject
      extended by com.lizardtech.djvu.GMap
          extended by com.lizardtech.djvu.GPixmap
All Implemented Interfaces:
DjVuInterface, java.lang.Cloneable

public class GPixmap
extends GMap
implements java.lang.Cloneable

This class represents 24 bit color image maps.

Version:
$ $
Author:
Bill C. Riemers

Field Summary
protected static byte[] clip
          Used to quickly clip out of bounds values.
protected static int[] ctable
          Cached color correction table.
protected static int[] ctableI
          Indentity color correction table.
protected static int[] invmap
          Used to represent division as multiplication.
protected static double lgamma
          The color correction subsample for the cached color table.
protected static java.lang.Object[] multiplierRefArray
          Used for attenuation
 
Fields inherited from class com.lizardtech.djvu.GMap
blueOffset, data, greenOffset, ncolors, ncolumns, needRamp, nrows, properties, redOffset
 
Fields inherited from class com.lizardtech.djvu.DjVuObject
hasReferences
 
Constructor Summary
GPixmap()
          Creates a new GPixmap object.
 
Method Summary
 void applyGammaCorrection(double gamma)
          Correct the colors with a gamma subsample normalized to 1.0 for no correction.
 void attenuate(GBitmap bm, int xpos, int ypos)
          Attenuate the specified bitmap.
 void blit(GBitmap bm, int xpos, int ypos, GPixel color)
          Insert the specified bitmap with the specified color.
static GPixmap createGPixmap(DjVuInterface ref)
          Creates an instance of GPixmap with the options interherited from the specified reference.
 void downsample(GMap src, int subsample, GRect pdr)
          Fill this image from another source at reduced resolution.
 void downsample43(GMap src, GRect pdr)
          Fill this image from another source at reduced resolution of 4 vertical pixels to 3.
 void fill(GMap ref, int dx, int dy)
          Insert the reference map at the specified location.
static int[] getColorCorrection(double gamma)
          Fill the array with color correction constants.
protected static int[] getMultiplier(int maxgray)
          Creates or retrieves a cached multiplier array to use when attenuating.
 GPixmap init(GMap ref)
          Initialize this pixmap from another image map.
 GPixmap init(GMap ref, GRect rect)
          Initialize this pixmap from a segment of another image map.
 GPixmap init(int arows, int acolumns, GPixel filler)
          Initialize this pixmap to the specified size and fill in the specified color.
 void stencil(GBitmap mask, GPixmap foregroundMap, int supersample, int subsample, GRect bounds, double gamma)
          Draw the foreground layer onto this background image.
 GMap translate(int dx, int dy, GMap retval)
          Copy this image with a translated origin.
 
Methods inherited from class com.lizardtech.djvu.GMap
clone, columns, createGPixelReference, createGPixelReference, fillRGBPixels, getBlueOffset, getColorSize, getData, getGreenOffset, getRedOffset, getRowSize, isRampNeeded, ramp, rowOffset, rows
 
Methods inherited from class com.lizardtech.djvu.DjVuObject
checkLockTime, create, create, createSoftReference, createWeakReference, getDjVuOptions, getFromReference, invoke, setDjVuOptions
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

invmap

protected static final int[] invmap
Used to represent division as multiplication.


ctableI

protected static final int[] ctableI
Indentity color correction table.


ctable

protected static int[] ctable
Cached color correction table.


lgamma

protected static double lgamma
The color correction subsample for the cached color table.


clip

protected static final byte[] clip
Used to quickly clip out of bounds values.


multiplierRefArray

protected static final java.lang.Object[] multiplierRefArray
Used for attenuation

Constructor Detail

GPixmap

public GPixmap()
Creates a new GPixmap object.

Method Detail

createGPixmap

public static GPixmap createGPixmap(DjVuInterface ref)
Creates an instance of GPixmap with the options interherited from the specified reference.

Parameters:
ref - Object to interherit DjVuOptions from.
Returns:
a new instance of GPixmap.

getColorCorrection

public static int[] getColorCorrection(double gamma)
Fill the array with color correction constants.

Parameters:
gamma - color correction subsample
Returns:
the new color correction table

getMultiplier

protected static int[] getMultiplier(int maxgray)
Creates or retrieves a cached multiplier array to use when attenuating.

Returns:
attenuation array

attenuate

public void attenuate(GBitmap bm,
                      int xpos,
                      int ypos)
Attenuate the specified bitmap.

Parameters:
bm - Bitmap to attenuate
xpos - horizontal position
ypos - vertical position

blit

public void blit(GBitmap bm,
                 int xpos,
                 int ypos,
                 GPixel color)
Insert the specified bitmap with the specified color.

Parameters:
bm - bitmap to insert
xpos - horizontal position
ypos - vertical position
color - color to insert bitmap with

applyGammaCorrection

public final void applyGammaCorrection(double gamma)
Correct the colors with a gamma subsample normalized to 1.0 for no correction.

Parameters:
gamma - color correction

downsample

public void downsample(GMap src,
                       int subsample,
                       GRect pdr)
Fill this image from another source at reduced resolution. Pixel averaging will be used.

Parameters:
src - image map to reduce
subsample - rate to subsample
pdr - target bounds

downsample43

public void downsample43(GMap src,
                         GRect pdr)
Fill this image from another source at reduced resolution of 4 vertical pixels to 3. An extrapulating pixel averaging algorithm is used.

Parameters:
src - image map to reduce
pdr - target bounds
Throws:
java.lang.IllegalArgumentException - if the target rectangle is out of bounds

fill

public void fill(GMap ref,
                 int dx,
                 int dy)
Insert the reference map at the specified location.

Specified by:
fill in class GMap
Parameters:
ref - map to insert
dx - horizontal position to insert at
dy - vertical position to insert at

init

public GPixmap init(int arows,
                    int acolumns,
                    GPixel filler)
Initialize this pixmap to the specified size and fill in the specified color.

Parameters:
arows - number of rows
acolumns - number of columns
filler - fill color
Returns:
the initialized pixmap

init

public GPixmap init(GMap ref,
                    GRect rect)
Initialize this pixmap from a segment of another image map.

Parameters:
ref - image map to initialize from
rect - bounding rectangle to initialize from
Returns:
the initialized pixmap

init

public GPixmap init(GMap ref)
Initialize this pixmap from another image map.

Parameters:
ref - image map to initialize from
Returns:
the initialized pixmap

stencil

public void stencil(GBitmap mask,
                    GPixmap foregroundMap,
                    int supersample,
                    int subsample,
                    GRect bounds,
                    double gamma)
Draw the foreground layer onto this background image.

Parameters:
mask - the mask layer
foregroundMap - the foreground colors
supersample - rate to upsample the foreground colors
subsample - rate to subsample the foreground colors
bounds - the target rectangle
gamma - color correction factor
Throws:
java.lang.IllegalArgumentException - if the specified bounds are not contained in the page

translate

public GMap translate(int dx,
                      int dy,
                      GMap retval)
Copy this image with a translated origin.

Specified by:
translate in class GMap
Parameters:
dx - horizontal distance to translate
dy - vertical distance to translate
retval - an old image to try and reuse for the return value
Returns:
the translated image