JIU 0.14.3

net.sourceforge.jiu.data
Interface ByteChannelImage

All Superinterfaces:
IntegerImage, PixelImage
All Known Subinterfaces:
Gray8Image, Paletted8Image, RGB24Image
All Known Implementing Classes:
BufferedRGB24Image, MemoryByteChannelImage, MemoryGray8Image, MemoryPaletted8Image, MemoryRGB24Image

public interface ByteChannelImage
extends IntegerImage

An extension of the IntegerImage interface that restricts the image to byte samples. The minimum sample value for all channels is 0, the maximum sample value 255.

Number of channels and resolution must be given to the constructor and cannot be changed after creation.

Each channel of the image is made up of byte values. Note that bytes in Java are signed, they can take values from -128 to 127. If you use IntegerImage's getSample and putSample methods you don't have to deal with this, you always get int samples that are in the 0 .. 255 interval.

To manually convert a Java byte value to an int value in the range of 0 to 255, do the following:

 byte b = ...; // initialize byte value
 int i = b & 0xff; 
 // i now is a value between 0 and 255
 

Author:
Marco Schmidt

Method Summary
 void clear(byte newValue)
          Sets all samples of the first channel to the argument byte value.
 void clear(int channelIndex, byte newValue)
          Sets all samples of one channel to a new value.
 byte getByteSample(int x, int y)
          Returns a single byte sample from the first channel and the specified position.
 byte getByteSample(int channel, int x, int y)
          Returns a single byte sample from the image.
 void getByteSamples(int channelIndex, int x, int y, int w, int h, byte[] dest, int destOffset)
          Copies samples from this image to a byte array.
 void putByteSample(int x, int y, byte newValue)
          Sets one byte sample in the first channel (index 0) to a new value.
 void putByteSample(int channel, int x, int y, byte newValue)
          Sets one byte sample in one channel to a new value.
 void putByteSamples(int channel, int x, int y, int w, int h, byte[] src, int srcOffset)
          Copies a number of samples from the argument array to this image.
 
Methods inherited from interface net.sourceforge.jiu.data.IntegerImage
clear, clear, getMaxSample, getSample, getSample, getSamples, putSample, putSample, putSamples
 
Methods inherited from interface net.sourceforge.jiu.data.PixelImage
createCompatibleImage, createCopy, getAllocatedMemory, getBitsPerPixel, getHeight, getImageType, getNumChannels, getWidth
 

Method Detail

clear

void clear(byte newValue)
Sets all samples of the first channel to the argument byte value. Equal to clear(0, newValue);.

Parameters:
newValue - all samples in the first channel are set to this value
See Also:
clear(int, byte), IntegerImage.clear(int), IntegerImage.clear(int, int)

clear

void clear(int channelIndex,
           byte newValue)
Sets all samples of one channel to a new value.

Parameters:
channelIndex - zero-based index of the channel to be cleared (must be smaller than PixelImage.getNumChannels()
newValue - all samples in the channel will be set to this value

getByteSample

byte getByteSample(int x,
                   int y)
Returns a single byte sample from the first channel and the specified position. A call to this method is the same as getByteSample(0, x, y).

Parameters:
x - horizontal position of the sample to be returned (must be between 0 and PixelImage.getWidth() - 1
y - vertical position of the sample to be returned (must be between 0 and PixelImage.getHeight() - 1
Returns:
the requested byte sample

getByteSample

byte getByteSample(int channel,
                   int x,
                   int y)
Returns a single byte sample from the image. When possible, try copying several samples at a time for higher speed (getByteSamples(int, int, int, int, int, byte[], int)).

Parameters:
channel - the number of the channel of the sample; must be from 0 to PixelImage.getNumChannels() - 1
x - the column of the sample to be returned; must be from 0 to PixelImage.getWidth() - 1
y - the row of the sample; must be from 0 to PixelImage.getHeight() - 1
Returns:
the sample, a single byte value
Throws:
IllegalArgumentException - if the arguments hurt one of the preconditions above
See Also:
getByteSamples(int, int, int, int, int, byte[], int)

getByteSamples

void getByteSamples(int channelIndex,
                    int x,
                    int y,
                    int w,
                    int h,
                    byte[] dest,
                    int destOffset)
Copies samples from this image to a byte array. Copies num samples in row y of channel channel, starting at horizontal offset x. Data will be written to the dest array, starting at offset destOffset. Data will be copied from one row only, so a maximum of getWidth() samples can be copied with a call to this method.

Parameters:
channelIndex - the index of the channel to be copied from; must be from 0 to getNumChannels() - 1
x - the horizontal offset where copying will start; must be from 0 to getWidth() - 1
y - the row from which will be copied; must be from 0 to getHeight() - 1
w - the number of columns to be copied
h - the number of rows to be copied
dest - the array where the data will be copied to; must have a length of at least destOffset + num
destOffset - the offset into dest where this method will start copying data
Throws:
IllegalArgumentException - if the arguments hurt one of the many preconditions above

putByteSample

void putByteSample(int channel,
                   int x,
                   int y,
                   byte newValue)
Sets one byte sample in one channel to a new value.


putByteSample

void putByteSample(int x,
                   int y,
                   byte newValue)
Sets one byte sample in the first channel (index 0) to a new value. Result is equal to putByteSample(0, x, y, newValue);.


putByteSamples

void putByteSamples(int channel,
                    int x,
                    int y,
                    int w,
                    int h,
                    byte[] src,
                    int srcOffset)
Copies a number of samples from the argument array to this image.


JIU 0.14.3

Copyright © 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Marco Schmidt