SetImageData.

This commit is contained in:
jussi
2025-05-02 16:09:33 +03:00
parent 3471e4514f
commit 6a4f8ab4a3
7 changed files with 54 additions and 20 deletions

View File

@@ -1916,6 +1916,7 @@ void luaRegister() {
assingGlobalFunction( "GetImageAlphaBorder", ltexturesGetImageAlphaBorder );
assingGlobalFunction( "GetImageColor", ltexturesGetImageColor );
/* Image configuration functions. */
assingGlobalFunction( "SetImageData", ltexturesSetImageData );
assingGlobalFunction( "GetImageData", ltexturesGetImageData );
assingGlobalFunction( "GetImageSize", ltexturesGetImageSize );
assingGlobalFunction( "GetImageMipmaps", ltexturesGetImageMipmaps );

View File

@@ -3,6 +3,7 @@
#include "textures.h"
#include "text.h"
#include "lua_core.h"
#include "rmath.h"
/*
## Textures - Image loading functions
@@ -930,6 +931,23 @@ int ltexturesGetImageColor( lua_State* L ) {
## Textures - Image configuration functions
*/
/*
> RL.SetImageData( Image image, Buffer data )
Set image data from Buffer
*/
int ltexturesSetImageData( lua_State* L ) {
Image* image = uluaGetImage( L, 1 );
Buffer* data = uluaGetBuffer( L, 2 );
memcpy( image->data, data->data, imin(
GetPixelDataSize( image->width, image->height, image->format ),
data->size
) );
return 0;
}
/*
> imageData = RL.GetImageData( Image image )
@@ -1127,7 +1145,7 @@ int ltexturesImageDrawRectangleLines( lua_State* L ) {
}
/*
> RL.ImageDrawTriangle( Image *dst, Vector2 v1, Vector2 v2, Vector2 v3, Color color )
> RL.ImageDrawTriangle( Image dst, Vector2 v1, Vector2 v2, Vector2 v3, Color color )
Draw triangle within an image
*/
@@ -1144,7 +1162,7 @@ int ltexturesImageDrawTriangle( lua_State* L ) {
}
/*
> RL.ImageDrawTriangleEx( Image *dst, Vector2 v1, Vector2 v2, Vector2 v3, Color c1, Color c2, Color c3 )
> RL.ImageDrawTriangleEx( Image dst, Vector2 v1, Vector2 v2, Vector2 v3, Color c1, Color c2, Color c3 )
Draw triangle with interpolated colors within an image
*/
@@ -1163,7 +1181,7 @@ int ltexturesImageDrawTriangleEx( lua_State* L ) {
}
/*
> RL.ImageDrawTriangleLines( Image *dst, Vector2 v1, Vector2 v2, Vector2 v3, Color color )
> RL.ImageDrawTriangleLines( Image dst, Vector2 v1, Vector2 v2, Vector2 v3, Color color )
Draw triangle outline within an image
*/
@@ -1180,7 +1198,7 @@ int ltexturesImageDrawTriangleLines( lua_State* L ) {
}
/*
> RL.ImageDrawTriangleFan( Image *dst, Vector2{} points, Color color )
> RL.ImageDrawTriangleFan( Image dst, Vector2{} points, Color color )
Draw a triangle fan defined by points within an image (first vertex is the center)
*/
@@ -1197,7 +1215,7 @@ int ltexturesImageDrawTriangleFan( lua_State* L ) {
}
/*
> RL.ImageDrawTriangleStrip( Image *dst, Vector2{} points, Color color )
> RL.ImageDrawTriangleStrip( Image dst, Vector2{} points, Color color )
Draw a triangle strip defined by points within an image
*/