下面列出了java.awt.image.IndexColorModel#getComponentSize() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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();
}
/** Gets the size of the components or the bit depth for all the color
* coomponents.
*/
private static byte[] getCompSize(IndexColorModel icm) {
int[] comp = icm.getComponentSize();
int size = comp.length;
byte[] buf = new byte[size];
for (int i = 0; i < size; i++)
buf[i] = (byte)(comp[i] - 1);
return buf;
}
/** Gets the LUT from the <code>IndexColorModel</code> as an two-dimensional
* byte array.
*/
private static byte[][] getLUT(IndexColorModel icm) {
int[] comp = icm.getComponentSize();
int size = icm.getMapSize();
byte[][] lut = new byte[comp.length][size];
icm.getReds(lut[0]);
icm.getGreens(lut[1]);
icm.getBlues(lut[2]);
if (comp.length == 4)
icm.getAlphas(lut[3]);
return lut;
}
/** Compute the length of this box. */
private static int computeLength(IndexColorModel icm) {
int size = icm.getMapSize();
int[] comp = icm.getComponentSize();
return 11 + comp.length + size * comp.length;
}