static void jxr_decode_block_alpha(jxr_image_t image, int mx, int my, int *data) { struct info *info = jxr_get_user_data(image); fz_context *ctx = info->ctx; unsigned char *p; int x, y, n; mx *= 16; my *= 16; n = fz_colorspace_n(ctx, info->cspace); for (y = 0; y < 16; y++) { if ((my + y) >= info->height) return; p = info->samples + (my + y) * info->stride + mx * (n + 1); for (x = 0; x < 16; x++) { if ((mx + x) < info->width) { jxr_unpack_alpha_sample(ctx, info, image, data, p + n); p += n + 1; } data++; } } }
static void jxr_decode_block(jxr_image_t image, int mx, int my, int *data) { struct info *info = jxr_get_user_data(image); fz_context *ctx = info->ctx; unsigned char *p; int x, y, n1; mx *= 16; my *= 16; n1 = fz_colorspace_n(ctx, info->cspace) + 1; for (y = 0; y < 16; y++) { if ((my + y) >= info->height) return; p = info->samples + (my + y) * info->stride + mx * n1; for (x = 0; x < 16; x++) { if ((mx + x) < info->width) { jxr_unpack_sample(ctx, info, image, data, p); p += n1; } data += jxr_get_IMAGE_CHANNELS(image) + jxr_get_ALPHACHANNEL_FLAG(image); data += (info->format == JXRC_FMT_32bppRGBE ? 1 : 0); } } }
static void xps_decode_jpegxr_block(jxr_image_t image, int mx, int my, int *data) { struct state *state = jxr_get_user_data(image); xps_context_t *ctx = state->ctx; xps_image_t *output = state->output; int depth; unsigned char *p; int x, y, k; if (!output->samples) { output->width = jxr_get_IMAGE_WIDTH(image); output->height = jxr_get_IMAGE_HEIGHT(image); output->comps = jxr_get_IMAGE_CHANNELS(image); output->hasalpha = jxr_get_ALPHACHANNEL_FLAG(image); output->bits = 8; output->stride = output->width * output->comps; output->samples = xps_alloc(ctx, output->stride * output->height); if (!output->samples) { gs_throw(gs_error_VMerror, "out of memory: output->samples.\n"); return; } switch (output->comps) { default: case 1: output->colorspace = ctx->gray; break; case 3: output->colorspace = ctx->srgb; break; case 4: output->colorspace = ctx->cmyk; break; } } depth = jxr_get_OUTPUT_BITDEPTH(image); my = my * 16; mx = mx * 16; for (y = 0; y < 16; y++) { if (my + y >= output->height) return; p = output->samples + (my + y) * output->stride + mx * output->comps; for (x = 0; x < 16; x++) { if (mx + x >= output->width) data += output->comps; else for (k = 0; k < output->comps; k++) *p++ = scale_bits(depth, *data++); } } }
static void xps_decode_jpegxr_alpha_block(jxr_image_t image, int mx, int my, int *data) { struct state *state = jxr_get_user_data(image); xps_context_t *ctx = state->ctx; xps_image_t *output = state->output; int depth; unsigned char *p; int x, y, k; if (!output->alpha) { output->alpha = xps_alloc(ctx, output->width * output->height); if (!output->alpha) { gs_throw(gs_error_VMerror, "out of memory: output->alpha.\n"); return; } } depth = jxr_get_OUTPUT_BITDEPTH(image); my = my * 16; mx = mx * 16; for (y = 0; y < 16; y++) { if (my + y >= output->height) return; p = output->alpha + (my + y) * output->width + mx; for (x = 0; x < 16; x++) { if (mx + x >= output->width) data ++; else *p++ = scale_bits(depth, *data++); } } }