本文整理汇总了Java中java.awt.image.ColorModel.getComponentSize方法的典型用法代码示例。如果您正苦于以下问题:Java ColorModel.getComponentSize方法的具体用法?Java ColorModel.getComponentSize怎么用?Java ColorModel.getComponentSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.image.ColorModel
的用法示例。
在下文中一共展示了ColorModel.getComponentSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: canEncodeImage
import java.awt.image.ColorModel; //导入方法依赖的package包/类
public boolean canEncodeImage(ImageTypeSpecifier type) {
if (type == null) {
throw new IllegalArgumentException("type == null!");
}
SampleModel sm = type.getSampleModel();
ColorModel cm = type.getColorModel();
boolean canEncode = sm.getNumBands() == 1 &&
sm.getSampleSize(0) <= 8 &&
sm.getWidth() <= 65535 &&
sm.getHeight() <= 65535 &&
(cm == null || cm.getComponentSize()[0] <= 8);
if (canEncode) {
return true;
} else {
return PaletteBuilder.canCreatePalette(type);
}
}
示例2: needToCreateIndex
import java.awt.image.ColorModel; //导入方法依赖的package包/类
private boolean needToCreateIndex(RenderedImage image) {
SampleModel sampleModel = image.getSampleModel();
ColorModel colorModel = image.getColorModel();
return sampleModel.getNumBands() != 1 ||
sampleModel.getSampleSize()[0] > 8 ||
colorModel.getComponentSize()[0] > 8;
}
示例3: getPixelFormatForColorModel
import java.awt.image.ColorModel; //导入方法依赖的package包/类
private int getPixelFormatForColorModel( ColorModel cm ){
if( cm == null ){
return DEFAULT_PIXEL_FORMAT; // TODO is PixelFormat.Canonical better here?
}
int bpp = cm.getPixelSize();
int[] sizes = cm.getComponentSize();
switch( bpp ){
case 1: return PixelFormat.Undefined; // Indexed is invalid and there is no 1bpp
case 4: return PixelFormat.Format4bppIndexed;
case 8: return PixelFormat.Format8bppIndexed;
case 16:
if( sizes.length <= 1) {
return PixelFormat.Format16bppGrayScale;
}
if( sizes.length == 3 ){
if( sizes[0] == 5 && sizes[2] == 5 ){
return sizes[1] == 5 ? PixelFormat.Format16bppRgb555 : PixelFormat.Format16bppRgb565;
}
}
if( sizes.length == 4 && cm.hasAlpha() ){
return PixelFormat.Format16bppArgb1555;
}
break;
case 24:
return PixelFormat.Format24bppRgb;
case 32:
if(!cm.hasAlpha()){
return PixelFormat.Format32bppRgb;
} else {
return cm.isAlphaPremultiplied() ? PixelFormat.Format32bppPArgb : PixelFormat.Format32bppArgb;
}
case 48:
return PixelFormat.Format48bppRgb;
case 64:
return cm.isAlphaPremultiplied() ? PixelFormat.Format64bppPArgb : PixelFormat.Format64bppArgb;
}
return PixelFormat.Undefined;
}