fz_error pdf_load_shading(fz_shade **shadep, pdf_xref *xref, fz_obj *dict) { fz_error error; fz_matrix mat; fz_obj *obj; fz_context *ctx = xref->ctx; if ((*shadep = pdf_find_item(ctx, xref->store, fz_drop_shade, dict))) { fz_keep_shade(*shadep); return fz_okay; } /* Type 2 pattern dictionary */ if (fz_dict_gets(ctx, dict, "PatternType")) { obj = fz_dict_gets(ctx, dict, "Matrix"); if (obj) mat = pdf_to_matrix(ctx, obj); else mat = fz_identity; obj = fz_dict_gets(ctx, dict, "ExtGState"); if (obj) { if (fz_dict_gets(ctx, obj, "CA") || fz_dict_gets(ctx, obj, "ca")) { fz_warn(ctx, "shading with alpha not supported"); } } obj = fz_dict_gets(ctx, dict, "Shading"); if (!obj) return fz_error_make(ctx, "syntaxerror: missing shading dictionary"); error = pdf_load_shading_dict(shadep, xref, obj, mat); if (error) return fz_error_note(ctx, error, "cannot load shading dictionary (%d %d R)", fz_to_num(obj), fz_to_gen(obj)); } /* Naked shading dictionary */ else { error = pdf_load_shading_dict(shadep, xref, dict, fz_identity); if (error) return fz_error_note(ctx, error, "cannot load shading dictionary (%d %d R)", fz_to_num(dict), fz_to_gen(dict)); } pdf_store_item(ctx, xref->store, fz_keep_shade, fz_drop_shade, dict, *shadep); return fz_okay; }
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; }