Пример #1
0
void pdf_convcolor(fz_colorspace *ss, float *sv, fz_colorspace *ds, float *dv)
{

	if (ss == pdf_devicegray)
	{
		if (ds == pdf_devicergb)
		{
			dv[0] = sv[0];
			dv[1] = sv[0];
			dv[2] = sv[0];
		}
		else if (ds == pdf_devicecmyk)
		{
			dv[0] = 0;
			dv[1] = 0;
			dv[2] = 0;
			dv[3] = sv[0];
		}
		else
			fz_stdconvcolor(ss, sv, ds, dv);
	}

	else if (ss == pdf_devicergb)
	{
		if (ds == pdf_devicegray)
		{
			dv[0] = sv[0] * 0.3 + sv[1] * 0.59 + sv[2] * 0.11;
		}
		else if (ds == pdf_devicecmyk)
		{
			float c = 1.0 - sv[1];
			float m = 1.0 - sv[2];
			float y = 1.0 - sv[3];
			float k = MIN(c, MIN(m, y));
			dv[0] = c - k;
			dv[1] = m - k;
			dv[2] = y - k;
			dv[3] = k;
		}
		else
			fz_stdconvcolor(ss, sv, ds, dv);
	}

	else if (ss == pdf_devicecmyk)
	{
		if (ds == pdf_devicegray)
		{
			float c = sv[1] * 0.3;
			float m = sv[2] * 0.59;
			float y = sv[2] * 0.11;
			dv[0] = 1.0 - MIN(c + m + y + sv[3], 1.0);
		}
		else if (ds == pdf_devicergb)
		{
			cmykToRGBMatrixMultiplication(sv, dv); /* cf. http://code.google.com/p/sumatrapdf/issues/detail?id=756 */
		}
		else
			fz_stdconvcolor(ss, sv, ds, dv);
	}

	else
		fz_stdconvcolor(ss, sv, ds, dv);
}
Пример #2
0
void pdf_convcolor(fz_colorspace *ss, float *sv, fz_colorspace *ds, float *dv)
{

	if (ss == pdf_devicegray)
	{
		if (ds == pdf_devicergb)
		{
			dv[0] = sv[0];
			dv[1] = sv[0];
			dv[2] = sv[0];
		}
		else if (ds == pdf_devicecmyk)
		{
			dv[0] = 0;
			dv[1] = 0;
			dv[2] = 0;
			dv[3] = sv[0];
		}
		else
			fz_stdconvcolor(ss, sv, ds, dv);
	}

	else if (ss == pdf_devicergb)
	{
		if (ds == pdf_devicegray)
		{
			dv[0] = sv[0] * 0.3 + sv[1] * 0.59 + sv[2] * 0.11;
		}
		else if (ds == pdf_devicecmyk)
		{
			float c = 1.0 - sv[1];
			float m = 1.0 - sv[2];
			float y = 1.0 - sv[3];
			float k = MIN(c, MIN(m, y));
			dv[0] = c - k;
			dv[1] = m - k;
			dv[2] = y - k;
			dv[3] = k;
		}
		else
			fz_stdconvcolor(ss, sv, ds, dv);
	}

	else if (ss == pdf_devicecmyk)
	{
		if (ds == pdf_devicegray)
		{
			float c = sv[1] * 0.3;
			float m = sv[2] * 0.59;
			float y = sv[2] * 0.11;
			dv[0] = 1.0 - MIN(c + m + y + sv[3], 1.0);
		}
		else if (ds == pdf_devicergb)
		{
			dv[0] = 1.0 - MIN(sv[0] + sv[3], 1.0);
			dv[1] = 1.0 - MIN(sv[1] + sv[3], 1.0);
			dv[2] = 1.0 - MIN(sv[2] + sv[3], 1.0);
		}
		else
			fz_stdconvcolor(ss, sv, ds, dv);
	}

	else
		fz_stdconvcolor(ss, sv, ds, dv);
}
Пример #3
0
void
fz_convertcolor(fz_colorspace *ss, float *sv, fz_colorspace *ds, float *dv)
{
	if (ss == fz_devicegray)
	{
		if ((ds == fz_devicergb) || (ds == fz_devicebgr))
		{
			dv[0] = sv[0];
			dv[1] = sv[0];
			dv[2] = sv[0];
		}
		else if (ds == fz_devicecmyk)
		{
			dv[0] = 0;
			dv[1] = 0;
			dv[2] = 0;
			dv[3] = sv[0];
		}
		else
			fz_stdconvcolor(ss, sv, ds, dv);
	}

	else if (ss == fz_devicergb)
	{
		if (ds == fz_devicegray)
		{
			dv[0] = sv[0] * 0.3f + sv[1] * 0.59f + sv[2] * 0.11f;
		}
		else if (ds == fz_devicebgr)
		{
			dv[0] = sv[2];
			dv[1] = sv[1];
			dv[2] = sv[0];
		}
		else if (ds == fz_devicecmyk)
		{
			float c = 1 - sv[0];
			float m = 1 - sv[1];
			float y = 1 - sv[2];
			float k = MIN(c, MIN(m, y));
			dv[0] = c - k;
			dv[1] = m - k;
			dv[2] = y - k;
			dv[3] = k;
		}
		else
			fz_stdconvcolor(ss, sv, ds, dv);
	}

	else if (ss == fz_devicebgr)
	{
		if (ds == fz_devicegray)
		{
			dv[0] = sv[0] * 0.11f + sv[1] * 0.59f + sv[2] * 0.3f;
		}
		else if (ds == fz_devicebgr)
		{
			dv[0] = sv[2];
			dv[1] = sv[1];
			dv[2] = sv[0];
		}
		else if (ds == fz_devicecmyk)
		{
			float c = 1 - sv[2];
			float m = 1 - sv[1];
			float y = 1 - sv[0];
			float k = MIN(c, MIN(m, y));
			dv[0] = c - k;
			dv[1] = m - k;
			dv[2] = y - k;
			dv[3] = k;
		}
		else
			fz_stdconvcolor(ss, sv, ds, dv);
	}

	else if (ss == fz_devicecmyk)
	{
		if (ds == fz_devicegray)
		{
			float c = sv[0] * 0.3f;
			float m = sv[1] * 0.59f;
			float y = sv[2] * 0.11f;
			dv[0] = 1 - MIN(c + m + y + sv[3], 1);
		}
		else if (ds == fz_devicergb)
		{
#ifdef SLOWCMYK
			cmyktoxyz(nil, sv, dv);
#else
			dv[0] = 1 - MIN(sv[0] + sv[3], 1);
			dv[1] = 1 - MIN(sv[1] + sv[3], 1);
			dv[2] = 1 - MIN(sv[2] + sv[3], 1);
#endif
		}
		else if (ds == fz_devicebgr)
		{
#ifdef SLOWCMYK
			float rgb[3];
			cmyktoxyz(nil, sv, rgb);
			dv[0] = rgb[2];
			dv[1] = rgb[1];
			dv[2] = rgb[0];
#else
			dv[0] = 1 - MIN(sv[2] + sv[3], 1);
			dv[1] = 1 - MIN(sv[1] + sv[3], 1);
			dv[2] = 1 - MIN(sv[0] + sv[3], 1);
#endif
		}
		else
			fz_stdconvcolor(ss, sv, ds, dv);
	}

	else
		fz_stdconvcolor(ss, sv, ds, dv);
}