Skip to main content

Subtraction images.

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
3 replies [Last post]
argb
Offline
Joined: 2014-04-10

Hi,
I made a method to implement the subtraction between images but gives me the following exception
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!

when the method is invoked
image1.getRGB (x, y);
Where am I wrong?
Thanks

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
karajohnson
Offline
Joined: 2014-05-20

thanks for your concern i also has that problem..

play pokies online

jv06
Offline
Joined: 2014-05-12

hey argb,

An ArrayOutOfBoundsException may be thrown if the coordinates are not in bounds. However, explicit bounds checking is not guaranteed.

So may be you exceeding the dimensions of the image.

i can't tell u exactly since u haven't posted a full code......

argb
Offline
Joined: 2014-04-10

Thanks jv06,
My code is

  if (img1H == img2H && img1W == img2W) {
            for (int y = 0; y < img1H;y++) {
                for (int x = 0; x < img1W; x++) {
//                  argb1 = image1.getRGB(x, y);
                    argb2 = image2.getRGB(x, y);

is that correct?

Thanks to the availability

good day