diff --git a/poppler/JPEG2000Stream.cc b/poppler/JPEG2000Stream.cc index 4c632d7..d1a61ba 100644 --- a/poppler/JPEG2000Stream.cc +++ b/poppler/JPEG2000Stream.cc @@ -188,6 +188,7 @@ void JPXStream::init() } unsigned char *cdata = (unsigned char *)priv->image->comps[component].data; int adjust = 0; + int depth = priv->image->comps[component].prec; if (priv->image->comps[component].prec > 8) adjust = priv->image->comps[component].prec - 8; int sgndcorr = 0; @@ -201,6 +202,8 @@ void JPXStream::init() if (unlikely(r > 255)) r = 255; } + if (depth < 8) + r = r << (8 - depth); *(cdata++) = r; } } @@ -335,6 +338,7 @@ void JPXStream::init() } unsigned char *cdata = (unsigned char *)priv->image->comps[component].data; int adjust = 0; + int depth = priv->image->comps[component].prec; if (priv->image->comps[component].prec > 8) adjust = priv->image->comps[component].prec - 8; int sgndcorr = 0; @@ -348,6 +352,8 @@ void JPXStream::init() if (unlikely(r > 255)) r = 255; } + if (depth < 8) + r = r << (8 - depth); *(cdata++) = r; } }