本文整理汇总了Java中java.awt.image.SampleModel.createCompatibleSampleModel方法的典型用法代码示例。如果您正苦于以下问题:Java SampleModel.createCompatibleSampleModel方法的具体用法?Java SampleModel.createCompatibleSampleModel怎么用?Java SampleModel.createCompatibleSampleModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.image.SampleModel
的用法示例。
在下文中一共展示了SampleModel.createCompatibleSampleModel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import java.awt.image.SampleModel; //导入方法依赖的package包/类
public static void main(String[] a) throws RuntimeException {
SampleModel model = Raster.createBandedRaster(DataBuffer.TYPE_INT,
10, 5, 4, null).getSampleModel();
final int inputWidths[]
= {Integer.MIN_VALUE, -1000, -1, 0, 1, 1000, Integer.MAX_VALUE};
final int inputHeights[]
= {Integer.MIN_VALUE, -1000, -1, 0, 1, 1000, Integer.MAX_VALUE};
// There are 49 combinations of (width, height) possible using above two
// arrays
// Only 6 valid combinations of (width, height) that do not throw
// exception are :
// (1, 1)
// (1, 1000)
// (1, Integer.MAX_VALUE)
// (1000, 1)
// (1000, 1000)
// (Integer.MAX_VALUE, 1)
final int expectedCount = 43;
int count = 0;
for (int i : inputWidths) {
for (int j : inputHeights) {
try {
SampleModel model2 = model.createCompatibleSampleModel(i, j);
} catch (IllegalArgumentException e) {
count++;
}
}
}
if (count != expectedCount) {
throw new RuntimeException(
"Test Failed. Expected IllegalArgumentException Count = " +
expectedCount + " Got Count = " + count);
}
}