LoadImageFromData.

This commit is contained in:
jussi
2024-02-17 00:49:57 +02:00
parent b2b8219295
commit 9de10be468
7 changed files with 51 additions and 2 deletions

View File

@@ -109,6 +109,34 @@ int ltexturesLoadImageFromMemory( lua_State *L ) {
return 1;
}
/*
> image, frameCount = RL.LoadImageFromData( Buffer data, Vector2 size, int mipmaps, int format )
Load image from data
- Success return Image
*/
int ltexturesLoadImageFromData( lua_State *L ) {
Buffer *data = uluaGetBuffer( L, 1 );
Vector2 size = uluaGetVector2( L, 2 );
int mipmaps = luaL_checkinteger( L, 3 );
int format = luaL_checkinteger( L, 4 );
Image image = {
.width = size.x,
.height = size.y,
.mipmaps = mipmaps,
.format = format
};
size_t dataSize = GetPixelDataSize( size.x, size.y, format );
image.data = malloc( dataSize * sizeof( unsigned char ) );
memcpy( image.data, data->data, dataSize );
uluaPushImage( L, image );
return 1;
}
/*
> image = RL.LoadImageFromTexture( Texture texture )