net.sourceforge.jiu.data

Class MemoryBilevelImage

Implemented Interfaces:
BilevelImage, GrayImage, GrayIntegerImage, IntegerImage, PixelImage

public class MemoryBilevelImage
extends java.lang.Object
implements BilevelImage

An implementation of the BilevelImage interface that stores image data in a byte array in memory. An image of width times height pixels will require (width + 7) / 8 * height bytes of memory.
Author:
Marco Schmidt

Field Summary

private int
BYTES_PER_ROW
private int
HEIGHT
private int
WIDTH
private byte[]
data

Fields inherited from interface net.sourceforge.jiu.data.BilevelImage

BLACK, WHITE

Constructor Summary

MemoryBilevelImage(int width, int height)
Create a new MemoryBilevelImage object with the specified resolution.

Method Summary

private void
checkBitOffset(int bitOffset)
private void
checkPositionAndNumber(int x, int y, int w, int h)
private void
checkValue(int value)
void
clear(int newValue)
void
clear(int channelIndex, int newValue)
PixelImage
createCompatibleImage(int width, int height)
PixelImage
createCopy()
long
getAllocatedMemory()
int
getBitsPerPixel()
int
getHeight()
Class
getImageType()
int
getMaxSample(int channelIndex)
int
getNumChannels()
void
getPackedBytes(int x, int y, int numSamples, byte[] dest, int destOffset, int destBitOffset)
int
getSample(int x, int y)
int
getSample(int channelIndex, int x, int y)
void
getSamples(int channelIndex, int x, int y, int w, int h, int[] dest, int destOffset)
int
getWidth()
boolean
isBlack(int x, int y)
boolean
isWhite(int x, int y)
void
putBlack(int x, int y)
void
putPackedBytes(int x, int y, int numSamples, byte[] src, int srcOffset, int srcBitOffset)
void
putSample(int x, int y, int newValue)
void
putSample(int channelIndex, int x, int y, int newValue)
void
putSamples(int channelIndex, int x, int y, int w, int h, int[] src, int srcOffset)
void
putWhite(int x, int y)

Field Details

BYTES_PER_ROW

private final int BYTES_PER_ROW

HEIGHT

private final int HEIGHT

WIDTH

private final int WIDTH

data

private final byte[] data

Constructor Details

MemoryBilevelImage

public MemoryBilevelImage(int width,
                          int height)
Create a new MemoryBilevelImage object with the specified resolution.
Parameters:
width - the horizontal resolution of the new image, must be larger than zero
height - the vertical resolution of the new image, must be larger than zero

Method Details

checkBitOffset

private void checkBitOffset(int bitOffset)

checkPositionAndNumber

private void checkPositionAndNumber(int x,
                                    int y,
                                    int w,
                                    int h)

checkValue

private void checkValue(int value)

clear

public void clear(int newValue)
Specified by:
clear in interface IntegerImage

clear

public void clear(int channelIndex,
                  int newValue)
Specified by:
clear in interface IntegerImage

createCompatibleImage

public PixelImage createCompatibleImage(int width,
                                        int height)
Specified by:
createCompatibleImage in interface PixelImage

createCopy

public PixelImage createCopy()
Specified by:
createCopy in interface PixelImage

getAllocatedMemory

public long getAllocatedMemory()
Specified by:
getAllocatedMemory in interface PixelImage

getBitsPerPixel

public int getBitsPerPixel()
Specified by:
getBitsPerPixel in interface PixelImage

getHeight

public int getHeight()
Specified by:
getHeight in interface PixelImage

getImageType

public Class getImageType()
Specified by:
getImageType in interface PixelImage

getMaxSample

public int getMaxSample(int channelIndex)
Specified by:
getMaxSample in interface IntegerImage

getNumChannels

public int getNumChannels()
Specified by:
getNumChannels in interface PixelImage

getPackedBytes

public void getPackedBytes(int x,
                           int y,
                           int numSamples,
                           byte[] dest,
                           int destOffset,
                           int destBitOffset)
Specified by:
getPackedBytes in interface BilevelImage

getSample

public int getSample(int x,
                     int y)
Specified by:
getSample in interface IntegerImage

getSample

public int getSample(int channelIndex,
                     int x,
                     int y)
Specified by:
getSample in interface IntegerImage

getSamples

public void getSamples(int channelIndex,
                       int x,
                       int y,
                       int w,
                       int h,
                       int[] dest,
                       int destOffset)
Specified by:
getSamples in interface IntegerImage

getWidth

public int getWidth()
Specified by:
getWidth in interface PixelImage

isBlack

public boolean isBlack(int x,
                       int y)
Specified by:
isBlack in interface GrayImage

isWhite

public boolean isWhite(int x,
                       int y)
Specified by:
isWhite in interface GrayImage

putBlack

public void putBlack(int x,
                     int y)
Specified by:
putBlack in interface GrayImage

putPackedBytes

public void putPackedBytes(int x,
                           int y,
                           int numSamples,
                           byte[] src,
                           int srcOffset,
                           int srcBitOffset)
Specified by:
putPackedBytes in interface BilevelImage

putSample

public void putSample(int x,
                      int y,
                      int newValue)
Specified by:
putSample in interface IntegerImage

putSample

public void putSample(int channelIndex,
                      int x,
                      int y,
                      int newValue)
Specified by:
putSample in interface IntegerImage

putSamples

public void putSamples(int channelIndex,
                       int x,
                       int y,
                       int w,
                       int h,
                       int[] src,
                       int srcOffset)
Specified by:
putSamples in interface IntegerImage

putWhite

public void putWhite(int x,
                     int y)
Specified by:
putWhite in interface GrayImage