com.lizardtech.djvu
Class GMap

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

public abstract class GMap
extends DjVuObject
implements java.lang.Cloneable

This is an abstract class for representing pixel maps.

Version:
$Revision: 1.9 $
Author:
Bill C. Riemers

Field Summary
protected  int blueOffset
          The offset to the color blue.
protected  byte[] data
          The raw pixel data.
protected  int greenOffset
          The offset to the color green.
protected  int ncolors
          The number of bytes per pixel
protected  int ncolumns
          The number of columns.
protected  boolean needRamp
          False if we can skip the ramp call.
protected  int nrows
          The number of rows.
 java.util.Hashtable properties
          properties associated with this image map
protected  int redOffset
          The offset to the color red.
 
Fields inherited from class com.lizardtech.djvu.DjVuObject
hasReferences
 
Constructor Summary
GMap(int ncolors, int redOffset, int greenOffset, int blueOffset, boolean needRamp)
          Creates a new GMap object.
 
Method Summary
 java.lang.Object clone()
          Create a copy of this image.
 int columns()
          Query the number of columns in an image.
 GPixelReference createGPixelReference(int offset)
          Create a GPixelReference (a pixel iterator) that refers to this map starting at the specified offset.
 GPixelReference createGPixelReference(int row, int column)
          Create a GPixelReference (a pixel iterator) that refers to this map starting at the specified position.
abstract  void fill(GMap ref, int dx, int dy)
          Insert the reference map at the specified location.
 void fillRGBPixels(int x, int y, int w, int h, int[] pixels, int off, int scansize)
          Fills an array of pixels from the specified values.
 int getBlueOffset()
          Query the data offset for blue pixels.
 int getColorSize()
          Query the bytes per pixel.
 byte[] getData()
          Query the raw data buffer.
 int getGreenOffset()
          Query the data offset for green pixels.
 int getRedOffset()
          Query the data offset for red pixels.
 int getRowSize()
          Query the getRowSize.
 boolean isRampNeeded()
          Query if we are allowed to skip the ramp call.
 GPixel ramp(GPixelReference ref)
          Convert the pixel to 24 bit color.
 int rowOffset(int row)
          Query the start offset of a row.
 int rows()
          Query the number of rows in an image.
abstract  GMap translate(int dx, int dy, GMap retval)
          Shift the origin of the image by coping the pixel data.
 
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

properties

public final java.util.Hashtable properties
properties associated with this image map


ncolors

protected final int ncolors
The number of bytes per pixel


redOffset

protected final int redOffset
The offset to the color red.


greenOffset

protected final int greenOffset
The offset to the color green.


blueOffset

protected final int blueOffset
The offset to the color blue.


ncolumns

protected int ncolumns
The number of columns.


nrows

protected int nrows
The number of rows.


needRamp

protected final boolean needRamp
False if we can skip the ramp call.


data

protected byte[] data
The raw pixel data.

Constructor Detail

GMap

public GMap(int ncolors,
            int redOffset,
            int greenOffset,
            int blueOffset,
            boolean needRamp)
Creates a new GMap object.

Method Detail

columns

public final int columns()
Query the number of columns in an image.

Returns:
the number of columns

fill

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

Parameters:
ref - map to insert
dx - horizontal position to insert at
dy - vertical position to insert at

fillRGBPixels

public void fillRGBPixels(int x,
                          int y,
                          int w,
                          int h,
                          int[] pixels,
                          int off,
                          int scansize)
Fills an array of pixels from the specified values.

Parameters:
x - the x-coordinate of the upper-left corner of the region of pixels
y - the y-coordinate of the upper-left corner of the region of pixels
w - the width of the region of pixels
h - the height of the region of pixels
pixels - the array of pixels
off - the offset into the pixel array
scansize - the distance from one row of pixels to the next in the array

rows

public final int rows()
Query the number of rows in an image.

Returns:
the number of rows

translate

public abstract GMap translate(int dx,
                               int dy,
                               GMap retval)
Shift the origin of the image by coping the pixel data.

Parameters:
dx - amount to shift the origin of the x-axis
dy - amount to shift the origin of the y-axis
retval - the image to copy the data into
Returns:
the translated image

clone

public java.lang.Object clone()
Create a copy of this image.

Overrides:
clone in class java.lang.Object
Returns:
The newly created copy.

getData

public final byte[] getData()
Query the raw data buffer.

Returns:
the array of pixels

rowOffset

public int rowOffset(int row)
Query the start offset of a row.

Parameters:
row - the row to query
Returns:
the offset to the pixel data

getRowSize

public int getRowSize()
Query the getRowSize.

Returns:
the getRowSize

getColorSize

public final int getColorSize()
Query the bytes per pixel.

Returns:
the number of bytes per pixel

getRedOffset

public final int getRedOffset()
Query the data offset for red pixels.

Returns:
red data offset

getGreenOffset

public final int getGreenOffset()
Query the data offset for green pixels.

Returns:
the number of bytes per pixel

getBlueOffset

public final int getBlueOffset()
Query the data offset for blue pixels.

Returns:
the number of bytes per pixel

createGPixelReference

public GPixelReference createGPixelReference(int offset)
Create a GPixelReference (a pixel iterator) that refers to this map starting at the specified offset.

Parameters:
offset - position of the first pixel to reference
Returns:
the newly created GPixelReference

createGPixelReference

public GPixelReference createGPixelReference(int row,
                                             int column)
Create a GPixelReference (a pixel iterator) that refers to this map starting at the specified position.

Parameters:
row - initial vertical position
column - initial horizontal position
Returns:
the newly created GPixelReference

ramp

public GPixel ramp(GPixelReference ref)
Convert the pixel to 24 bit color.

Returns:
the converted pixel

isRampNeeded

public boolean isRampNeeded()
Query if we are allowed to skip the ramp call. This call can be used to help optimize loops.

Returns:
true if not 24 bit color