fz_error *
pdf_loadshadefunction(fz_shade *shade, pdf_xref *xref, fz_obj *shading, float t0, float t1)
{
	fz_error *error;
	float t;
	fz_obj *obj;
	pdf_function *func;
	int i;

	obj = fz_dictgets(shading, "Function");
	if (obj)
	{
		shade->usefunction = 1;

		error = pdf_loadfunction(&func, xref, obj);
		if (error)
			return error;

		for (i = 0; i < 256; ++i)
		{
			t = t0 + (i / 256.0) * (t1 - t0);
			error = pdf_evalfunction(func, &t, 1, shade->function[i], shade->cs->n);
			if (error)
			{
				pdf_dropfunction(func);
				return error;
			}
		}

		pdf_dropfunction(func);
	}

	return nil;
}
Example #2
0
static void separationtoxyz(fz_colorspace *fzcs, float *sep, float *xyz)
{
	struct separation *cs = (struct separation *)fzcs;
	fz_error error;
	float alt[FZ_MAXCOLORS];

	error = pdf_evalfunction(cs->tint, sep, fzcs->n, alt, cs->base->n);
	if (error)
	{
		fz_catch(error, "cannot evaluate separation function");
		xyz[0] = 0;
		xyz[1] = 0;
		xyz[2] = 0;
		return;
	}

	cs->base->toxyz(cs->base, alt, xyz);
}
static void separationtoxyz(fz_colorspace *fzcs, float *sep, float *xyz)
{
	struct separation *cs = (struct separation *)fzcs;
	fz_error *error;
	float alt[FZ_MAXCOLORS];

	error = pdf_evalfunction(cs->tint, sep, fzcs->n, alt, cs->base->n);
	if (error)
	{
		fz_warn("separation: %s", error->msg);
		fz_droperror(error);
		xyz[0] = 0;
		xyz[1] = 0;
		xyz[2] = 0;
		return;
	}

	cs->base->toxyz(cs->base, alt, xyz);
}