private void compose_pdf_page()
{
m_pdf_xres = m_tiff_xres;
m_pdf_yres = m_tiff_yres;
if (m_pdf_overrideres)
{
m_pdf_xres = m_pdf_defaultxres;
m_pdf_yres = m_pdf_defaultyres;
}
if (m_pdf_xres == 0.0)
m_pdf_xres = m_pdf_defaultxres;
if (m_pdf_yres == 0.0)
m_pdf_yres = m_pdf_defaultyres;
if ((m_tiff_resunit != ResUnit.CENTIMETER && m_tiff_resunit != ResUnit.INCH) &&
(m_tiff_xres < Tiff2PdfConstants.PS_UNIT_SIZE && m_tiff_yres < Tiff2PdfConstants.PS_UNIT_SIZE))
{
// apply special processing for case when resolution
// unit is unspecified and resolution is "very low" (less then Tiff2PdfConstants.PS_UNIT_SIZE)
m_pdf_imagewidth = ((float)m_tiff_width) / m_pdf_xres;
m_pdf_imagelength = ((float)m_tiff_length) / m_pdf_yres;
}
else
{
m_pdf_imagewidth = ((float)m_tiff_width) * Tiff2PdfConstants.PS_UNIT_SIZE / m_pdf_xres;
m_pdf_imagelength = ((float)m_tiff_length) * Tiff2PdfConstants.PS_UNIT_SIZE / m_pdf_yres;
}
if (m_pdf_overridepagesize)
{
m_pdf_pagewidth = m_pdf_defaultpagewidth;
m_pdf_pagelength = m_pdf_defaultpagelength;
}
else
{
m_pdf_pagewidth = m_pdf_imagewidth;
m_pdf_pagelength = m_pdf_imagelength;
}
m_pdf_mediabox.x1 = 0.0f;
m_pdf_mediabox.y1 = 0.0f;
m_pdf_mediabox.x2 = m_pdf_pagewidth;
m_pdf_mediabox.y2 = m_pdf_pagelength;
m_pdf_imagebox.x1 = 0.0f;
m_pdf_imagebox.y1 = 0.0f;
m_pdf_imagebox.x2 = m_pdf_imagewidth;
m_pdf_imagebox.y2 = m_pdf_imagelength;
if (m_pdf_overridepagesize)
{
m_pdf_imagebox.x1 += (m_pdf_pagewidth - m_pdf_imagewidth) / 2.0F;
m_pdf_imagebox.y1 += (m_pdf_pagelength - m_pdf_imagelength) / 2.0F;
m_pdf_imagebox.x2 += (m_pdf_pagewidth - m_pdf_imagewidth) / 2.0F;
m_pdf_imagebox.y2 += (m_pdf_pagelength - m_pdf_imagelength) / 2.0F;
}
if (m_tiff_orientation > Orientation.BOTLEFT)
{
float f = m_pdf_mediabox.x2;
m_pdf_mediabox.x2 = m_pdf_mediabox.y2;
m_pdf_mediabox.y2 = f;
}
T2P_TILE[] tiles = null;
int istiled = ((m_tiff_pages[m_pdf_page]).page_tilecount == 0) ? 0 : 1;
if (istiled == 0)
{
compose_pdf_page_orient(m_pdf_imagebox, m_tiff_orientation);
return;
}
else
{
int tilewidth = m_tiff_pages[m_pdf_page].tiles_tilewidth;
int tilelength = m_tiff_pages[m_pdf_page].tiles_tilelength;
int tilecountx = (m_tiff_width + tilewidth - 1) / tilewidth;
m_tiff_pages[m_pdf_page].tiles_tilecountx = tilecountx;
int tilecounty = (m_tiff_length + tilelength - 1) / tilelength;
m_tiff_pages[m_pdf_page].tiles_tilecounty = tilecounty;
m_tiff_pages[m_pdf_page].tiles_edgetilewidth = m_tiff_width % tilewidth;
m_tiff_pages[m_pdf_page].tiles_edgetilelength = m_tiff_length % tilelength;
tiles = m_tiff_pages[m_pdf_page].tiles_tiles;
int i = 0;
int i2 = 0;
T2P_BOX boxp = null;
for (i2 = 0; i2 < tilecounty - 1; i2++)
{
for (i = 0; i < tilecountx - 1; i++)
{
boxp = tiles[i2 * tilecountx + i].tile_box;
boxp.x1 = m_pdf_imagebox.x1 + ((float)(m_pdf_imagewidth * i * tilewidth) / (float)m_tiff_width);
boxp.x2 = m_pdf_imagebox.x1 + ((float)(m_pdf_imagewidth * (i + 1) * tilewidth) / (float)m_tiff_width);
boxp.y1 = m_pdf_imagebox.y2 - ((float)(m_pdf_imagelength * (i2 + 1) * tilelength) / (float)m_tiff_length);
boxp.y2 = m_pdf_imagebox.y2 - ((float)(m_pdf_imagelength * i2 * tilelength) / (float)m_tiff_length);
}
boxp = tiles[i2 * tilecountx + i].tile_box;
boxp.x1 = m_pdf_imagebox.x1 + ((float)(m_pdf_imagewidth * i * tilewidth) / (float)m_tiff_width);
boxp.x2 = m_pdf_imagebox.x2;
boxp.y1 = m_pdf_imagebox.y2 - ((float)(m_pdf_imagelength * (i2 + 1) * tilelength) / (float)m_tiff_length);
boxp.y2 = m_pdf_imagebox.y2 - ((float)(m_pdf_imagelength * i2 * tilelength) / (float)m_tiff_length);
}
for (i = 0; i < tilecountx - 1; i++)
{
boxp = tiles[i2 * tilecountx + i].tile_box;
boxp.x1 = m_pdf_imagebox.x1 + ((float)(m_pdf_imagewidth * i * tilewidth) / (float)m_tiff_width);
boxp.x2 = m_pdf_imagebox.x1 + ((float)(m_pdf_imagewidth *(i + 1) * tilewidth) / (float)m_tiff_width);
boxp.y1 = m_pdf_imagebox.y1;
boxp.y2 = m_pdf_imagebox.y2 - ((float)(m_pdf_imagelength * i2 * tilelength) / (float)m_tiff_length);
}
boxp = tiles[i2 * tilecountx + i].tile_box;
boxp.x1 = m_pdf_imagebox.x1 + ((float)(m_pdf_imagewidth * i * tilewidth) / (float)m_tiff_width);
boxp.x2 = m_pdf_imagebox.x2;
boxp.y1 = m_pdf_imagebox.y1;
boxp.y2 = m_pdf_imagebox.y2 - ((float)(m_pdf_imagelength * i2 * tilelength) / (float)m_tiff_length);
}
if (m_tiff_orientation == 0 || m_tiff_orientation == Orientation.TOPLEFT)
{
for (int i = 0; i < m_tiff_pages[m_pdf_page].page_tilecount; i++)
compose_pdf_page_orient(tiles[i].tile_box, 0);
return;
}
for (int i = 0; i < m_tiff_pages[m_pdf_page].page_tilecount; i++)
{
T2P_BOX boxp = tiles[i].tile_box;
boxp.x1 -= m_pdf_imagebox.x1;
boxp.x2 -= m_pdf_imagebox.x1;
boxp.y1 -= m_pdf_imagebox.y1;
boxp.y2 -= m_pdf_imagebox.y1;
if (m_tiff_orientation == Orientation.TOPRIGHT ||
m_tiff_orientation == Orientation.BOTRIGHT)
{
boxp.x1 = m_pdf_imagebox.x2 - m_pdf_imagebox.x1 - boxp.x1;
boxp.x2 = m_pdf_imagebox.x2 - m_pdf_imagebox.x1 - boxp.x2;
}
if (m_tiff_orientation == Orientation.BOTRIGHT ||
m_tiff_orientation == Orientation.BOTLEFT)
{
boxp.y1 = m_pdf_imagebox.y2 - m_pdf_imagebox.y1 - boxp.y1;
boxp.y2 = m_pdf_imagebox.y2 - m_pdf_imagebox.y1 - boxp.y2;
}
if (m_tiff_orientation == Orientation.LEFTBOT ||
m_tiff_orientation == Orientation.LEFTTOP)
{
boxp.y1 = m_pdf_imagebox.y2 - m_pdf_imagebox.y1 - boxp.y1;
boxp.y2 = m_pdf_imagebox.y2 - m_pdf_imagebox.y1 - boxp.y2;
}
if (m_tiff_orientation == Orientation.LEFTTOP ||
m_tiff_orientation == Orientation.RIGHTTOP)
{
boxp.x1 = m_pdf_imagebox.x2 - m_pdf_imagebox.x1 - boxp.x1;
boxp.x2 = m_pdf_imagebox.x2 - m_pdf_imagebox.x1 - boxp.x2;
}
if (m_tiff_orientation > Orientation.BOTLEFT)
{
float f = boxp.x1;
boxp.x1 = boxp.y1;
boxp.y1 = f;
f = boxp.x2;
boxp.x2 = boxp.y2;
boxp.y2 = f;
compose_pdf_page_orient_flip(boxp, m_tiff_orientation);
}
else
{
compose_pdf_page_orient(boxp, m_tiff_orientation);
}
}
}