All Downloads are FREE. Search and download functionalities are using the official Maven repository.

colorspace.boxes.ChannelDefinitionBox Maven / Gradle / Ivy

Go to download

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: ChannelDefinitionBox.java,v 1.1 2002/07/25 14:50:46 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;
import java.util.Hashtable;
import java.util.Enumeration;

/**
 * This class maps the components in the codestream
 * to channels in the image.  It models the Component
 * Mapping box in the JP2 header.
 * 
 * @version	1.0
 * @author	Bruce A. Kern
 */
public final class ChannelDefinitionBox extends JP2Box
{
    static { type = 0x63646566; }

    private int ndefs;
    private Hashtable definitions = new Hashtable();

    /**
     * Construct a ChannelDefinitionBox 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 ChannelDefinitionBox (RandomAccessIO in, int boxStart) 
        throws IOException, ColorSpaceException {
        super (in, boxStart);
        readBox(); }
    
    /** Analyze the box content. */
    private void readBox() throws IOException {
        
        byte [] bfr = new byte [8];

        in.seek(dataStart);
        in.readFully (bfr,0,2);
        ndefs = ICCProfile.getShort(bfr,0) & 0x0000ffff;

        int offset = dataStart+2;
        in.seek (offset);
        for (int i=0; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy