matrix = new float[sm.getNumBands()][1];
matrix[0][0] = 1;
}
Raster srcRas = src.getData(wr.getBounds());
BandCombineOp op = new BandCombineOp(matrix, null);
op.filter(srcRas, wr);
} else {
// REVIEW: Alpha handling may not be correct through here.
// Since the colorconversion may not be a linear op it
// is probably required to divide out the alpha before
// doing the color conversion.
//
// This might be especially tricky since there are bugs
// in the ColorConvert Ops handling of alpha...
ColorConvertOp op = new ColorConvertOp(null);
Raster srcRas = src.getData(wr.getBounds());
Point pt = new Point(srcRas.getMinX(), srcRas.getMinY());
WritableRaster srcWr = (WritableRaster)srcRas;
// srcWr = Raster.createWritableRaster(srcRas.getSampleModel(),
// srcRas.getDataBuffer(),
// pt);
BufferedImage srcBI, dstBI;
srcBI = new BufferedImage(cm,
srcWr.createWritableTranslatedChild(0,0),
cm.isAlphaPremultiplied(),
null);
// All this nonsense is to work around the fact that the
// Color convert op doesn't properly copy the Alpha from
// src to dst.
PixelInterleavedSampleModel dstSM;
dstSM = (PixelInterleavedSampleModel)wr.getSampleModel();
SampleModel smna = new PixelInterleavedSampleModel
(dstSM.getDataType(),
dstSM.getWidth(), dstSM.getHeight(),
dstSM.getPixelStride(), dstSM.getScanlineStride(),
new int [] { 0 });
WritableRaster dstWr;
dstWr = Raster.createWritableRaster(smna,
wr.getDataBuffer(),
new Point(0,0));
ColorModel cmna = new ComponentColorModel
(ColorSpace.getInstance(ColorSpace.CS_GRAY),
new int [] {8}, false, false,
Transparency.OPAQUE,
DataBuffer.TYPE_BYTE);
dstBI = new BufferedImage(cmna, dstWr, false, null);
op.filter(srcBI, dstBI);
// I never have to 'fix' alpha premult since I take
// it's value from my source....
if (cm.hasAlpha() && getColorModel().hasAlpha())
copyBand(srcWr, sm.getNumBands()-1,