private void readSIZ(System.IO.BinaryReader ehs)
{
HeaderInfo.SIZ ms = hi.NewSIZ;
hi.sizValue = ms;
// Read the length of SIZ marker segment (Lsiz)
ms.lsiz = ehs.ReadUInt16();
// Read the capability of the codestream (Rsiz)
ms.rsiz = ehs.ReadUInt16();
if (ms.rsiz > 2)
{
throw new System.InvalidOperationException("Codestream capabiities not JPEG 2000 - Part I" + " compliant");
}
// Read image size
ms.xsiz = ehs.ReadInt32();
ms.ysiz = ehs.ReadInt32();
if (ms.xsiz <= 0 || ms.ysiz <= 0)
{
throw new System.IO.IOException("JJ2000 does not support images whose " + "width and/or height not in the " + "range: 1 -- (2^31)-1");
}
// Read image offset
ms.x0siz = ehs.ReadInt32();
ms.y0siz = ehs.ReadInt32();
if (ms.x0siz < 0 || ms.y0siz < 0)
{
throw new System.IO.IOException("JJ2000 does not support images offset " + "not in the range: 0 -- (2^31)-1");
}
// Read size of tile
ms.xtsiz = ehs.ReadInt32();
ms.ytsiz = ehs.ReadInt32();
if (ms.xtsiz <= 0 || ms.ytsiz <= 0)
{
throw new System.IO.IOException("JJ2000 does not support tiles whose " + "width and/or height are not in " + "the range: 1 -- (2^31)-1");
}
// Read upper-left tile offset
ms.xt0siz = ehs.ReadInt32();
ms.yt0siz = ehs.ReadInt32();
if (ms.xt0siz < 0 || ms.yt0siz < 0)
{
throw new System.IO.IOException("JJ2000 does not support tiles whose " + "offset is not in " + "the range: 0 -- (2^31)-1");
}
// Read number of components and initialize related arrays
nComp = ms.csiz = ehs.ReadUInt16();
if (nComp < 1 || nComp > 16384)
{
throw new System.ArgumentException("Number of component out of " + "range 1--16384: " + nComp);
}
ms.ssiz = new int[nComp];
ms.xrsiz = new int[nComp];
ms.yrsiz = new int[nComp];
// Read bit-depth and down-sampling factors of each component
for (int i = 0; i < nComp; i++)
{
ms.ssiz[i] = ehs.ReadByte();
ms.xrsiz[i] = ehs.ReadByte();
ms.yrsiz[i] = ehs.ReadByte();
}
// Check marker length
checkMarkerLength(ehs, "SIZ marker");
// Create needed ModuleSpec
nTiles = ms.NumTiles;
// Finish initialization of decSpec
decSpec = new DecoderSpecs(nTiles, nComp);
}