本文整理汇总了Java中javax.imageio.ImageWriteParam.setProgressiveMode方法的典型用法代码示例。如果您正苦于以下问题:Java ImageWriteParam.setProgressiveMode方法的具体用法?Java ImageWriteParam.setProgressiveMode怎么用?Java ImageWriteParam.setProgressiveMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.imageio.ImageWriteParam
的用法示例。
在下文中一共展示了ImageWriteParam.setProgressiveMode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAnimatedImage
import javax.imageio.ImageWriteParam; //导入方法依赖的package包/类
public void createAnimatedImage(BufferedImage bi, IIOMetadata metadata,
ImageWriter writer, File outputFile) {
try {
fos = new FileOutputStream(outputFile);
ImageOutputStream ios = ImageIO.createImageOutputStream(fos);
System.out.println(ios);
writer.setOutput(ios);
ImageWriteParam param = writer.getDefaultWriteParam();
IIOMetadata streamData = writer.getDefaultStreamMetadata(param);
writer.prepareWriteSequence(streamData);
ImageTypeSpecifier specify = new ImageTypeSpecifier(bi);
IIOMetadata imgData = writer.convertImageMetadata(
(IIOMetadata) metadata, specify, param);
GIFImageMetadata gifData = setAnimationProperties(imgData);
IIOImage iim = new IIOImage(bi, null, gifData);
param.setProgressiveMode(param.MODE_DISABLED);
writer.writeToSequence(iim, param);
writer.endWriteSequence();
ios.close();
} catch (Exception e) {
e.printStackTrace();
}
}
示例2: main
import javax.imageio.ImageWriteParam; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
Iterator witer = ImageIO.getImageWritersByFormatName("png");
ImageWriter w = (ImageWriter)witer.next();
File f = File.createTempFile("WriteProgressive", ".png");
ImageOutputStream ios = ImageIO.createImageOutputStream(f);
w.setOutput(ios);
BufferedImage bi = new BufferedImage(100, 100,
BufferedImage.TYPE_3BYTE_BGR);
Graphics2D g = bi.createGraphics();
Random r = new Random(10);
for (int i = 0; i < 10000; i++) {
Color c =
new Color(r.nextInt(256), r.nextInt(256), r.nextInt(256));
g.setColor(c);
g.fillRect(r.nextInt(100), r.nextInt(100), 1, 1);
}
IIOImage iioimage = new IIOImage(bi, null, null);
ImageWriteParam param = w.getDefaultWriteParam();
param.setProgressiveMode(ImageWriteParam.MODE_DEFAULT);
try {
w.write(null, iioimage, param);
} catch (NullPointerException npe) {
throw new RuntimeException("Got NPE during write!");
}
ios.close();
BufferedImage bi2 = ImageIO.read(f);
f.delete();
ImageCompare.compare(bi, bi2);
}
示例3: test4441315
import javax.imageio.ImageWriteParam; //导入方法依赖的package包/类
private static void test4441315() {
ImageWriteParam iwp = new ImageWriteParam4441315();
try {
iwp.setProgressiveMode(ImageWriteParam.MODE_EXPLICIT);
throw new RuntimeException("Failed to get IAE!");
} catch (IllegalArgumentException e) {
}
}