[gs-commits] rev 11810 - branches/luratech_work/base
larsu at ghostscript.com
larsu at ghostscript.com
Thu Oct 14 20:16:38 UTC 2010
Author: larsu
Date: 2010-10-14 20:16:37 +0000 (Thu, 14 Oct 2010)
New Revision: 11810
Modified:
branches/luratech_work/base/sjpx_luratech.c
Log:
sjpx_luratech.c: Add support for indexed color spaces.
For now, the palette is expanded.
This fixes rendering of j2kp4-file9-palette.pdf.
Modified: branches/luratech_work/base/sjpx_luratech.c
===================================================================
--- branches/luratech_work/base/sjpx_luratech.c 2010-10-14 16:40:39 UTC (rev 11809)
+++ branches/luratech_work/base/sjpx_luratech.c 2010-10-14 20:16:37 UTC (rev 11810)
@@ -117,7 +117,27 @@
from each call in planar buffers and interleave a tile at
a time into a stipe buffer for output */
- if (state->ncomp == 1) {
+ if (state->colorspace == gs_jpx_cs_indexed && sComponent == 0) {
+ JP2_Palette_Params *pal;
+ JP2_Error err;
+ int i, c;
+ unsigned char *dst = &state->image[state->stride * ulRow +
+ state->ncomp * ulStart + comp];
+
+ err = JP2_Decompress_GetPalette(state->handle, &pal);
+ if (err != cJP2_Error_OK)
+ return err;
+
+ if (pal->ulEntries != 256)
+ return cJP2_Error_Invalid_Colorspace;
+
+ for (i = 0; i < ulNum; i++) {
+ unsigned char v = pucData[i];
+ for (c = 0; c < state->ncomp; c++)
+ *dst++ = (unsigned char)pal->ppulPalette[c][v];
+ }
+ }
+ else if (state->ncomp == 1) {
if (state->bpc <= 8) {
memcpy(&state->image[state->stride*ulRow + state->ncomp*ulStart],
pucData, ulNum);
@@ -423,24 +443,46 @@
}
image_cs = (JP2_Colorspace)result;
switch (result) {
- case cJP2_Colorspace_Gray: cspace = "gray"; break;
- case cJP2_Colorspace_RGBa: cspace = "sRGB"; break;
+ case cJP2_Colorspace_Gray:
+ cspace = "gray";
+ state->colorspace = gs_jpx_cs_gray;
+ break;
+ case cJP2_Colorspace_RGBa:
+ cspace = "sRGB";
+ state->colorspace = gs_jpx_cs_rgb;
+ break;
case cJP2_Colorspace_RGB_YCCa:
cspace = "sRGB YCrCb"; break;
+ state->colorspace = gs_jpx_cs_rgb;
+ break;
case cJP2_Colorspace_CIE_LABa:
- cspace = "CIE Lab"; break;
+ cspace = "CIE Lab";
+ state->colorspace = gs_jpx_cs_rgb;
+ break;
case cJP2_Colorspace_ICCa:
- cspace = "ICC profile"; break;
+ cspace = "ICC profile";
+ state->colorspace = gs_jpx_cs_rgb;
+ break;
case cJP2_Colorspace_Palette_Gray:
- cspace = "indexed gray"; break;
+ cspace = "indexed gray";
+ state->colorspace = gs_jpx_cs_indexed;
+ break;
case cJP2_Colorspace_Palette_RGBa:
- cspace = "indexed sRGB"; break;
+ cspace = "indexed sRGB";
+ state->colorspace = gs_jpx_cs_indexed;
+ break;
case cJP2_Colorspace_Palette_RGB_YCCa:
- cspace = "indexed sRGB YCrCb"; break;
+ cspace = "indexed sRGB YCrCb";
+ state->colorspace = gs_jpx_cs_indexed;
+ break;
case cJP2_Colorspace_Palette_CIE_LABa:
- cspace = "indexed CIE Lab"; break;
+ cspace = "indexed CIE Lab";
+ state->colorspace = gs_jpx_cs_indexed;
+ break;
case cJP2_Colorspace_Palette_ICCa:
- cspace = "indexed with ICC profile"; break;
+ cspace = "indexed with ICC profile";
+ state->colorspace = gs_jpx_cs_indexed;
+ break;
}
if_debug1('w', "[w]jpxd image colorspace is %s\n", cspace);
}
More information about the gs-commits
mailing list