private int write_pdf_xobject_calcs()
{
int written = writeToFile("[");
float X_W = 0.0f;
float Y_W = 0.0f;
float Z_W = 0.0f;
if ((m_pdf_colorspace & t2p_cs_t.T2P_CS_CALGRAY) != 0)
{
written += writeToFile("/CalGray ");
X_W = m_tiff_whitechromaticities[0];
Y_W = m_tiff_whitechromaticities[1];
Z_W = 1.0F - (X_W + Y_W);
X_W /= Y_W;
Z_W /= Y_W;
Y_W = 1.0F;
}
float X_R = 0.0f;
float Y_R = 0.0f;
float Z_R = 0.0f;
float X_G = 0.0f;
float Y_G = 0.0f;
float Z_G = 0.0f;
float X_B = 0.0f;
float Y_B = 0.0f;
float Z_B = 0.0f;
if ((m_pdf_colorspace & t2p_cs_t.T2P_CS_CALRGB) != 0)
{
written += writeToFile("/CalRGB ");
float x_w = m_tiff_whitechromaticities[0];
float y_w = m_tiff_whitechromaticities[1];
float x_r = m_tiff_primarychromaticities[0];
float y_r = m_tiff_primarychromaticities[1];
float x_g = m_tiff_primarychromaticities[2];
float y_g = m_tiff_primarychromaticities[3];
float x_b = m_tiff_primarychromaticities[4];
float y_b = m_tiff_primarychromaticities[5];
const float R = 1.0f;
const float G = 1.0f;
const float B = 1.0f;
float z_w = y_w * ((x_g - x_b) * y_r - (x_r - x_b) * y_g + (x_r - x_g) * y_b);
Y_R = (y_r / R) * ((x_g - x_b) * y_w - (x_w - x_b) * y_g + (x_w - x_g) * y_b) / z_w;
X_R = Y_R * x_r / y_r;
Z_R = Y_R * (((1 - x_r) / y_r) - 1);
Y_G = ((0.0F - y_g) / G) * ((x_r - x_b) * y_w - (x_w - x_b) * y_r + (x_w - x_r) * y_b) / z_w;
X_G = Y_G * x_g / y_g;
Z_G = Y_G * (((1 - x_g) / y_g) - 1);
Y_B = (y_b / B) * ((x_r - x_g) * y_w - (x_w - x_g) * y_r + (x_w - x_r) * y_g) / z_w;
X_B = Y_B * x_b / y_b;
Z_B = Y_B * (((1 - x_b) / y_b) - 1);
X_W = (X_R * R) + (X_G * G) + (X_B * B);
Y_W = (Y_R * R) + (Y_G * G) + (Y_B * B);
Z_W = (Z_R * R) + (Z_G * G) + (Z_B * B);
X_W /= Y_W;
Z_W /= Y_W;
Y_W = 1.0f;
}
written += writeToFile("<< \n");
string buffer = null;
if ((m_pdf_colorspace & t2p_cs_t.T2P_CS_CALGRAY) != 0)
{
written += writeToFile("/WhitePoint ");
buffer = string.Format(CultureInfo.InvariantCulture, "[{0:F4} {1:F4} {2:F4}] \n", X_W, Y_W, Z_W);
written += writeToFile(buffer);
written += writeToFile("/Gamma 2.2 \n");
}
if ((m_pdf_colorspace & t2p_cs_t.T2P_CS_CALRGB) != 0)
{
written += writeToFile("/WhitePoint ");
buffer = string.Format(CultureInfo.InvariantCulture, "[{0:F4} {1:F4} {2:F4}] \n", X_W, Y_W, Z_W);
written += writeToFile(buffer);
written += writeToFile("/Matrix ");
buffer = string.Format(CultureInfo.InvariantCulture,
"[{0:F4} {1:F4} {2:F4} {3:F4} {4:F4} {5:F4} {6:F4} {7:F4} {8:F4}] \n",
X_R, Y_R, Z_R, X_G, Y_G, Z_G, X_B, Y_B, Z_B);
written += writeToFile(buffer);
written += writeToFile("/Gamma [2.2 2.2 2.2] \n");
}
written += writeToFile(">>] \n");
return written;
}