I'm trying to write a method to test if pixel by pixel two images are equal, and a lot of the ways I'm seeing are really complicated and above my knowledge. This is the way I'm trying to do it, but I'm getting errors:
public boolean equals(Object other)
{
if(!(other instanceof MyArt))
{
return false;
}
MyArt otherArtObject = (MyArt)other;
for(int x = 0; x < image.getWidth(); x++)
{
for(int y = 0; y < image.getHeight(); y++)
{
Pixel pixelObj = this.image.getPixel(x,y);
Pixel otherPixelObj = otherArtObject.image.getPixel(x,y);
if((pixelObj == otherPixelObj)&&(pixelObj.getRed()==otherPixelObj.getRed())&&(pixelObj.getBlue()==otherPixelObj.getBlue())&&(pixelObj.getGreen()==otherPixelObj.getGreen()))
{
return true;
}
}
}
return false;
}
The my art class just creates another image. So it creates another object, and then if the two objects are equal, and the red, green and blue, values are equivalent it returns true. If not it returns false. Thanks for any input!