本文整理汇总了Java中java.awt.image.IndexColorModel.getPixelSize方法的典型用法代码示例。如果您正苦于以下问题:Java IndexColorModel.getPixelSize方法的具体用法?Java IndexColorModel.getPixelSize怎么用?Java IndexColorModel.getPixelSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.image.IndexColorModel
的用法示例。
在下文中一共展示了IndexColorModel.getPixelSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setAlpha
import java.awt.image.IndexColorModel; //导入方法依赖的package包/类
/**
* Returns an index color model with specified opacity (alpha).
* @param icm an index color model from which to copy RGBs.
* @param alpha opacity in the range [0.0,1.0].
* @return the index color model with alpha.
*/
public static IndexColorModel setAlpha(IndexColorModel icm, double alpha) {
int bits = icm.getPixelSize();
int size = icm.getMapSize();
byte[] r = new byte[size];
byte[] g = new byte[size];
byte[] b = new byte[size];
byte[] a = new byte[size];
icm.getReds(r);
icm.getGreens(g);
icm.getBlues(b);
byte ia = (byte)(255.0*alpha+0.5);
for (int i=0; i<size; ++i)
a[i] = ia;
return new IndexColorModel(bits,size,r,g,b,a);
}
示例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: drawDIBImage
import java.awt.image.IndexColorModel; //导入方法依赖的package包/类
protected void drawDIBImage(byte[] image,
float destX, float destY,
float destWidth, float destHeight,
float srcX, float srcY,
float srcWidth, float srcHeight,
int sampleBitsPerPixel,
IndexColorModel icm) {
int bitCount = 24;
byte[] bmiColors = null;
if (icm != null) {
bitCount = sampleBitsPerPixel;
bmiColors = new byte[(1<<icm.getPixelSize())*4];
for (int i=0;i<icm.getMapSize(); i++) {
bmiColors[i*4+0]=(byte)(icm.getBlue(i)&0xff);
bmiColors[i*4+1]=(byte)(icm.getGreen(i)&0xff);
bmiColors[i*4+2]=(byte)(icm.getRed(i)&0xff);
}
}
drawDIBImage(getPrintDC(), image,
destX, destY,
destWidth, destHeight,
srcX, srcY,
srcWidth, srcHeight,
bitCount, bmiColors);
}