/* <dict> .image3 - */ private int zimage3(i_ctx_t *i_ctx_p) { os_ptr op = osp; gs_image3_t image; int interleave_type; ref *pDataDict; ref *pMaskDict; image_params ip_data, ip_mask; int ignored; int code, mcode; check_type(*op, t_dictionary); check_dict_read(*op); if ((code = dict_int_param(op, "InterleaveType", 1, 3, -1, &interleave_type)) < 0 ) return code; gs_image3_t_init(&image, NULL, interleave_type); if (dict_find_string(op, "DataDict", &pDataDict) <= 0 || dict_find_string(op, "MaskDict", &pMaskDict) <= 0 ) return_error(e_rangecheck); if ((code = pixel_image_params(i_ctx_p, pDataDict, (gs_pixel_image_t *)&image, &ip_data, 12, false)) < 0 || (mcode = code = data_image_params(imemory, pMaskDict, &image.MaskDict, &ip_mask, false, 1, 12, false)) < 0 || (code = dict_int_param(pDataDict, "ImageType", 1, 1, 0, &ignored)) < 0 || (code = dict_int_param(pMaskDict, "ImageType", 1, 1, 0, &ignored)) < 0 ) return code; /* * MaskDict must have a DataSource iff InterleaveType == 3. */ if ((ip_data.MultipleDataSources && interleave_type != 3) || ip_mask.MultipleDataSources || mcode != (image.InterleaveType != 3) ) return_error(e_rangecheck); if (image.InterleaveType == 3) { /* Insert the mask DataSource before the data DataSources. */ memmove(&ip_data.DataSource[1], &ip_data.DataSource[0], (countof(ip_data.DataSource) - 1) * sizeof(ip_data.DataSource[0])); ip_data.DataSource[0] = ip_mask.DataSource[0]; } return zimage_setup(i_ctx_p, (gs_pixel_image_t *)&image, &ip_data.DataSource[0], image.CombineWithColor, 1); }
/* <dict> .imagemask1 - */ static int zimagemask1(i_ctx_t *i_ctx_p) { os_ptr op = osp; gs_image_t image; image_params ip; int code; gs_image_t_init_mask_adjust(&image, false, gs_incachedevice(igs) != CACHE_DEVICE_NONE); code = data_image_params(imemory, op, (gs_data_image_t *) & image, &ip, true, 1, 1, false); if (code < 0) return code; return zimage_setup(i_ctx_p, (gs_pixel_image_t *)&image, &ip.DataSource[0], true, 1); }
/* Extract and check the parameters for a gs_pixel_image_t. */ int pixel_image_params(i_ctx_t *i_ctx_p, const ref *op, gs_pixel_image_t *pim, image_params *pip, int max_bits_per_component, bool has_alpha, gs_color_space *csp) { int num_components = gs_color_space_num_components(csp); int code; if (num_components < 1) return_error(e_rangecheck); /* Pattern space not allowed */ pim->ColorSpace = csp; code = data_image_params(imemory, op, (gs_data_image_t *) pim, pip, true, num_components, max_bits_per_component, has_alpha); if (code < 0) return code; pim->format = (pip->MultipleDataSources ? gs_image_format_component_planar : gs_image_format_chunky); return dict_bool_param(op, "CombineWithColor", false, &pim->CombineWithColor); }