private void writeSIZ()
{
int tmp;
// SIZ marker
hbuf.Write((System.Int16) CSJ2K.j2k.codestream.Markers.SIZ);
// Lsiz (Marker length) corresponding to
// Lsiz(2 bytes)+Rsiz(2)+Xsiz(4)+Ysiz(4)+XOsiz(4)+YOsiz(4)+
// XTsiz(4)+YTsiz(4)+XTOsiz(4)+YTOsiz(4)+Csiz(2)+
// (Ssiz(1)+XRsiz(1)+YRsiz(1))*nComp
// markSegLen = 38 + 3*nComp;
int markSegLen = 38 + 3 * nComp;
hbuf.Write((System.Int16) markSegLen);
// Rsiz (codestream capabilities)
hbuf.Write((System.Int16) 0); // JPEG 2000 - Part I
// Xsiz (original image width)
hbuf.Write(tiler.ImgWidth + tiler.ImgULX);
// Ysiz (original image height)
hbuf.Write(tiler.ImgHeight + tiler.ImgULY);
// XOsiz (horizontal offset from the origin of the reference
// grid to the left side of the image area)
hbuf.Write(tiler.ImgULX);
// YOsiz (vertical offset from the origin of the reference
// grid to the top side of the image area)
hbuf.Write(tiler.ImgULY);
// XTsiz (nominal tile width)
hbuf.Write(tiler.NomTileWidth);
// YTsiz (nominal tile height)
hbuf.Write(tiler.NomTileHeight);
Coord torig = tiler.getTilingOrigin(null);
// XTOsiz (Horizontal offset from the origin of the reference
// grid to the left side of the first tile)
hbuf.Write(torig.x);
// YTOsiz (Vertical offset from the origin of the reference
// grid to the top side of the first tile)
hbuf.Write(torig.y);
// Csiz (number of components)
hbuf.Write((System.Int16) nComp);
// Bit-depth and downsampling factors.
for (int c = 0; c < nComp; c++)
{
// Loop on each component
// Ssiz bit-depth before mixing
tmp = origSrc.getNomRangeBits(c) - 1;
tmp |= ((isOrigSig[c]?1:0) << CSJ2K.j2k.codestream.Markers.SSIZ_DEPTH_BITS);
hbuf.Write((System.Byte) tmp);
// XRsiz (component sub-sampling value x-wise)
hbuf.Write((System.Byte) tiler.getCompSubsX(c));
// YRsiz (component sub-sampling value y-wise)
hbuf.Write((System.Byte) tiler.getCompSubsY(c));
} // End loop on each component
}