
colorspace.boxes.PaletteBox Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jj2000 Show documentation
Show all versions of jj2000 Show documentation
Fork of jpeg2k code from https://code.google.com/p/jj2000/.
This is a dependency for support of compression in Grib2 files in netCDF-java and TDS.
We welcome bug fixes and other contributions to this code.
The newest version!
/*****************************************************************************
*
* $Id: PaletteBox.java,v 1.1 2002/07/25 14:50:47 grosbois Exp $
*
* Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
* $Date $
*****************************************************************************/
package colorspace.boxes;
import colorspace .ColorSpaceException;
import icc .ICCProfile;
import jj2000.j2k.util.ParameterList;
import jj2000.j2k.io.RandomAccessIO;
import java.io.IOException;
/**
* This class models the palette box contained in a JP2
* image.
*
* @version 1.0
* @author Bruce A. Kern
*/
public final class PaletteBox extends JP2Box
{
static { type = 0x70636c72; }
private int nentries;
private int ncolumns;
private short [] bitdepth;
private int [][] entries;
/**
* Construct a PaletteBox from an input image.
* @param in RandomAccessIO jp2 image
* @param boxStart offset to the start of the box in the image
* @exception IOException, ColorSpaceException
*/
public PaletteBox (RandomAccessIO in, int boxStart)
throws IOException, ColorSpaceException {
super (in, boxStart);
readBox(); }
/** Analyze the box content. */
void readBox()
throws IOException, ColorSpaceException {
byte [] bfr = new byte [4];
int i,j,b,m;
int entry;
// Read the number of palette entries and columns per entry.
in.seek((int)dataStart);
in.readFully (bfr,0,3);
nentries = ICCProfile.getShort(bfr,0) & 0x0000ffff;
ncolumns = bfr[2] & 0x0000ffff;
// Read the bitdepths for each column
bitdepth = new short [ncolumns];
bfr = new byte [ncolumns];
in.readFully (bfr,0,ncolumns);
for (i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy