Package net.sourceforge.jiu.data
Class MemoryPaletted8Image
java.lang.Object
net.sourceforge.jiu.data.MemoryByteChannelImage
net.sourceforge.jiu.data.MemoryPaletted8Image
- All Implemented Interfaces:
ByteChannelImage
,IntegerImage
,Paletted8Image
,PalettedImage
,PalettedIntegerImage
,PixelImage
This class stores a paletted image with one byte per sample in memory.
- Author:
- Marco Schmidt
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMemoryPaletted8Image
(int width, int height) Create an image of byte channels.MemoryPaletted8Image
(int width, int height, Palette palette) -
Method Summary
Modifier and TypeMethodDescriptionstatic void
checkPalette
(Palette palette) createCompatibleImage
(int width, int height) Creates an instance of the same class as this one, with width and height given by the arguments.long
Returns the number of bytes that were dynamically allocated for this image object.If there is a single interface or class that describes the image data type of this class, theClass
object associated with that interface (or class) is returned (ornull
otherwise).int
getMaxSample
(int channel) Returns the maximum value for one of the image's channels.Returns this image's palette.void
setPalette
(Palette palette) Sets this image's palette to a new value.Methods inherited from class net.sourceforge.jiu.data.MemoryByteChannelImage
checkPositionAndNumber, clear, clear, clear, clear, createCopy, getBitsPerPixel, getByteSample, getByteSample, getByteSamples, getHeight, getNumChannels, getSample, getSample, getSamples, getWidth, putByteSample, putByteSample, putByteSamples, putSample, putSample, putSamples
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.sourceforge.jiu.data.ByteChannelImage
clear, clear, getByteSample, getByteSample, getByteSamples, putByteSample, putByteSample, putByteSamples
Methods inherited from interface net.sourceforge.jiu.data.IntegerImage
clear, clear, getSample, getSample, getSamples, putSample, putSample, putSamples
Methods inherited from interface net.sourceforge.jiu.data.PixelImage
createCopy, getBitsPerPixel, getHeight, getNumChannels, getWidth
-
Field Details
-
palette
This image's palette. -
maxSampleValue
private int maxSampleValue
-
-
Constructor Details
-
MemoryPaletted8Image
public MemoryPaletted8Image(int width, int height) Create an image of byte channels. Image data will be completely in memory, so memory requirements arewidth * height * numChannels
bytes. Note that the data will not be initialized, so you should not assume anything about its content.- Parameters:
width
- the horizontal resolution, must be non-zero and positiveheight
- the vertical resolution, must be non-zero and positive- Throws:
IllegalArgumentException
- if any of the parameters are smaller than 1
-
MemoryPaletted8Image
-
-
Method Details
-
checkPalette
-
createCompatibleImage
Description copied from interface:PixelImage
Creates an instance of the same class as this one, with width and height given by the arguments.- Specified by:
createCompatibleImage
in interfacePixelImage
- Specified by:
createCompatibleImage
in classMemoryByteChannelImage
- Parameters:
width
- the horizontal resolution of the new imageheight
- the vertical resolution of the new image- Returns:
- the new image
-
getAllocatedMemory
public long getAllocatedMemory()Description copied from interface:PixelImage
Returns the number of bytes that were dynamically allocated for this image object.- Specified by:
getAllocatedMemory
in interfacePixelImage
- Overrides:
getAllocatedMemory
in classMemoryByteChannelImage
- Returns:
- allocated memory in bytes
-
getImageType
Description copied from interface:PixelImage
If there is a single interface or class that describes the image data type of this class, theClass
object associated with that interface (or class) is returned (ornull
otherwise). ThisClass
object, if available for two image objects, can be used to find out if they are compatible. Example:MemoryGray8Image
returnsnet.sourceforge.jiu.data.Gray8Image.class
.- Specified by:
getImageType
in interfacePixelImage
-
getMaxSample
public int getMaxSample(int channel) Description copied from interface:IntegerImage
Returns the maximum value for one of the image's channels. The minimum value is always0
.- Specified by:
getMaxSample
in interfaceIntegerImage
- Overrides:
getMaxSample
in classMemoryByteChannelImage
- Parameters:
channel
- zero-based index of the channel, from0
toPixelImage.getNumChannels()
- 1
- Returns:
- maximum allowed sample value
-
getPalette
Returns this image's palette.- Specified by:
getPalette
in interfacePalettedImage
- Returns:
- palette object
- See Also:
-
getTypeDescription
-
setPalette
Sets this image's palette to a new value.- Specified by:
setPalette
in interfacePalettedImage
- Parameters:
palette
- the new palette for this image- See Also:
-