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
public class MemoryPaletted8Image extends MemoryByteChannelImage implements Paletted8Image
This class stores a paletted image with one byte per sample in memory.- Author:
- Marco Schmidt
- See Also:
ByteChannelImage,IntegerImage,Palette
-
-
Field Summary
Fields Modifier and Type Field Description private intmaxSampleValueprivate PalettepaletteThis image's palette.
-
Constructor Summary
Constructors Constructor Description MemoryPaletted8Image(int width, int height)Create an image of byte channels.MemoryPaletted8Image(int width, int height, Palette palette)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidcheckPalette(Palette palette)PixelImagecreateCompatibleImage(int width, int height)Creates an instance of the same class as this one, with width and height given by the arguments.longgetAllocatedMemory()Returns the number of bytes that were dynamically allocated for this image object.ClassgetImageType()If there is a single interface or class that describes the image data type of this class, theClassobject associated with that interface (or class) is returned (ornullotherwise).intgetMaxSample(int channel)Returns the maximum value for one of the image's channels.PalettegetPalette()Returns this image's palette.StringgetTypeDescription()voidsetPalette(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 Detail
-
palette
private Palette palette
This image's palette.
-
maxSampleValue
private int maxSampleValue
-
-
Constructor Detail
-
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 * numChannelsbytes. 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
public MemoryPaletted8Image(int width, int height, Palette palette)
-
-
Method Detail
-
checkPalette
public static void checkPalette(Palette palette)
-
createCompatibleImage
public PixelImage createCompatibleImage(int width, int height)
Description copied from interface:PixelImageCreates an instance of the same class as this one, with width and height given by the arguments.- Specified by:
createCompatibleImagein interfacePixelImage- Specified by:
createCompatibleImagein 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:PixelImageReturns the number of bytes that were dynamically allocated for this image object.- Specified by:
getAllocatedMemoryin interfacePixelImage- Overrides:
getAllocatedMemoryin classMemoryByteChannelImage- Returns:
- allocated memory in bytes
-
getImageType
public Class getImageType()
Description copied from interface:PixelImageIf there is a single interface or class that describes the image data type of this class, theClassobject associated with that interface (or class) is returned (ornullotherwise). ThisClassobject, if available for two image objects, can be used to find out if they are compatible. Example:MemoryGray8Imagereturnsnet.sourceforge.jiu.data.Gray8Image.class.- Specified by:
getImageTypein interfacePixelImage
-
getMaxSample
public int getMaxSample(int channel)
Description copied from interface:IntegerImageReturns the maximum value for one of the image's channels. The minimum value is always0.- Specified by:
getMaxSamplein interfaceIntegerImage- Overrides:
getMaxSamplein classMemoryByteChannelImage- Parameters:
channel- zero-based index of the channel, from0toPixelImage.getNumChannels()- 1- Returns:
- maximum allowed sample value
-
getPalette
public Palette getPalette()
Returns this image's palette.- Specified by:
getPalettein interfacePalettedImage- Returns:
- palette object
- See Also:
setPalette(net.sourceforge.jiu.data.Palette)
-
getTypeDescription
public String getTypeDescription()
-
setPalette
public void setPalette(Palette palette)
Sets this image's palette to a new value.- Specified by:
setPalettein interfacePalettedImage- Parameters:
palette- the new palette for this image- See Also:
getPalette()
-
-