apps fm4






Java Image I/O API Guide: 3 - Writing Image I/O Applications






Documentation Contents


CONTENTS | PREV
| NEXT








3.4 The ImageWriter Class




Just as we obtained a list of ImageReaders for a particular format using a method from the ImageIO class, we can obtain a list of ImageWriters:

Iterator writers = ImageIO.getImageWritersByFormatName("png");
ImageWriter writer = (ImageWriter)writers.next();



Once an ImageWriter has been obtained, its destination must be set to an ImageOutputStream:

File f = new File("c:\images\myimage.png");
ImageOutputStream ios = ImageIO.createImageOutputStream(f);
writer.setOutput(ios);



Finally, the image may be written to the output stream:

BufferedImage bi;
writer.write(bi);




3.4.1 Writing Multiple Images




The IIOImage class is use to store references to an image, one or more thumbnail images, and metadata (non-image data) associated with the image. Metadata will be discussed below; for now, we will simply pass null as the value for the metadata-related parameters.

The ImageWriter class contains a write method that creates a new file from an IIOImage, and a writeInsert method that adds an IIOImage to an existing file . By calling the two in sequence a multi-image file may be written:

BufferedImage first_bi, second_bi;
IIOImage first_IIOImage = new IIOImage(first_bi, null, null);
IIOImage second_IIOImage = new IIOImage(second_bi, null, null);
writer.write(null, first_IIOImage, null);
if (writer.canInsertImage(1)) {
writer.writeInsert(1, second_IIOImage, null);
} else {
System.err.println("Writer can't append a second image!");
}






CONTENTS | PREV
| NEXT






Copyright © 1995-2010 Sun Microsystems, Inc. All Rights Reserved. Please send comments using this Feedback page.

Java Technology








Wyszukiwarka

Podobne podstrony:
https doc 0o 7g apps viewer googleusercontent
remote x apps 3vxn4tu24iqpik56yr5cgnheg6qnjroa4pavl4i 3vxn4tu24iqpik56yr5cgnheg6qnjroa4pavl4i
extending fm4
apps fm5
apps fm8
ILLUSION APPS
intro fm4
remote x apps 1 jubsp6z6o6okd2t2t2hk27vlkk7eruggepudavy jubsp6z6o6okd2t2t2hk27vlkk7eruggepudavy
remote x apps 7 iszcg6tbz6ufmymt5ictp7mb2s2banlopwxmlxi iszcg6tbz6ufmymt5ictp7mb2s2banlopwxmlxi
remote x apps 3 3ymcj4w5zjeh23xo47vzwd7b27og5uz52wr3vca 3ymcj4w5zjeh23xo47vzwd7b27og5uz52wr3vca
remote x apps 4 go3brw6m4vcy3pz4unuziqgch66dastubqxml4q go3brw6m4vcy3pz4unuziqgch66dastubqxml4q
remote x apps 5 hk5kgky2tn4nae3ld6w2uhgdmxf7452kjwiv57i hk5kgky2tn4nae3ld6w2uhgdmxf7452kjwiv57i
remote x apps 5 hk5kgky2tn4nae3ld6w2uhgdmxf7452kjwiv57i hk5kgky2tn4nae3ld6w2uhgdmxf7452kjwiv57i
apps fm7
falsh CIC V41 BMW APPS
Design Java Apps with UML 72 dpi

więcej podobnych podstron