[fpc-pascal] Save image into BMP or JPEG using Free Pascal (Save screenshot of OpenGL scene)

Michalis Kamburelis michalis.kambi at gmail.com
Wed Feb 20 11:45:29 CET 2008

Marco van de Voort wrote:
>> Jakub Marian wrote:
>> The image format in the memory is clearly specified, as the main use of 
>> this unit is to cooperate with OpenGL (for loading images, textures, 
>> saving screenshots etc.). See TImage class comments, basically RawPixels 
>> is simply a pointer to an array of Width * Height pixel values, and each 
>> descendant of TImage specifies the exact layout of "pixel" --- e.g. for 
>> TRGBImage a pixel is just 3 bytes, for red/green/blue.
> Is the latter a hard requirement of OpenGL? In the fpimage rework, I had
> hoped to skip 24-bit color and use 32-bit for that.

There is GL_RGBA format, combined with GL_UNSIGNED_BYTE this makes 32 
bit pixel (with the last byte for storing alpha --- depending on what 
you actually do with your image data, you may be able to simply ignore it).

> Also, does OpenGL support bottom up (lines other way around in memory)
> layouts, or only top down?

AFAIK, no. That is, OpenGL images always have the lowest row first in 
the memory. Everyone simply swaps the rows in memory for OpenGL, since 
all image formats have this the other way around.


More information about the fpc-pascal mailing list