Background:
The goal is to write a file with a large size (at least 2048 x 2048 pixels) with the displayed OpenGL data.
Today, I first use glReadPixels to get 32-bit (argb8888) pixel data into an int array.
Then I copy the data to a new short array, converting 32-bit argb values ββto 16-bit (rgb565) values. At this point, I also flip the image upside down and change the order of colors to make opengl-image data compatible with android raster data (order of line order and color channel).
Finally, I create an instance of Bitmap () and .copyPixelsFromBuffer (Buffer b) to save it to disk as a png file.
However, I want to use memory more efficiently to avoid memory failures on some phones.
Question:
Is it possible to somehow transfer the first transformation from int [] β short [] (and avoid allocating a new array for the pixel data)? Maybe just use byte arrays / buffers and write the converted pixels to the same array that I read from ...
More important: can I skip creating a bitmap (here, where the program crashed) and somehow write the data directly to disk as a working image file (and avoid re-highlighting the pixel data in the raster object)?
EDIT: , , 16- , .