* specify applied. */
public Filter handleStream(InputStream inIS,
ParsedURL origURL,
boolean needRawData) {
final DeferRable dr = new DeferRable();
final InputStream is = inIS;
final boolean raw = needRawData;
final String errCode;
final Object [] errParam;
if (origURL != null) {
errCode = ERR_URL_FORMAT_UNREADABLE;
errParam = new Object[] {"PNG", origURL};
} else {
errCode = ERR_STREAM_FORMAT_UNREADABLE;
errParam = new Object[] {"PNG"};
}
Thread t = new Thread() {
public void run() {
Filter filt;
try {
PNGDecodeParam param = new PNGDecodeParam();
param.setExpandPalette(true);
if (raw)
param.setPerformGammaCorrection(false);
else {
param.setPerformGammaCorrection(true);
param.setDisplayExponent(2.2f); // sRGB gamma
}
CachableRed cr = new PNGRed(is, param);
dr.setBounds(new Rectangle2D.Double
(0, 0, cr.getWidth(), cr.getHeight()));
cr = new Any2sRGBRed(cr);
cr = new FormatRed(cr, GraphicsUtil.sRGB_Unpre);
WritableRaster wr = (WritableRaster)cr.getData();
ColorModel cm = cr.getColorModel();
BufferedImage image;
image = new BufferedImage
(cm, wr, cm.isAlphaPremultiplied(), null);
cr = GraphicsUtil.wrap(image);
filt = new RedRable(cr);
} catch (IOException ioe) {
filt = ImageTagRegistry.getBrokenLinkImage
(this, errCode, errParam);
} catch (Throwable t) {
filt = ImageTagRegistry.getBrokenLinkImage
(this, errCode, errParam);
}
dr.setSource(filt);
}
};
t.start();
return dr;
}