org.ajax4jsf.framework.resource.PngRenderer Maven / Gradle / Ivy
/**
* Licensed under the Common Development and Distribution License,
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.sun.com/cddl/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package org.ajax4jsf.framework.resource;
import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage;
import java.io.IOException;
import java.io.OutputStream;
import javax.imageio.ImageIO;
/**
* @author [email protected] (latest modification by $Author: alexsmirnov $)
* @version $Revision: 1.3 $ $Date: 2006/11/15 14:58:28 $
*
*/
public class PngRenderer extends ImageRenderer {
public void sendImage(ResourceContext context, RenderedImage image)
throws IOException {
OutputStream outputStream = context.getOutputStream();
try {
ImageIO.write(image, "png", outputStream);
outputStream.flush();
outputStream.close();
} catch (Exception e) {
// IE can unexpected close connection
}
}
public String getContentType() {
// TODO Auto-generated method stub
return "image/png";
}
public int getImageType() {
// TODO Auto-generated method stub
return BufferedImage.TYPE_INT_ARGB;
}
}