public Tiler(BlkImgDataSrc src, int ax, int ay, int px, int py, int nw, int nh)
: base(src)
{
// Initialize
this.src = src;
this.x0siz = ax;
this.y0siz = ay;
this.xt0siz = px;
this.yt0siz = py;
this.xtsiz = nw;
this.ytsiz = nh;
// Verify that input is not tiled
if (src.getNumTiles() != 1)
{
throw new System.ArgumentException("Source is tiled");
}
// Verify that source is not "canvased"
if (src.ImgULX != 0 || src.ImgULY != 0)
{
throw new System.ArgumentException("Source is \"canvased\"");
}
// Verify that arguments satisfy trivial requirements
if (x0siz < 0 || y0siz < 0 || xt0siz < 0 || yt0siz < 0 || xtsiz < 0 || ytsiz < 0 || xt0siz > x0siz
|| yt0siz > y0siz)
{
throw new System.ArgumentException("Invalid image origin, " + "tiling origin or nominal " + "tile size");
}
// If no tiling has been specified, creates a unique tile with maximum
// dimension.
if (xtsiz == 0) xtsiz = x0siz + src.ImgWidth - xt0siz;
if (ytsiz == 0) ytsiz = y0siz + src.ImgHeight - yt0siz;
// Automatically adjusts xt0siz,yt0siz so that tile (0,0) always
// overlaps with the image.
if (x0siz - xt0siz >= xtsiz)
{
xt0siz += ((x0siz - xt0siz) / xtsiz) * xtsiz;
}
if (y0siz - yt0siz >= ytsiz)
{
yt0siz += ((y0siz - yt0siz) / ytsiz) * ytsiz;
}
if (x0siz - xt0siz >= xtsiz || y0siz - yt0siz >= ytsiz)
{
FacilityManager.getMsgLogger()
.printmsg(
CSJ2K.j2k.util.MsgLogger_Fields.INFO,
"Automatically adjusted tiling " + "origin to equivalent one (" + xt0siz + "," + yt0siz
+ ") so that " + "first tile overlaps the image");
}
// Calculate the number of tiles
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
ntX = (int)System.Math.Ceiling((x0siz + src.ImgWidth) / (double)xtsiz);
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
ntY = (int)System.Math.Ceiling((y0siz + src.ImgHeight) / (double)ytsiz);
}