本文整理汇总了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;
}