Function Read-Memory-Image

Part of:

package glfw
( read-memory-image < data > < size > < img > < flags > )
Parameters
data
The memory buffer holding the contents of the file that should be read.
size
The size, in bytes, of the memory buffer.
img
Pointer to a GLFWimage struct, which will hold the information about the loaded image (if the
read was successful).
flags
Flags for controlling the image reading process. Valid flags are listed in table 3.6
Return values
The function returns t if the image was loaded successfully. Otherwise nil is
returned.
Description
The function reads an image from the memory buffer specified by the parameter data and returns the
image information and data in a GLFWimage structure, which has the following definition:
§ ¤
typedef struct {
int Width, Height; // Image dimensions
int Format; // OpenGL pixel format
int BytesPerPixel; // Number of bytes per pixel
unsigned char *Data; // Pointer to pixel data
} GLFWimage;
¦ ¥
Width and Height give the dimensions of the image. Format specifies an OpenGL™ pixel format,
which can be GL_LUMINANCE or GL_ALPHA (for gray scale images), GL_RGB or GL_RGBA.
BytesPerPixel specifies the number of bytes per pixel. Data is a pointer to the actual pixel data.
By default the read image is rescaled to the nearest larger 2m × 2n resolution using bilinear
interpolation, if necessary, which is useful if the image is to be used as an OpenGL™ texture. This
behavior can be disabled by setting the GLFW_NO_RESCALE_BIT flag.
Unless the flag GLFW_ORIGIN_UL_BIT is set, the first pixel in img->Data is the lower left corner of
the image. If the flag GLFW_ORIGIN_UL_BIT is set, however, the first pixel is the upper left corner.
For single component images (i.e. gray scale), Format is set to GL_ALPHA if the flag
GLFW_ALPHA_MAP_BIT flag is set, otherwise Format is set to GL_LUMINANCE.
Notes
glfwReadMemoryImage supports the Truevision Targa version 1 file format (.TGA). Supported pixel
formats are: 8-bit gray scale, 8-bit paletted (24/32-bit color), 24-bit true color and 32-bit true color +
alpha.
Paletted images are translated into true color or true color + alpha pixel formats.
Please note that OpenGL™ 1.0 does not support single component alpha maps, so do not use images
with Format = GL_ALPHA directly as textures under OpenGL™ 1.0.