Image export functions.
This commit is contained in:
20
API.md
20
API.md
@@ -641,7 +641,7 @@ Set title for window ( Only PLATFORM_DESKTOP )
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
> RL_lcoreCloseWindow()
|
> RL_CloseWindow()
|
||||||
|
|
||||||
Close window and unload OpenGL context and free all resources
|
Close window and unload OpenGL context and free all resources
|
||||||
|
|
||||||
@@ -1614,6 +1614,24 @@ Unload image from CPU memory ( RAM )
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
> success = RL_ExportImage( Image image, string fileName )
|
||||||
|
|
||||||
|
Export image data to file, returns true on success
|
||||||
|
|
||||||
|
- Failure return nil
|
||||||
|
- Success return bool
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> success = RL_ExportImageAsCode( Image image, string fileName )
|
||||||
|
|
||||||
|
Export image as code file defining an array of bytes, returns true on success
|
||||||
|
|
||||||
|
- Failure return nil
|
||||||
|
- Success return bool
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
> texture = RL_LoadTexture( string fileName )
|
> texture = RL_LoadTexture( string fileName )
|
||||||
|
|
||||||
Load texture from file into GPU memory ( VRAM )
|
Load texture from file into GPU memory ( VRAM )
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ Texture2D* texturesGetSourceTexture( size_t index );
|
|||||||
int ltexturesLoadImage( lua_State *L );
|
int ltexturesLoadImage( lua_State *L );
|
||||||
int ltexturesGenImageColor( lua_State *L );
|
int ltexturesGenImageColor( lua_State *L );
|
||||||
int ltexturesUnloadImage( lua_State *L );
|
int ltexturesUnloadImage( lua_State *L );
|
||||||
|
int ltexturesExportImage( lua_State *L );
|
||||||
|
int ltexturesExportImageAsCode( lua_State *L );
|
||||||
int ltexturesLoadTexture( lua_State *L );
|
int ltexturesLoadTexture( lua_State *L );
|
||||||
int ltexturesLoadTextureFromImage( lua_State *L );
|
int ltexturesLoadTextureFromImage( lua_State *L );
|
||||||
int ltexturesUnloadTexture( lua_State *L );
|
int ltexturesUnloadTexture( lua_State *L );
|
||||||
|
|||||||
@@ -302,7 +302,7 @@ int lcoreSetWindowTitle( lua_State *L ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
> RL_lcoreCloseWindow()
|
> RL_CloseWindow()
|
||||||
|
|
||||||
Close window and unload OpenGL context and free all resources
|
Close window and unload OpenGL context and free all resources
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -521,6 +521,8 @@ void luaRegister() {
|
|||||||
lua_register( L, "RL_LoadImage", ltexturesLoadImage );
|
lua_register( L, "RL_LoadImage", ltexturesLoadImage );
|
||||||
lua_register( L, "RL_GenImageColor", ltexturesGenImageColor );
|
lua_register( L, "RL_GenImageColor", ltexturesGenImageColor );
|
||||||
lua_register( L, "RL_UnloadImage", ltexturesUnloadImage );
|
lua_register( L, "RL_UnloadImage", ltexturesUnloadImage );
|
||||||
|
lua_register( L, "RL_ExportImage", ltexturesExportImage );
|
||||||
|
lua_register( L, "RL_ExportImageAsCode", ltexturesExportImageAsCode );
|
||||||
lua_register( L, "RL_LoadTexture", ltexturesLoadTexture );
|
lua_register( L, "RL_LoadTexture", ltexturesLoadTexture );
|
||||||
lua_register( L, "RL_LoadTextureFromImage", ltexturesLoadTextureFromImage );
|
lua_register( L, "RL_LoadTextureFromImage", ltexturesLoadTextureFromImage );
|
||||||
lua_register( L, "RL_UnloadTexture", ltexturesUnloadTexture );
|
lua_register( L, "RL_UnloadTexture", ltexturesUnloadTexture );
|
||||||
|
|||||||
@@ -203,6 +203,56 @@ int ltexturesUnloadImage( lua_State *L ) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> success = RL_ExportImage( Image image, string fileName )
|
||||||
|
|
||||||
|
Export image data to file, returns true on success
|
||||||
|
|
||||||
|
- Failure return nil
|
||||||
|
- Success return bool
|
||||||
|
*/
|
||||||
|
int ltexturesExportImage( lua_State *L ) {
|
||||||
|
if ( !lua_isnumber( L, -2 ) || !lua_isstring( L, -1 ) ) {
|
||||||
|
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_ExportImage( Image image, string fileName )" );
|
||||||
|
lua_pushnil( L );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
size_t id = lua_tointeger( L, -2 );
|
||||||
|
|
||||||
|
if ( !validImage( id ) ) {
|
||||||
|
lua_pushnil( L );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
lua_pushboolean( L, ExportImage( *state->images[ id ], lua_tostring( L, -1 ) ) );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> success = RL_ExportImageAsCode( Image image, string fileName )
|
||||||
|
|
||||||
|
Export image as code file defining an array of bytes, returns true on success
|
||||||
|
|
||||||
|
- Failure return nil
|
||||||
|
- Success return bool
|
||||||
|
*/
|
||||||
|
int ltexturesExportImageAsCode( lua_State *L ) {
|
||||||
|
if ( !lua_isnumber( L, -2 ) || !lua_isstring( L, -1 ) ) {
|
||||||
|
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_ExportImageAsCode( Image image, string fileName )" );
|
||||||
|
lua_pushnil( L );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
size_t id = lua_tointeger( L, -2 );
|
||||||
|
|
||||||
|
if ( !validImage( id ) ) {
|
||||||
|
lua_pushnil( L );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
lua_pushboolean( L, ExportImageAsCode( *state->images[ id ], lua_tostring( L, -1 ) ) );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
> texture = RL_LoadTexture( string fileName )
|
> texture = RL_LoadTexture( string fileName )
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user