I have some Javascript code that acts on an pixel array defined like so:
screen = {'width':160, 'height':144, 'data':new Array(160*144*4)};
...
canvas.putImageData(GPU._scrn, 0,0);
Where screen is 1D array of width * height * 4 values representing the colors as detailed here: https://developer.mozilla.org/En/HTML/Canvas/Pixel_manipulation_with_canvas
Is there a convenience method to paint this array to the screen as is? If not, what's the easiest way to paint this array using Swing?
BufferedImage
is probably the most flexible choice. You can use it as anIcon
or overridepaintComponent()
for the full generality of Java2D.