LoadImageFromData.
This commit is contained in:
8
API.md
8
API.md
@@ -5547,6 +5547,14 @@ Load image from memory buffer, fileType refers to extension: i.e. '.png'
|
||||
|
||||
---
|
||||
|
||||
> image, frameCount = RL.LoadImageFromData( Buffer data, Vector2 size, int mipmaps, int format )
|
||||
|
||||
Load image from data
|
||||
|
||||
- Success return Image
|
||||
|
||||
---
|
||||
|
||||
> image = RL.LoadImageFromTexture( Texture texture )
|
||||
|
||||
Load image from GPU texture data
|
||||
|
||||
@@ -2964,6 +2964,16 @@ function RL.LoadImageAnim( fileName ) end
|
||||
---@return any frameCount
|
||||
function RL.LoadImageFromMemory( fileType, data ) end
|
||||
|
||||
---Load image from data
|
||||
---- Success return Image
|
||||
---@param data any
|
||||
---@param size table
|
||||
---@param mipmaps integer
|
||||
---@param format integer
|
||||
---@return any image
|
||||
---@return any frameCount
|
||||
function RL.LoadImageFromData( data, size, mipmaps, format ) end
|
||||
|
||||
---Load image from GPU texture data
|
||||
---- Success return Image
|
||||
---@param texture any
|
||||
|
||||
@@ -3,6 +3,7 @@ Release: ReiLua version 0.8.0 Using Raylib 5.0 and Forked Raygui 4.0
|
||||
------------------------------------------------------------------------
|
||||
KEY CHANGES:
|
||||
- CHANGE: GetBufferData takes also position and length arguments.
|
||||
- ADDED: LoadImageFromData.
|
||||
|
||||
DETAILED CHANGES:
|
||||
- ADDED: GetBufferElementSize and GetBufferLength.
|
||||
|
||||
@@ -6,6 +6,7 @@ int ltexturesLoadImageRaw( lua_State *L );
|
||||
int ltexturesLoadImageSvg( lua_State *L );
|
||||
int ltexturesLoadImageAnim( lua_State *L );
|
||||
int ltexturesLoadImageFromMemory( lua_State *L );
|
||||
int ltexturesLoadImageFromData( lua_State *L );
|
||||
int ltexturesLoadImageFromTexture( lua_State *L );
|
||||
int ltexturesLoadImageFromScreen( lua_State *L );
|
||||
int ltextureIsImageReady( lua_State *L );
|
||||
|
||||
@@ -1491,6 +1491,7 @@ void luaRegister() {
|
||||
assingGlobalFunction( "LoadImageSvg", ltexturesLoadImageSvg );
|
||||
assingGlobalFunction( "LoadImageAnim", ltexturesLoadImageAnim );
|
||||
assingGlobalFunction( "LoadImageFromMemory", ltexturesLoadImageFromMemory );
|
||||
assingGlobalFunction( "LoadImageFromData", ltexturesLoadImageFromData );
|
||||
assingGlobalFunction( "LoadImageFromTexture", ltexturesLoadImageFromTexture );
|
||||
assingGlobalFunction( "LoadImageFromScreen", ltexturesLoadImageFromScreen );
|
||||
assingGlobalFunction( "IsImageReady", ltextureIsImageReady );
|
||||
|
||||
@@ -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 )
|
||||
|
||||
|
||||
Reference in New Issue
Block a user