-2
爲了看到下面的代碼的影響,我需要一個圖像文件,驗證if測試;你可以給我不同的圖像IndexColorModel
。我需要一個圖像文件,驗證此測試「if(input.getColorModel()instanceof IndexColorModel)」
System.out.println(input.getColorModel());
System.out.println("vvvvvv");
if (input.getColorModel() instanceof IndexColorModel) {
System.out.println("eeeeeeeee");
// Retrieve the IndexColorModel
IndexColorModel icm = (IndexColorModel)input.getColorModel();
// Cache the number of elements in each band of the colormap.
int mapSize = icm.getMapSize();
// Allocate an array for the lookup table data.
System.out.println("eeeeeeeee");
System.out.println(mapSize);
byte[][] lutData = new byte[3][mapSize];
// Load the lookup table data from the IndexColorModel.
icm.getReds(lutData[0]);
icm.getGreens(lutData[1]);
icm.getBlues(lutData[2]);
// Create the lookup table object.
LookupTableJAI lut = new LookupTableJAI(lutData);
// Replace the original image with the 3-band RGB image.
input = JAI.create("lookup", input, lut);
}
如果您希望其他人閱讀它,請格式化您的代碼。 – dharms