本文整理汇总了Java中java.awt.image.ColorModel.getNumComponents方法的典型用法代码示例。如果您正苦于以下问题:Java ColorModel.getNumComponents方法的具体用法?Java ColorModel.getNumComponents怎么用?Java ColorModel.getNumComponents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.image.ColorModel
的用法示例。
在下文中一共展示了ColorModel.getNumComponents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isRescaleOpValid
import java.awt.image.ColorModel; //导入方法依赖的package包/类
/**************************** RescaleOp support *****************************/
public static boolean isRescaleOpValid(RescaleOp rop,
BufferedImage srcImg)
{
int numFactors = rop.getNumFactors();
ColorModel srcCM = srcImg.getColorModel();
if (srcCM instanceof IndexColorModel) {
throw new
IllegalArgumentException("Rescaling cannot be "+
"performed on an indexed image");
}
if (numFactors != 1 &&
numFactors != srcCM.getNumColorComponents() &&
numFactors != srcCM.getNumComponents())
{
throw new IllegalArgumentException("Number of scaling constants "+
"does not equal the number of"+
" of color or color/alpha "+
" components");
}
int csType = srcCM.getColorSpace().getType();
if (csType != ColorSpace.TYPE_RGB &&
csType != ColorSpace.TYPE_GRAY)
{
// Not prepared to deal with other color spaces
return false;
}
if (numFactors == 2 || numFactors > 4) {
// Not really prepared to handle this at the native level, so...
return false;
}
return true;
}