📄 rpfcolortable.java
字号:
if (Debug.debugging("rpfdetail")) { Debug.output("RpfColortable: Color/gray section subheader (ID=134) location: " + loc[0].componentLocation); } binFile.seek(loc[0].componentLocation); /* Read section subheader */ /* Number of offset records: 2 */ numColorOffsetRecs = binFile.read(); /* Number of cc offset records: 3 */ numColorConvOffsetRecs = binFile.read(); if (Debug.debugging("rpfdetail")) { Debug.output("RpfColortable: numColorOffsetRecs(3): " + numColorOffsetRecs); Debug.output("RpfColortable: numColorConvOffsetRecs(2): " + numColorConvOffsetRecs); } /* DKS. New, read array of structures */ /* Read colormap offset table */ colorOffset = new ColorOffset[numColorOffsetRecs]; /* * DKS. Read color/gray offset records (colormap * subsection) */ if (Debug.debugging("rpfdetail")) { Debug.output("RpfColortable: Colormap subsection loc[1]: " + loc[1].componentLocation); } binFile.seek(loc[1].componentLocation); /* colormap offset table offset: length 4 */ colormapOffsetTableOffset = (long) binFile.readInteger(); /* offset record length:17? length 2 */ offsetRecordLength = (int) binFile.readShort(); if (Debug.debugging("rpfdetail")) { Debug.output("RpfColortable: colormapOffsetTableOffset: " + colormapOffsetTableOffset); Debug.output("RpfColortable: offsetRecordLength:" + offsetRecordLength); } if (reducedColorTable == COLORS_216 || Cib) { /* * 216 or * 217 * colors * desired. * No cct * reading * needed */ /* Read colormap offset table */ for (i = 0; i < numColorOffsetRecs; i++) { /* 3 */ colorOffset[i] = new ColorOffset(); colorOffset[i].tableId = (int) binFile.readShort(); colorOffset[i].numColorRecords = (long) (binFile.readInteger() & 0xFFFFFFFFL); colorOffset[i].colorElementLength = binFile.read(); colorOffset[i].histogramRecordLength = (int) binFile.readShort(); colorOffset[i].colorTableOffset = (long) binFile.readInteger() & 0xFFFFFFFFL; colorOffset[i].histogramTableOffset = (long) binFile.readInteger() & 0xFFFFFFFFL; if (Debug.debugging("rpfdetail")) { Debug.output("RpfColortable: Parse_clut: " + i); Debug.output(colorOffset[i].toString()); } // May look hackish, but 3 is the specification // number for CIB if (colorOffset[i].tableId == CIB_SPEC_CODE_ID) { Cib = true; } else { Cib = false; } /* look for numColorRecords[i] == 216 or 217 */ ncr = colorOffset[i].numColorRecords; if ((ncr == 216) || (ncr == 217)) foundLUT = true; else foundLUT = false; if (Debug.debugging("rpfdetail")) { Debug.output("RpfColortable: foundLUT of desired 216?: " + foundLUT); } if (foundLUT) { /* * Read the color/gray records: 216 or 217 * (transp) color table. */ /* loc[1] is colormap subsection */ binFile.seek(loc[1].componentLocation + colorOffset[i].colorTableOffset); if (ncr >= CADRG_COLORS) { if (Debug.debugging("rpf")) { Debug.error("RpfColortable: ncr is not correct, wingin' it (" + ncr + ")"); } ncr = CADRG_COLORS; } for (j = 0; j < ncr; j++) { /* 216 or 217 */ colorConvTable[j] = j; // Allocate the OMColor here...... if (Cib) { red = binFile.read() & 0x00ff; /* * read * mono * byte * value */ alpha = opaqueness; green = red; blue = red; } else { red = binFile.read() & 0x00ff; /* * read * byte * value */ green = binFile.read() & 0x00ff; /* * read * byte * value */ blue = binFile.read() & 0x00ff; /* * read * byte * value */ alpha = binFile.read(); /* * read byte * value */ alpha = opaqueness; /* DKS NEW TRANSP */ if (ncr == 217 && rgb[(int) (ncr - 1)] == null) { /* * transp * exists */ alpha = 255; red = 255; green = 255; blue = 255; rgb[(int) (ncr - 1)] = new Color(red, green, blue, alpha); } /* if */ } /* else */ rgb[j] = new Color(red, green, blue, alpha); if (Debug.debugging("rpfcolortable")) { if (j == 0) Debug.output("RpfColortable:\n\n---Full color table---\n"); Debug.output("RpfColortable:red: " + red + ", green: " + green + ", blue: " + blue + ", alpha: " + alpha); } } /* for j */ break; /* out of for i */ } /* if foundLUT */ } /* for i */ } /* if reducedColorTable == COLOR_216 */ else { /* cct needed */ /* DKS. Read cct records */ if (Debug.debugging("rpfdetail")) { Debug.output("RpfColortable: color converter subsection loc[2]:" + loc[2].componentLocation); } binFile.seek(loc[2].componentLocation); colorConvOffsetTableOffset = (long) binFile.readInteger(); colorConvOffsetRecl = (int) binFile.readShort(); colorConvRecl = (int) binFile.readShort(); if (Debug.debugging("rpfdetail")) { Debug.output("RpfColortable: colorConvOffsetTableOffset:" + colorConvOffsetTableOffset); Debug.output("RpfColortable: colorConvOffsetRecl:" + colorConvOffsetRecl); Debug.output("RpfColortable: colorConvRecl:" + colorConvRecl); } ColorConversionTable[] cct = new ColorConversionTable[numColorConvOffsetRecs]; /* Color Converter offset table */ for (i = 0; i < numColorConvOffsetRecs; i++) { /* * 2 * cct * recs */ cct[i] = new ColorConversionTable(); cct[i].colorConvTableId = (int) binFile.readShort(); cct[i].colorConvNumRecs = (long) binFile.readInteger(); cct[i].colorConvTableOffset = (long) binFile.readInteger(); cct[i].colorConvSourceTableOffset = (long) binFile.readInteger(); cct[i].colorConvTargetTableOffset = (long) binFile.readInteger(); if (Debug.debugging("rpfdetail")) { Debug.output("RpfColortable: color conversion table - " + i); Debug.output(cct[i].toString()); } } /* for i */ colorOffset = new ColorOffset[numColorConvOffsetRecs]; for (i = 0; i < numColorConvOffsetRecs; i++) { /* 2 */ /* * Read colormap subsection for this target table: * find # color/gray recs. */ binFile.seek(loc[1].componentLocation + cct[i].colorConvTargetTableOffset); colorOffset[i] = new ColorOffset(); colorOffset[i].tableId = (int) binFile.readShort(); colorOffset[i].numColorRecords = (long) binFile.readInteger(); /* look for numColorRecords[i] == 216 or 217 */ ncr = colorOffset[i].numColorRecords; /* numColorRecords[0] can't be 216 for a cct */ /* Read, use 32 or 33 clrs */ if ((((ncr == 32) || (ncr == 33)) && (reducedColorTable == COLORS_32)) || (((ncr == 16) || (ncr == 17)) && (reducedColorTable == COLORS_16))) { /* Read, use 16 or 17 clrs */ foundLUT = true; } else { foundLUT = false; } if (Debug.debugging("rpfdetail")) { Debug.output("RpfColortable: foundLUT?:" + foundLUT); } if (foundLUT) { /* * continue reading colormap * subsection */ colorOffset[i].colorElementLength = binFile.read(); colorOffset[i].histogramRecordLength = (int) binFile.readShort(); colorOffset[i].colorTableOffset = (long) binFile.readInteger(); colorOffset[i].histogramTableOffset = (long) binFile.readInteger(); if (Debug.debugging("rpfdetail")) { Debug.output("RpfColortable: Parse_clut: " + i); Debug.output(colorOffset[i].toString());
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -