建立一個256色調色盤的IndexColorModel |
尚未結案
|
vespa
一般會員 發表:14 回覆:22 積分:7 註冊:2004-02-13 發送簡訊給我 |
請問大家:
Java 2D 圖學技術一書內有提到五色調色盤的IndexColorModel
程式碼如下:
static int indexColor(Color _color) {
byte ff = (byte)0xff;
byte[] r = { ff, 0, 0, ff, 0 };
byte[] g = { 0, ff, 0, ff, 0 };
byte[] b = { 0, 0, ff, ff, 0 };
ColorModel cm = new IndexColorModel(3, 5, r, g, b);
float[] normalizedComponents = _color.getComponents(null);
int[] unnormalizedComponents = cm.getUnnormalizedComponents(
normalizedComponents, 0, null, 0);
int rgb = _color.getRGB();
Object pixel = cm.getDataElements(rgb, null);
return ((byte[])pixel)[0]; 請問如果要把調色盤調至256色或更高的色階應該要怎麼修改?
好像跟R、G、B的位元遮罩有關?
謝謝...
|
neoart
版主 發表:22 回覆:582 積分:425 註冊:2003-05-09 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |