2
I have a one-dimensional array that contains the colors of an image, where at each 3-position interval the color of a pixel is represented (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] (Blue). From this array, I am creating a Bufferedimage, trying to pass this array as 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 image created generates only pixels with the blue color, I wonder if it is possible to pass this array as parameter or if I will have to set pixel by pixel the new image.