From 3da30304fc1225ab55ab7c5e791870fec1b0b3c3 Mon Sep 17 00:00:00 2001 From: Mathieu Malaterre Date: Wed, 26 Feb 2014 11:03:55 +0000 Subject: [PATCH] [trunk] Import patch from sumatrapdf team. This adds alpha handling. This patch changes ABI. Update issue 225 --- src/lib/openjp2/jp2.c | 9 ++++++++- src/lib/openjp2/openjpeg.h | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/lib/openjp2/jp2.c b/src/lib/openjp2/jp2.c index d3f7515b..9dde2e97 100644 --- a/src/lib/openjp2/jp2.c +++ b/src/lib/openjp2/jp2.c @@ -995,7 +995,12 @@ void opj_jp2_apply_cdef(opj_image_t *image, opj_jp2_color_t *color) for(i = 0; i < n; ++i) { /* WATCH: acn = asoc - 1 ! */ - if((asoc = info[i].asoc) == 0) continue; + if((asoc = info[i].asoc) == 0) + { + if (i < image->numcomps) + image->comps[i].alpha = info[i].typ; + continue; + } cn = info[i].cn; acn = asoc - 1; @@ -1011,6 +1016,8 @@ void opj_jp2_apply_cdef(opj_image_t *image, opj_jp2_color_t *color) info[i].asoc = cn + 1; info[acn].asoc = info[acn].cn + 1; } + + image->comps[cn].alpha = info[i].typ; } if(color->jp2_cdef->info) opj_free(color->jp2_cdef->info); diff --git a/src/lib/openjp2/openjpeg.h b/src/lib/openjp2/openjpeg.h index bbc74577..4792433a 100644 --- a/src/lib/openjp2/openjpeg.h +++ b/src/lib/openjp2/openjpeg.h @@ -538,6 +538,8 @@ typedef struct opj_image_comp { OPJ_UINT32 factor; /** image component data */ OPJ_INT32 *data; + /** alpha channel */ + OPJ_UINT16 alpha; } opj_image_comp_t; /**