public interface ShortChannelImage extends IntegerImage
IntegerImage
interface that restricts the image to
short
samples.
The minimum sample value for all channels is 0
,
the maximum sample value 65535
(216 - 1).
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 short
values.
Note that shorts in Java are signed, they can take values from -32768
to 32767
.
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 .. 65535 interval.
To manually convert a Java short
value to an int
value
in the range of 0 to 65535, do the following:
short s = ...; // initialize short value int i = s & 0xffff; // i now is a value between 0 and 65535
Modifier and Type | Method and Description |
---|---|
void |
clear(int channelIndex,
short newValue)
Sets all samples of one channel to a new value.
|
void |
clear(short newValue)
Sets all samples of the first channel to the argument short value.
|
short |
getShortSample(int x,
int y)
Returns a single short sample from the first channel and the specified position.
|
short |
getShortSample(int channel,
int x,
int y)
Returns a single short sample from the image.
|
void |
getShortSamples(int channelIndex,
int x,
int y,
int w,
int h,
short[] dest,
int destOffset)
Copies samples from this image to a short array.
|
void |
putShortSample(int channel,
int x,
int y,
short newValue)
Sets one short sample in one channel to a new value.
|
void |
putShortSample(int x,
int y,
short newValue)
Sets one short sample in the first channel (index
0 ) to a new value. |
void |
putShortSamples(int channel,
int x,
int y,
int w,
int h,
short[] src,
int srcOffset)
Copies a number of samples from the argument array to this image.
|
clear, clear, getMaxSample, getSample, getSample, getSamples, putSample, putSample, putSamples
createCompatibleImage, createCopy, getAllocatedMemory, getBitsPerPixel, getHeight, getImageType, getNumChannels, getWidth
void clear(short newValue)
clear(0, newValue);
.newValue
- all samples in the first channel are set to this valueclear(int, short)
,
IntegerImage.clear(int)
,
IntegerImage.clear(int, int)
void clear(int channelIndex, short newValue)
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 valueshort getShortSample(int x, int y)
getShortSample(0, x, y)
.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
short getShortSample(int channel, int x, int y)
getShortSamples(int, int, int, int, int, short[], int)
).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
java.lang.IllegalArgumentException
- if the arguments hurt one of the preconditions abovegetShortSamples(int, int, int, int, int, short[], int)
void getShortSamples(int channelIndex, int x, int y, int w, int h, short[] dest, int destOffset)
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.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
- number of columns to be copiedh
- number of rows to be copieddest
- 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 datajava.lang.IllegalArgumentException
- if the arguments hurt one of the many
preconditions abovevoid putShortSample(int channel, int x, int y, short newValue)
void putShortSample(int x, int y, short newValue)
0
) to a new value.
Result is equal to putShortSample(0, x, y, newValue);
.void putShortSamples(int channel, int x, int y, int w, int h, short[] src, int srcOffset)