static int gx_image1_mask_sget(gs_image_common_t *pic, stream *s, gs_color_space *ignore_pcs) { gs_image1_t *const pim = (gs_image1_t *)pic; int code; uint control; if ((code = sget_variable_uint(s, &control)) < 0) return code; gs_image_t_init_mask(pim, (control & MI_Decode) != 0); if ((code = sget_variable_uint(s, (uint *)&pim->Width)) < 0 || (code = sget_variable_uint(s, (uint *)&pim->Height)) < 0 ) return code; if (control & MI_ImageMatrix) { if ((code = sget_matrix(s, &pim->ImageMatrix)) < 0) return code; } else gx_image_matrix_set_default((gs_data_image_t *)pim); pim->Interpolate = (control & MI_Interpolate) != 0; pim->adjust = (control & MI_adjust) != 0; pim->Alpha = (control >> MI_Alpha_SHIFT) & MI_Alpha_MASK; pim->BitsPerComponent = ((control >> MI_BPC_SHIFT) & MI_BPC_MASK) + 1; return 0; }
/* * Read generic pixel image parameters. */ int gx_pixel_image_sget(gs_pixel_image_t *pim, stream *s, gs_color_space *pcs) { uint control; float decode_default_1 = 1; int num_components, num_decode; int i; int code; uint ignore; if ((code = sget_variable_uint(s, &control)) < 0 || (code = sget_variable_uint(s, (uint *)&pim->Width)) < 0 || (code = sget_variable_uint(s, (uint *)&pim->Height)) < 0 ) return code; if_debug3('b', "[b]get control=0x%x, Width=%d, Height=%d\n", control, pim->Width, pim->Height); if (control & PI_ImageMatrix) { if ((code = sget_matrix(s, &pim->ImageMatrix)) < 0) return code; debug_b_print_matrix(pim); } else gx_image_matrix_set_default((gs_data_image_t *)pim); pim->BitsPerComponent = ((control >> PI_BPC_SHIFT) & PI_BPC_MASK) + 1; pim->format = (control >> PI_FORMAT_SHIFT) & PI_FORMAT_MASK; pim->ColorSpace = pcs; num_components = gs_color_space_num_components(pcs); num_decode = num_components * 2; if (gs_color_space_get_index(pcs) == gs_color_space_index_Indexed) decode_default_1 = (float)pcs->params.indexed.hival; if (control & PI_Decode) { uint dflags = 0x10000; float *dp = pim->Decode; for (i = 0; i < num_decode; i += 2, dp += 2, dflags <<= 2) { if (dflags >= 0x10000) { dflags = sgetc(s) + 0x100; if (dflags < 0x100) return_error(gs_error_ioerror); } switch (dflags & 0xc0) { case 0x00: dp[0] = 0, dp[1] = DECODE_DEFAULT(i + 1, decode_default_1); break; case 0x40: dp[0] = DECODE_DEFAULT(i + 1, decode_default_1), dp[1] = 0; break; case 0x80: dp[0] = 0; if (sgets(s, (byte *)(dp + 1), sizeof(float), &ignore) < 0) return_error(gs_error_ioerror); break; case 0xc0: if (sgets(s, (byte *)dp, sizeof(float) * 2, &ignore) < 0) return_error(gs_error_ioerror); break; } } debug_b_print_decode(pim, num_decode); } else { for (i = 0; i < num_decode; ++i) pim->Decode[i] = DECODE_DEFAULT(i, decode_default_1); } pim->Interpolate = (control & PI_Interpolate) != 0; pim->CombineWithColor = (control & PI_CombineWithColor) != 0; return control >> PI_BITS; }