I have a one-dimensional array that contains the colors of an image, where each interval of 3 positions is represented by the color of a pixel (R, G, B):
int[] cores = {255, 0, 0, 0, 255, 0, 0, 0, 255};
In this array I would have 3 pixels, where the first would be [255, 0, 0] (Red), the second [0, 255, 0] (Green) and finally [0, 0, 255] . From this array, I'm creating a BufferedImage, trying to pass this array as a parameter, but I did not understand the utility of the offset and scansize parameters (the last two parameters passed to setRGB).
BufferedImage rendered = new BufferedImage(getWidth(), getHeight(), this.imageType);
rendered.setRGB(0, 0, this.getWidth(), this.getHeight(), this.getData(), 0, this.getWidth());
The created image only generates pixels with blue color, I would like to know if it is possible to pass this array as a parameter or if I have to set pixel by pixel the new image.