本文整理匯總了Java中java.awt.image.RescaleOp.getNumFactors方法的典型用法代碼示例。如果您正苦於以下問題:Java RescaleOp.getNumFactors方法的具體用法?Java RescaleOp.getNumFactors怎麽用?Java RescaleOp.getNumFactors使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.image.RescaleOp
的用法示例。
在下文中一共展示了RescaleOp.getNumFactors方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isRescaleOpValid
import java.awt.image.RescaleOp; //導入方法依賴的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;
}