# CreateImageFromMemblock

## Description

Creates an image from a memblock. The memblock must exist, if the image exists it will be overwritten, if not it will be created. The first 4 bytes of the memlbock store the image width, the next 4 bytes store the image height, the next 4 bytes store the bit depth, currently this must be 32. After that the raw image data begins in the format RGBA, with each component stored in a single byte, so each pixel takes up 4 bytes. The size of the image data can be calculated by width*height*4 bytes (for now bit depth can be assumed to be 32 bits = 4 bytes). Note that due to little endian format writing the image data with bytes will result in offsets 0=R, 1=G, 2=B, 3=A, but writing them all as a single integer will be interpreted as a value with A as the most significant byte, followed by B, then G, then R as the least significant byte. The pixel data starts in the top left corner of the image an proceeds left to right then top to bottom resulting in the image being stored as a sequence of rows ending in the bottom right corner. This command uses a lot of GPU bandwidth so it is not recommended that this command be called every frame on large images.

## Definition

CreateImageFromMemblock( imageID, memID )

void agk::CreateImageFromMemblock( UINT imageID, UINT memID )

integer CreateImageFromMemblock( memID )

UINT agk::CreateImageFromMemblock( UINT memID )

## Parameters

- imageID - The ID of the image to create or modify.
- memID - The ID of the memblock to read, the memblock is unaffected by this command.