com.lizardtech.djvu
Class GBitmap

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

public class GBitmap
extends GMap
implements java.lang.Cloneable

This class represents bitonal and gray scale pixel images.

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

Field Summary
protected  int grays
          Color depth
 
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
GBitmap()
          Creates a new GBitmap object.
 
Method Summary
 boolean blit(GBitmap bm, int xh, int yh, int subsample)
          Insert another bitmap at the specified location.
 GRect compute_bounding_box()
          Find the bounding box for non-white pixels.
static GBitmap createGBitmap(DjVuInterface ref)
          Creates an instance of GBitmap with the options interherited from the specified reference.
 void fill(GMap ref, int dx, int dy)
          Insert the reference map at the specified location.
 void fill(short value)
          Set the value of all pixels.
 boolean getBooleanAt(int offset)
          Query a pixel as boolean
protected  int getBorder()
          Query the border width.
 int getByteAt(int offset)
          Query the pixel at a particular location
 int getBytesPerRow()
          Query the number of bytes per row.
 int getGrays()
          Query the color depth.
 GPixel[] getRamp()
           
 int getRowSize()
          Query the number of bytes per row.
 GBitmap init(GBitmap ref)
          Initialize this map by copying a reference map
 GBitmap init(GBitmap ref, GRect rect, int border)
          /** Initialize this map by copying a reference map
 GBitmap init(GBitmap ref, int aborder)
          Initialize this map by copying a reference map
 GBitmap init(int arows, int acolumns, int aborder)
          Initialize this image with the specified values.
 boolean insertMap(GBitmap bit, int dx, int dy, boolean doBlit)
          Insert the reference map at the specified location.
 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.
 void setByteAt(int offset, int value)
          Set the pixel value.
 void setGrays(int ngrays)
          Set the color depth
 void setMinimumBorder(int minimum)
          Set the minimum border needed
 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.GMap
clone, columns, createGPixelReference, createGPixelReference, fillRGBPixels, getBlueOffset, getColorSize, getData, getGreenOffset, getRedOffset, 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

grays

protected int grays
Color depth

Constructor Detail

GBitmap

public GBitmap()
Creates a new GBitmap object.

Method Detail

getRamp

public GPixel[] getRamp()

createGBitmap

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

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

getBooleanAt

public final boolean getBooleanAt(int offset)
Query a pixel as boolean

Parameters:
offset - position to query
Returns:
true if zero

setByteAt

public final void setByteAt(int offset,
                            int value)
Set the pixel value.

Parameters:
offset - position of the pixel to set
value - gray scale value to set

getByteAt

public final int getByteAt(int offset)
Query the pixel at a particular location

Parameters:
offset - the pixel location
Returns:
the gray scale value

getBytesPerRow

public int getBytesPerRow()
Query the number of bytes per row.

Returns:
the number of bytes per row

getGrays

public final int getGrays()
Query the color depth.

Returns:
number of grays

setGrays

public void setGrays(int ngrays)
Set the color depth

Parameters:
ngrays - number of grays
Throws:
java.lang.IllegalArgumentException - if the number of grays is less than 2 or greater than 256

blit

public boolean blit(GBitmap bm,
                    int xh,
                    int yh,
                    int subsample)
Insert another bitmap at the specified location. Note that both bitmaps need to have the same number of grays.

Parameters:
bm - bitmap to insert
xh - horizontal location to insert at
yh - vertical location to insert at
subsample - rate to subsample at
Returns:
true if the blit intersected this bitmap

rowOffset

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

Overrides:
rowOffset in class GMap
Parameters:
row - the row to query
Returns:
the offset to the pixel data

getRowSize

public final int getRowSize()
Query the number of bytes per row.

Overrides:
getRowSize in class GMap
Returns:
bytes per row

fill

public void fill(short value)
Set the value of all pixels.

Parameters:
value - gray scale value to assign to all pixels

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

insertMap

public boolean insertMap(GBitmap bit,
                         int dx,
                         int dy,
                         boolean doBlit)
Insert the reference map at the specified location.

Parameters:
bit - map to insert
dx - horizontal position to insert at
dy - vertical position to insert at
doBlit - true if the gray scale values should be added
Returns:
true if pixels are inserted

init

public GBitmap init(int arows,
                    int acolumns,
                    int aborder)
Initialize this image with the specified values.

Parameters:
arows - number of rows
acolumns - number of columns
aborder - width of the border
Returns:
the initialized image map

init

public final GBitmap init(GBitmap ref)
Initialize this map by copying a reference map

Parameters:
ref - map to copy
Returns:
the initialized map

init

public GBitmap init(GBitmap ref,
                    int aborder)
Initialize this map by copying a reference map

Parameters:
ref - map to copy
aborder - number of border pixels
Returns:
the initialized map

init

public GBitmap init(GBitmap ref,
                    GRect rect,
                    int border)
/** Initialize this map by copying a reference map

Parameters:
ref - map to copy
rect - area to copy
border - number of border pixels
Returns:
the initialized map

setMinimumBorder

public void setMinimumBorder(int minimum)
Set the minimum border needed

Parameters:
minimum - the minumum border needed

translate

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

Specified by:
translate in class GMap
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

getBorder

protected final int getBorder()
Query the border width.

Returns:
the border width

ramp

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

Overrides:
ramp in class GMap
Returns:
the converted pixel

isRampNeeded

public boolean isRampNeeded()
Query if we are allowed to skip the ramp call.

Overrides:
isRampNeeded in class GMap
Returns:
true if not 24 bit color

compute_bounding_box

public GRect compute_bounding_box()
Find the bounding box for non-white pixels.

Returns:
bounding rectangle