FileDocCategorySizeDatePackage
MerlinIO.javaAPI DocApache Axis 1.42537Sat Apr 22 18:57:28 BST 2006org.apache.axis.components.image

MerlinIO

public class MerlinIO extends Component implements ImageIO
JDK1.4 based Image I/O NOTE: NEEDS WORK!!!! NEEDS TO BE TESTED.
author
Davanum Srinivas
since
2.0

Fields Summary
Constructors Summary
Methods Summary
public java.awt.ImageloadImage(java.io.InputStream in)
Load an Image.

param
in the stream to load the image
return
the Image

        return javax.imageio.ImageIO.read(in);
    
public voidsaveImage(java.lang.String mimeType, java.awt.Image image, java.io.OutputStream os)
Save an image.

param
mimeType the mime-type of the format to save the image
param
image the image to save
param
os the stream to write to
exception
JimiException if an error prevents image encoding

        ImageWriter writer = null;
        Iterator iter = javax.imageio.ImageIO.getImageWritersByMIMEType(mimeType);
        if (iter.hasNext()) {
            writer = (ImageWriter) iter.next();
        }
        writer.setOutput(javax.imageio.ImageIO.createImageOutputStream(os));
        BufferedImage rendImage = null;
        if (image instanceof BufferedImage) {
            rendImage = (BufferedImage) image;
        } else {
            MediaTracker tracker = new MediaTracker(this);
            tracker.addImage(image, 0);
            tracker.waitForAll();
            rendImage = new BufferedImage(image.getWidth(null), image.getHeight(null), 1);
            Graphics g = rendImage.createGraphics();
            g.drawImage(image, 0, 0, null);
        }
        writer.write(new IIOImage(rendImage, null, null));
        writer.dispose();