fz_shade * pdf_load_shading(pdf_document *xref, pdf_obj *dict) { fz_matrix mat; pdf_obj *obj; fz_context *ctx = xref->ctx; fz_shade *shade; if ((shade = pdf_find_item(ctx, fz_free_shade_imp, dict))) { return shade; } /* Type 2 pattern dictionary */ if (pdf_dict_gets(dict, "PatternType")) { obj = pdf_dict_gets(dict, "Matrix"); if (obj) mat = pdf_to_matrix(ctx, obj); else mat = fz_identity; obj = pdf_dict_gets(dict, "ExtGState"); if (obj) { if (pdf_dict_gets(obj, "CA") || pdf_dict_gets(obj, "ca")) { fz_warn(ctx, "shading with alpha not supported"); } } obj = pdf_dict_gets(dict, "Shading"); if (!obj) fz_throw(ctx, "syntaxerror: missing shading dictionary"); shade = pdf_load_shading_dict(xref, obj, mat); /* RJW: "cannot load shading dictionary (%d %d R)", pdf_to_num(obj), pdf_to_gen(obj) */ } /* Naked shading dictionary */ else { shade = pdf_load_shading_dict(xref, dict, fz_identity); /* RJW: "cannot load shading dictionary (%d %d R)", pdf_to_num(dict), pdf_to_gen(dict) */ } pdf_store_item(ctx, dict, shade, fz_shade_size(shade)); return shade; }
fz_shade * pdf_load_shading(fz_context *ctx, pdf_document *doc, pdf_obj *dict) { fz_matrix mat; pdf_obj *obj; fz_shade *shade; if ((shade = pdf_find_item(ctx, fz_drop_shade_imp, dict)) != NULL) { return shade; } /* Type 2 pattern dictionary */ if (pdf_dict_gets(ctx, dict, "PatternType")) { obj = pdf_dict_gets(ctx, dict, "Matrix"); if (obj) pdf_to_matrix(ctx, obj, &mat); else mat = fz_identity; obj = pdf_dict_gets(ctx, dict, "ExtGState"); if (obj) { if (pdf_dict_gets(ctx, obj, "CA") || pdf_dict_gets(ctx, obj, "ca")) { fz_warn(ctx, "shading with alpha not supported"); } } obj = pdf_dict_gets(ctx, dict, "Shading"); if (!obj) fz_throw(ctx, FZ_ERROR_GENERIC, "syntaxerror: missing shading dictionary"); shade = pdf_load_shading_dict(ctx, doc, obj, &mat); } /* Naked shading dictionary */ else { shade = pdf_load_shading_dict(ctx, doc, dict, &fz_identity); } pdf_store_item(ctx, dict, shade, fz_shade_size(shade)); return shade; }
fz_shade * pdf_load_shading(fz_context *ctx, pdf_document *doc, pdf_obj *dict) { fz_matrix mat; pdf_obj *obj; fz_shade *shade; if ((shade = pdf_find_item(ctx, fz_drop_shade_imp, dict)) != NULL) { return shade; } /* Type 2 pattern dictionary */ if (pdf_dict_get(ctx, dict, PDF_NAME(PatternType))) { obj = pdf_dict_get(ctx, dict, PDF_NAME(Matrix)); if (obj) pdf_to_matrix(ctx, obj, &mat); else mat = fz_identity; obj = pdf_dict_get(ctx, dict, PDF_NAME(ExtGState)); if (obj) { if (pdf_dict_get(ctx, obj, PDF_NAME(CA)) || pdf_dict_get(ctx, obj, PDF_NAME(ca))) { fz_warn(ctx, "shading with alpha not supported"); } } obj = pdf_dict_get(ctx, dict, PDF_NAME(Shading)); if (!obj) fz_throw(ctx, FZ_ERROR_SYNTAX, "missing shading dictionary"); shade = pdf_load_shading_dict(ctx, doc, obj, &mat); } /* Naked shading dictionary */ else { shade = pdf_load_shading_dict(ctx, doc, dict, &fz_identity); } pdf_store_item(ctx, dict, shade, fz_shade_size(ctx, shade)); return shade; }