Hi, I am trying to make a program that would allow a user to load an image, then click a button on the side that would change the colors within the image. My friend wanted something like this so he could test different color variations quickly for some items he is drawing for a game.
He made a Color palette table with 5 rows and 7 columns. Each row consists of the 7 color tied with that color palette. Row one is the "template" colors. He would load a template image and then my program would go through comparing the colors and changing them to another row's color. Hopefully that makes sense. I'm trying to use Greenfoot's getColor() and setColor() to accomplish this but when I compare the colors nothing happens. This is my color changing code,
as this is howeve, nothing changes. I've seen people on google mention using BufferedImage to do something like this but this seemed a lot easier, being I have no experience with BufferedImage class or Graphics2d. Is what I'm trying to do even possible using greenfoots getColor() and setColor() ?
public void change() { int width = pic.getWidth(); int height = pic.getHeight(); temp = getPic().getTemp(); //template color newCol = getPic().getCol(); //color to change to //scan through pixels in image for(int x = 15; x < width; x++) for(int y = 15; y < height; y++) { here = pic.getColorAt(x,y); //current color //begin changing colors if(here.equals(temp[0])) pic.setColorAt(x,y, newCol[0]); else if(here.equals(temp[1])) pic.setColorAt(x,y, newCol[1]); else if(here.equals(temp[2])) pic.setColorAt(x,y, newCol[2]); else if(here.equals(temp[3])) pic.setColorAt(x,y, newCol[3]); else if(here.equals(temp[4])) pic.setColorAt(x,y, newCol[4]); else if(here.equals(temp[5])) pic.setColorAt(x,y, newCol[5]); else if(here.equals(temp[6])) pic.setColorAt(x,y, newCol[6]); } }