本文整理匯總了Java中java.awt.image.IndexColorModel.getRGB方法的典型用法代碼示例。如果您正苦於以下問題:Java IndexColorModel.getRGB方法的具體用法?Java IndexColorModel.getRGB怎麽用?Java IndexColorModel.getRGB使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.image.IndexColorModel
的用法示例。
在下文中一共展示了IndexColorModel.getRGB方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createTestImage
import java.awt.image.IndexColorModel; //導入方法依賴的package包/類
protected BufferedImage createTestImage(int numColors) {
IndexColorModel icm = createTestICM(numColors);
int w = numColors * 10;
int h = 20;
BufferedImage img = new BufferedImage(w, h,
BufferedImage.TYPE_BYTE_INDEXED, icm);
Graphics2D g = img.createGraphics();
for (int i = 0; i < numColors; i++) {
int rgb = icm.getRGB(i);
//System.out.printf("pixel %d, rgb %x\n", i, rgb);
g.setColor(new Color(rgb));
g.fillRect(i * 10, 0, w - i * 10, h);
}
g.dispose();
return img;
}
示例2: main
import java.awt.image.IndexColorModel; //導入方法依賴的package包/類
public static void main(String args[]) {
IndexColorModel cm =
new IndexColorModel(8, 1, new byte[]{(byte) 128}, new byte[]{(byte) 128}, new byte[]{(byte) 128});
cm.getTransparency();
cm.getComponentSize();
cm.isAlphaPremultiplied();
cm.hasAlpha();
cm.isAlphaPremultiplied();
cm.getTransferType();
cm.getPixelSize();
cm.getComponentSize();
cm.getNumComponents();
cm.getNumColorComponents();
cm.getRed(20);
cm.getGreen(20);
cm.getBlue(20);
cm.getAlpha(20);
cm.getRGB(20);
cm.isAlphaPremultiplied();
}
示例3: isMultiColor
import java.awt.image.IndexColorModel; //導入方法依賴的package包/類
/**
* Determines if a specified color map has more than one color.
* Note that we ignore any variation in alpha.
*/
private static boolean isMultiColor(ColorMapped cm) {
ColorMap cmap = cm.getColorMap();
IndexColorModel icm = cmap.getColorModel();
int n = icm.getMapSize();
int rgb = icm.getRGB(0)&0x00ffffff;
for (int i=1; i<n; ++i)
if (rgb!=(icm.getRGB(i)&0x00ffffff))
return true;
return false;
}