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]; fz_eval_function(ctx, sep->tint, color, cs->n, alt, sep->base->n); sep->base->to_rgb(ctx, sep->base, alt, rgb); }
static void pdf_sample_composite_shade_function(fz_context *ctx, fz_shade *shade, fz_function *func, float t0, float t1) { int i; float t; for (i = 0; i < 256; i++) { t = t0 + (i / 255.0f) * (t1 - t0); fz_eval_function(ctx, func, &t, 1, shade->function[i], shade->colorspace->n); shade->function[i][shade->colorspace->n] = 1; } }
static void pdf_sample_component_shade_function(fz_context *ctx, fz_shade *shade, int funcs, fz_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++) fz_eval_function(ctx, func[k], &t, 1, &shade->function[i][k], 1); shade->function[i][k] = 1; } }
static void pdf_load_function_based_shading(fz_context *ctx, pdf_document *doc, fz_shade *shade, pdf_obj *dict, fz_function *func) { pdf_obj *obj; float x0, y0, x1, y1; float fv[2]; fz_matrix matrix; int xx, yy; float *p; x0 = y0 = 0; x1 = y1 = 1; obj = pdf_dict_gets(ctx, dict, "Domain"); if (obj) { x0 = pdf_to_real(ctx, pdf_array_get(ctx, obj, 0)); x1 = pdf_to_real(ctx, pdf_array_get(ctx, obj, 1)); y0 = pdf_to_real(ctx, pdf_array_get(ctx, obj, 2)); y1 = pdf_to_real(ctx, pdf_array_get(ctx, obj, 3)); } obj = pdf_dict_gets(ctx, dict, "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)*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; fz_eval_function(ctx, func, fv, 2, p, shade->colorspace->n); p += shade->colorspace->n; } } }