本文整理匯總了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) {
}
}