ErrorCodes.OBJECT_NOT_EXPECTED_TYPE,
image.toString(),
"RgbMaskedImage",
null);
}
RgbMaskedImage rgbImage = (RgbMaskedImage) image;
int[] src = rgbImage.getData();
RgbImage rgbOutput = new RgbImage(rgbImage.getWidth(), rgbImage.getHeight());
int[] dst = rgbOutput.getData();
for (int i=0; i<rgbImage.getHeight(); i++) {
for (int j=0; j<rgbImage.getWidth(); j++) {
int nColorPixel = src[i*rgbImage.getWidth() + j];
if (rgbImage.isMasked(i, j)) {
int nRed = RgbVal.getR(nColorPixel);
int nGreen = RgbVal.getG(nColorPixel);
int nBlue = RgbVal.getB(nColorPixel);
nRed = Math.max(Byte.MIN_VALUE,
Math.min(Byte.MAX_VALUE,
(nRed*this.nDim)>>8));
nGreen = Math.max(Byte.MIN_VALUE,
Math.min(Byte.MAX_VALUE,
(nGreen*this.nDim)>>8));
nBlue = Math.max(Byte.MIN_VALUE,
Math.min(Byte.MAX_VALUE,
(nBlue*this.nDim)>>8));
dst[i*rgbImage.getWidth()+j] =
RgbVal.toRgb((byte)nRed, (byte)nGreen, (byte)nBlue);
} else {
dst[i*rgbImage.getWidth()+j] = nColorPixel;
}
}
}
super.setOutput(rgbOutput);
}