/** Returns a <code>GenericImageSinglePassIterator</code> that is
* either a <code>IntPixelIterator</code> or a <code>BytePixelIterator</code>.
* @param image the image to iterate over.
* @param iteratorType one of these 8 BufferedImage types:
* TYPE_INT_ARGB, TYPE_INT_ARGB_PRE, TYPE_INT_RGB, TYPE_INT_BGR,
* TYPE_3BYTE_BGR, TYPE_BYTE_GRAY, TYPE_4BYTE_ABGR, TYPE_4BYTE_ABGR_PRE.
* @return a <code>GenericImageSinglePassIterator</code> for the image provided.
*/
public static GenericImageSinglePassIterator get(Image image,int iteratorType) {
if(!(iteratorType==BufferedImage.TYPE_INT_ARGB ||
iteratorType==BufferedImage.TYPE_INT_ARGB_PRE ||
iteratorType==BufferedImage.TYPE_INT_RGB ||
iteratorType==BufferedImage.TYPE_INT_BGR ||
iteratorType==BufferedImage.TYPE_3BYTE_BGR ||
iteratorType==BufferedImage.TYPE_BYTE_GRAY ||
iteratorType==BufferedImage.TYPE_4BYTE_ABGR ||
iteratorType==BufferedImage.TYPE_4BYTE_ABGR_PRE)) {
throw new IllegalArgumentException("illegal iterator type: "+iteratorType);
}
final ImageProducer producer = image.getSource();
final Consumer consumer = new Consumer(producer, iteratorType);
// ImageProducer.startProduction often starts its own thread, but it's not
// required to. Sometimes in my testing a BufferedImage would make
// this a blocking call. So to be safe this call should be in its
// own thread:
Thread productionThread = new Thread("GenericImageSinglePassIterator: Production Thread") {
@Override
public void run() {
producer.startProduction(consumer);
}
};
productionThread.start();
return consumer.getPixelIterator();
}
GenericImageSinglePassIterator.java 文件源码
java
阅读 21
收藏 0
点赞 0
评论 0
项目:pumpernickel
作者:
评论列表
文章目录