summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lua_core.c3
-rw-r--r--src/textures.c66
2 files changed, 69 insertions, 0 deletions
diff --git a/src/lua_core.c b/src/lua_core.c
index 2389463..fe9d8c7 100644
--- a/src/lua_core.c
+++ b/src/lua_core.c
@@ -1774,6 +1774,9 @@ void luaRegister() {
/* Textures. */
/* Image loading functions. */
assingGlobalFunction( "LoadImage", ltexturesLoadImage );
+ assingGlobalFunction( "LoadImageRaw", ltexturesLoadImageRaw );
+ assingGlobalFunction( "LoadImageAnim", ltexturesLoadImageAnim );
+ assingGlobalFunction( "LoadImageFromMemory", ltexturesLoadImageFromMemory );
assingGlobalFunction( "LoadImageFromTexture", ltexturesLoadImageFromTexture );
assingGlobalFunction( "LoadImageFromScreen", ltexturesLoadImageFromScreen );
assingGlobalFunction( "IsImageReady", ltextureIsImageReady );
diff --git a/src/textures.c b/src/textures.c
index c5b07e4..008aa14 100644
--- a/src/textures.c
+++ b/src/textures.c
@@ -13,6 +13,7 @@
Load image from file into CPU memory (RAM)
+- Failure return nil
- Success return Image
*/
int ltexturesLoadImage( lua_State *L ) {
@@ -28,6 +29,71 @@ int ltexturesLoadImage( lua_State *L ) {
}
/*
+> image = RL.LoadImageRaw( string fileName, Vector2 size, int format, int headerSize )
+
+Load image from RAW file data
+
+- Failure return nil
+- Success return Image
+*/
+int ltexturesLoadImageRaw( lua_State *L ) {
+ const char *fileName = luaL_checkstring( L, 1 );
+ Vector2 size = uluaGetVector2( L, 2 );
+ int format = luaL_checkinteger( L, 3 );
+ int headerSize = luaL_checkinteger( L, 4 );
+
+ if ( FileExists( fileName ) ) {
+ uluaPushImage( L, LoadImageRaw( fileName, (int)size.x, (int)size.y, format, headerSize ) );
+
+ return 1;
+ }
+ TraceLog( state->logLevelInvalid, "Invalid file '%s'", fileName );
+ lua_pushnil( L );
+
+ return 1;
+}
+
+/*
+> image, frameCount = RL.LoadImageAnim( string fileName )
+
+Load image sequence from file (frames appended to image.data). All frames are returned in RGBA format
+
+- Failure return nil
+- Success return Image, int
+*/
+int ltexturesLoadImageAnim( lua_State *L ) {
+ const char *fileName = luaL_checkstring( L, 1 );
+
+ if ( FileExists( fileName ) ) {
+ int frameCount = 0;
+ uluaPushImage( L, LoadImageAnim( fileName, &frameCount ) );
+ lua_pushinteger( L, frameCount );
+
+ return 2;
+ }
+ TraceLog( state->logLevelInvalid, "Invalid file '%s'", fileName );
+ lua_pushnil( L );
+
+ return 1;
+}
+
+/*
+> image, frameCount = RL.LoadImageFromMemory( string fileType, Buffer data )
+
+Load image from memory buffer, fileType refers to extension: i.e. '.png'
+
+- Success return Image
+*/
+int ltexturesLoadImageFromMemory( lua_State *L ) {
+ const char *fileType = luaL_checkstring( L, 1 );
+ Buffer *data = uluaGetBuffer( L, 2 );
+
+ uluaPushImage( L, LoadImageFromMemory( fileType, data->data, data->size ) );
+
+ return 1;
+}
+
+/*
> image = RL.LoadImageFromTexture( Texture texture )
Load image from GPU texture data