/// **************************************************************************
///
/// $Id: ImageHeaderBox.java,v 1.1 2002/07/25 14:50:47 grosbois Exp $
///
/// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
/// $Date $
/// ***************************************************************************
///
using System;
using ColorSpaceException = CSJ2K.Color.ColorSpaceException;
using ParameterList = CSJ2K.j2k.util.ParameterList;
using RandomAccessIO = CSJ2K.j2k.io.RandomAccessIO;
using ICCProfile = CSJ2K.Icc.ICCProfile;
namespace CSJ2K.Color.Boxes
{
/// This class models the Image Header box contained in a JP2
/// image. It is a stub class here since for colormapping the
/// knowlege of the existance of the box in the image is sufficient.
///
///
/// 1.0
///
/// Bruce A. Kern
///
public sealed class ImageHeaderBox:JP2Box
{
internal long height;
internal long width;
internal int nc;
internal short bpc;
internal short c;
internal bool unk;
internal bool ipr;
/// Construct an ImageHeaderBox from an input image.
/// RandomAccessIO jp2 image
///
/// offset to the start of the box in the image
///
/// ColorSpaceException
///
public ImageHeaderBox(RandomAccessIO in_Renamed, int boxStart):base(in_Renamed, boxStart)
{
readBox();
}
/// Return a suitable String representation of the class instance.
public override System.String ToString()
{
System.Text.StringBuilder rep = new System.Text.StringBuilder("[ImageHeaderBox ").Append(eol).Append(" ");
rep.Append("height= ").Append(System.Convert.ToString(height)).Append(", ");
rep.Append("width= ").Append(System.Convert.ToString(width)).Append(eol).Append(" ");
rep.Append("nc= ").Append(System.Convert.ToString(nc)).Append(", ");
rep.Append("bpc= ").Append(System.Convert.ToString(bpc)).Append(", ");
rep.Append("c= ").Append(System.Convert.ToString(c)).Append(eol).Append(" ");
rep.Append("image colorspace is ").Append(new System.Text.StringBuilder(unk == true?"known":"unknown").ToString());
rep.Append(", the image ").Append(new System.Text.StringBuilder(ipr == true?"contains ":"does not contain ").ToString()).Append("intellectual property").Append("]");
return rep.ToString();
}
/// Analyze the box content.
internal void readBox()
{
byte[] bfr = new byte[14];
in_Renamed.seek(dataStart);
in_Renamed.readFully(bfr, 0, 14);
height = ICCProfile.getInt(bfr, 0);
width = ICCProfile.getInt(bfr, 4);
nc = ICCProfile.getShort(bfr, 8);
bpc = (short) (bfr[10] & 0x00ff);
c = (short) (bfr[11] & 0x00ff);
unk = bfr[12] == 0?true:false;
ipr = bfr[13] == 1?true:false;
}
/* end class ImageHeaderBox */
static ImageHeaderBox()
{
{
type = 69686472;
}
}
}
}