I am currently trying to make a CImage class similar to the PImage class. But I want to have a method for accessing pixel values from the image array in the form img.pixels[y].
How do I set up the method that way?
Here’s the some of the code
class CImage{
C3[][] cImageArray;
int width;
int height;
CImage (PImage img){
width = img.width;
height = img.height;
cImageArray = new C3[width][height];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
cImageArray[x][y] = new C3(img.pixels[index(x, y, width)]);
}
}
}
/*
C3 getC3[x][y]{
return imageArray[x][y];
}
*/
PImage toPImage(){
PImage img = new PImage(width, height, RGB);
for(int y = 0; y < height; y++){
for(int x = 0; x < width; x++){
img.pixels[index(x, y, width)] = cImageArray[x][y].toColor();
}
}
return img;
}
}
It’s the getC3 method. Or do I just use object.cImageArray[y]?
I am also trying to make a set C3 method in that fashion.