Hello,
After reading in an image, storing the image as a buffered image i did two
things:
(1) convert the buffered image (type rgb) to a grayscale image, which
displayed the correct result
(2) copy the original rgb image to a new rgb image, which gave a fuzzy,
almost warped image. The error was traced to the setpixel line.
The code worked fine running on a windows 98 machine, but the error was
encountered on a solaris machine. Is this a bug ??? could the java experts
please give me some advice
the code used was :-
public void Subtract () {
System.out.println("beginning subtraction of images");
Raster r1 = colour1.getData(); // colour1/2 are local buffered
Raster r2 = colour2.getData(); // images
int[] pixel1 = new int[3];
int[] pixel2 = new int[3];
int[] pixelresult = new int[3];
BufferedImage out = new BufferedImage(this.width,this.height,
BufferedImage.TYPE_INT_RGB);
WritableRaster w = out.getData().createCompatibleWritableRaster();
for (int x =0; x < width; x++) {
for (int y = 0; y < height; y++) {
pixel1 = r1.getPixel(x,y,pixel1);
pixel2 = r2.getPixel(x,y,pixel2);
for (int i=0; i < pixel1.length; i++ ) {
pixelresult[i] = pixel1[i] - pixel2[i];
if (pixelresult[i] < 0) {
pixelresult[i] = 0;
}
}
w.setPixel(x,y,(int[])pixelresult);
}
}
out.setData(w);
this.result = out;
System.out.println("finished subtracting images");
}
regards,
sean
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".