示例#1
0
static void
separation_to_rgb(fz_context *ctx, fz_colorspace *cs, float *color, float *rgb)
{
	struct separation *sep = cs->data;
	float alt[FZ_MAX_COLORS];
	pdf_eval_function(ctx, sep->tint, color, cs->n, alt, sep->base->n);
	sep->base->to_rgb(ctx, sep->base, alt, rgb);
}
示例#2
0
static void
pdf_sample_composite_shade_function(fz_context *ctx, fz_shade *shade, pdf_function *func, float t0, float t1)
{
    int i;
    float t;

    for (i = 0; i < 256; i++)
    {
        t = t0 + (i / 255.0f) * (t1 - t0);
        pdf_eval_function(ctx, func, &t, 1, shade->function[i], shade->colorspace->n);
        shade->function[i][shade->colorspace->n] = 1;
    }
}
示例#3
0
static void
pdf_sample_component_shade_function(fz_context *ctx, fz_shade *shade, int funcs, pdf_function **func, float t0, float t1)
{
    int i, k;
    float t;

    for (i = 0; i < 256; i++)
    {
        t = t0 + (i / 255.0f) * (t1 - t0);
        for (k = 0; k < funcs; k++)
            pdf_eval_function(ctx, func[k], &t, 1, &shade->function[i][k], 1);
        shade->function[i][k] = 1;
    }
}
示例#4
0
static void
pdf_load_function_based_shading(fz_context *ctx, pdf_document *doc, fz_shade *shade, pdf_obj *dict, pdf_function *func)
{
	pdf_obj *obj;
	float x0, y0, x1, y1;
	float fv[2];
	fz_matrix matrix;
	int xx, yy;
	float *p;
	int n = fz_colorspace_n(ctx, shade->colorspace);

	x0 = y0 = 0;
	x1 = y1 = 1;
	obj = pdf_dict_get(ctx, dict, PDF_NAME(Domain));
	if (obj)
	{
		x0 = pdf_array_get_real(ctx, obj, 0);
		x1 = pdf_array_get_real(ctx, obj, 1);
		y0 = pdf_array_get_real(ctx, obj, 2);
		y1 = pdf_array_get_real(ctx, obj, 3);
	}

	obj = pdf_dict_get(ctx, dict, PDF_NAME(Matrix));
	if (obj)
		pdf_to_matrix(ctx, obj, &matrix);
	else
		matrix = fz_identity;
	shade->u.f.matrix = matrix;
	shade->u.f.xdivs = FUNSEGS;
	shade->u.f.ydivs = FUNSEGS;
	shade->u.f.fn_vals = fz_malloc(ctx, (FUNSEGS+1)*(FUNSEGS+1)*n*sizeof(float));
	shade->u.f.domain[0][0] = x0;
	shade->u.f.domain[0][1] = y0;
	shade->u.f.domain[1][0] = x1;
	shade->u.f.domain[1][1] = y1;

	p = shade->u.f.fn_vals;
	for (yy = 0; yy <= FUNSEGS; yy++)
	{
		fv[1] = y0 + (y1 - y0) * yy / FUNSEGS;

		for (xx = 0; xx <= FUNSEGS; xx++)
		{
			fv[0] = x0 + (x1 - x0) * xx / FUNSEGS;

			pdf_eval_function(ctx, func, fv, 2, p, n);
			p += n;
		}
	}
}
示例#5
0
static void
pdf_load_function_based_shading(fz_shade *shade, pdf_document *xref, pdf_obj *dict, pdf_function *func)
{
    pdf_obj *obj;
    float x0, y0, x1, y1;
    float fv[2];
    fz_matrix matrix;
    int xx, yy;
    fz_context *ctx = xref->ctx;
    float *p;

    x0 = y0 = 0;
    x1 = y1 = 1;
    obj = pdf_dict_gets(dict, "Domain");
    if (obj)
    {
        x0 = pdf_to_real(pdf_array_get(obj, 0));
        x1 = pdf_to_real(pdf_array_get(obj, 1));
        y0 = pdf_to_real(pdf_array_get(obj, 2));
        y1 = pdf_to_real(pdf_array_get(obj, 3));
    }

    matrix = fz_identity;
    obj = pdf_dict_gets(dict, "Matrix");
    if (obj)
        matrix = pdf_to_matrix(ctx, obj);
    shade->u.f.matrix = matrix;
    shade->u.f.xdivs = FUNSEGS;
    shade->u.f.ydivs = FUNSEGS;
    shade->u.f.fn_vals = fz_malloc(ctx, (FUNSEGS+1)*(FUNSEGS+1)*shade->colorspace->n*sizeof(float));
    shade->u.f.domain[0][0] = x0;
    shade->u.f.domain[0][1] = y0;
    shade->u.f.domain[1][0] = x1;
    shade->u.f.domain[1][1] = y1;

    p = shade->u.f.fn_vals;
    for (yy = 0; yy <= FUNSEGS; yy++)
    {
        fv[1] = y0 + (y1 - y0) * yy / FUNSEGS;

        for (xx = 0; xx <= FUNSEGS; xx++)
        {
            fv[0] = x0 + (x1 - x0) * xx / FUNSEGS;

            pdf_eval_function(ctx, func, fv, 2, p, shade->colorspace->n);
            p += shade->colorspace->n;
        }
    }
}
示例#6
0
文件: pdf_shade.c 项目: UIKit0/mupdf
static void
pdf_load_function_based_shading(fz_shade *shade, pdf_document *xref, pdf_obj *dict, pdf_function *func)
{
	pdf_obj *obj;
	float x0, y0, x1, y1;
	fz_matrix matrix;
	struct vertex v[4];
	int xx, yy;
	float x, y;
	float xn, yn;
	int i;
	fz_context *ctx = xref->ctx;

	x0 = y0 = 0;
	x1 = y1 = 1;
	obj = pdf_dict_gets(dict, "Domain");
	if (pdf_array_len(obj) == 4)
	{
		x0 = pdf_to_real(pdf_array_get(obj, 0));
		x1 = pdf_to_real(pdf_array_get(obj, 1));
		y0 = pdf_to_real(pdf_array_get(obj, 2));
		y1 = pdf_to_real(pdf_array_get(obj, 3));
	}

	matrix = fz_identity;
	obj = pdf_dict_gets(dict, "Matrix");
	if (pdf_array_len(obj) == 6)
		matrix = pdf_to_matrix(ctx, obj);

	for (yy = 0; yy < FUNSEGS; yy++)
	{
		y = y0 + (y1 - y0) * yy / FUNSEGS;
		yn = y0 + (y1 - y0) * (yy + 1) / FUNSEGS;

		for (xx = 0; xx < FUNSEGS; xx++)
		{
			x = x0 + (x1 - x0) * xx / FUNSEGS;
			xn = x0 + (x1 - x0) * (xx + 1) / FUNSEGS;

			v[0].x = x; v[0].y = y;
			v[1].x = xn; v[1].y = y;
			v[2].x = xn; v[2].y = yn;
			v[3].x = x; v[3].y = yn;

			for (i = 0; i < 4; i++)
			{
				fz_point pt;
				float fv[2];

				fv[0] = v[i].x;
				fv[1] = v[i].y;
				pdf_eval_function(ctx, func, fv, 2, v[i].c, shade->colorspace->n);

				pt.x = v[i].x;
				pt.y = v[i].y;
				pt = fz_transform_point(matrix, pt);
				v[i].x = pt.x;
				v[i].y = pt.y;
			}

			pdf_add_quad(ctx, shade, &v[0], &v[1], &v[2], &v[3]);
		}
	}
}