Package net.sourceforge.jiu.color.io
Class PaletteSerialization
- java.lang.Object
-
- net.sourceforge.jiu.color.io.PaletteSerialization
-
- All Implemented Interfaces:
RGBIndex
public class PaletteSerialization extends Object implements RGBIndex
This class loads and saves palettes. Loading is done using theImageLoaderclass - an image is loaded which is supposed to have no more than 256 pixels, the palette entries. When saving, thePNMCodecis used to store palettes as .ppm files.- Since:
- 0.5.0
- Author:
- Marco Schmidt
-
-
Field Summary
-
Fields inherited from interface net.sourceforge.jiu.data.RGBIndex
INDEX_BLUE, INDEX_GREEN, INDEX_RED
-
-
Constructor Summary
Constructors Modifier Constructor Description privatePaletteSerialization()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static PaletteconvertImageToPalette(RGB24Image image)Create a palette from the pixels of the argument image.static RGB24ImageconvertPaletteToImage(Palette palette)Creates an RGB24Image from the palette entries, each entry becomes a pixel in an image of width 1 and height palette.getNumEntries().static Paletteload(File paletteFile)Loads a palette from the argument file.static voidsave(Palette palette, File paletteFile)Saves the palette to the given file as a PPM image file.
-
-
-
Method Detail
-
convertImageToPalette
public static Palette convertImageToPalette(RGB24Image image)
Create a palette from the pixels of the argument image.
-
convertPaletteToImage
public static RGB24Image convertPaletteToImage(Palette palette)
Creates an RGB24Image from the palette entries, each entry becomes a pixel in an image of width 1 and height palette.getNumEntries().
-
load
public static Palette load(File paletteFile)
Loads a palette from the argument file. UsesImageLoaderto load an image from the argument file, then callsconvertImageToPalette(net.sourceforge.jiu.data.RGB24Image)and returns the palette created that way.
-
save
public static void save(Palette palette, File paletteFile) throws IOException
Saves the palette to the given file as a PPM image file. UsesPNMCodec.- Throws:
IOException
-
-