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

16
API.md
View File

@@ -7398,6 +7398,12 @@ Get image pixel color at (x, y) position
--- ---
> RL.SetImageData( Image image, Buffer data )
Set image data from Buffer
---
> imageData = RL.GetImageData( Image image ) > imageData = RL.GetImageData( Image image )
Get image data as Buffer Get image data as Buffer
@@ -7482,31 +7488,31 @@ Draw rectangle lines within an image
--- ---
> 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 Draw triangle within an image
--- ---
> 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 Draw triangle with interpolated colors within an image
--- ---
> 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 Draw triangle outline within an image
--- ---
> 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) Draw a triangle fan defined by points within an image (first vertex is the center)
--- ---
> 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 Draw a triangle strip defined by points within an image

View File

@@ -3914,6 +3914,12 @@ function RL.GetImageColor( image, pixelPos ) end
-- Textures - Image configuration functions -- Textures - Image configuration functions
---Set image data from Buffer
---@param image any
---@param data any
---@return any RL.SetImageData
function RL.SetImageData( image, data ) end
---Get image data as Buffer ---Get image data as Buffer
---- Success return Buffer ---- Success return Buffer
---@param image any ---@param image any
@@ -4002,16 +4008,16 @@ function RL.ImageDrawRectangle( dst, rec, color ) end
function RL.ImageDrawRectangleLines( dst, rec, thick, color ) end function RL.ImageDrawRectangleLines( dst, rec, thick, color ) end
---Draw triangle within an image ---Draw triangle within an image
---@param *dst any ---@param dst any
---@param v1 table ---@param v1 table
---@param v2 table ---@param v2 table
---@param v3 table ---@param v3 table
---@param color table ---@param color table
---@return any RL.ImageDrawTriangle ---@return any RL.ImageDrawTriangle
function RL.ImageDrawTriangle( *dst, v1, v2, v3, color ) end function RL.ImageDrawTriangle( dst, v1, v2, v3, color ) end
---Draw triangle with interpolated colors within an image ---Draw triangle with interpolated colors within an image
---@param *dst any ---@param dst any
---@param v1 table ---@param v1 table
---@param v2 table ---@param v2 table
---@param v3 table ---@param v3 table
@@ -4019,30 +4025,30 @@ function RL.ImageDrawTriangle( *dst, v1, v2, v3, color ) end
---@param c2 table ---@param c2 table
---@param c3 table ---@param c3 table
---@return any RL.ImageDrawTriangleEx ---@return any RL.ImageDrawTriangleEx
function RL.ImageDrawTriangleEx( *dst, v1, v2, v3, c1, c2, c3 ) end function RL.ImageDrawTriangleEx( dst, v1, v2, v3, c1, c2, c3 ) end
---Draw triangle outline within an image ---Draw triangle outline within an image
---@param *dst any ---@param dst any
---@param v1 table ---@param v1 table
---@param v2 table ---@param v2 table
---@param v3 table ---@param v3 table
---@param color table ---@param color table
---@return any RL.ImageDrawTriangleLines ---@return any RL.ImageDrawTriangleLines
function RL.ImageDrawTriangleLines( *dst, v1, v2, v3, color ) end function RL.ImageDrawTriangleLines( dst, v1, v2, v3, color ) end
---Draw a triangle fan defined by points within an image (first vertex is the center) ---Draw a triangle fan defined by points within an image (first vertex is the center)
---@param *dst any ---@param dst any
---@param points table ---@param points table
---@param color table ---@param color table
---@return any RL.ImageDrawTriangleFan ---@return any RL.ImageDrawTriangleFan
function RL.ImageDrawTriangleFan( *dst, points, color ) end function RL.ImageDrawTriangleFan( dst, points, color ) end
---Draw a triangle strip defined by points within an image ---Draw a triangle strip defined by points within an image
---@param *dst any ---@param dst any
---@param points table ---@param points table
---@param color table ---@param color table
---@return any RL.ImageDrawTriangleStrip ---@return any RL.ImageDrawTriangleStrip
function RL.ImageDrawTriangleStrip( *dst, points, color ) end function RL.ImageDrawTriangleStrip( dst, points, color ) end
---Draw a source image within a destination image (Tint applied to source) ---Draw a source image within a destination image (Tint applied to source)
---@param dst any ---@param dst any

View File

@@ -45,6 +45,7 @@ DETAILED CHANGES:
- ADDED: SDL3 Events. - ADDED: SDL3 Events.
- ADDED: Fast tilemap example. - ADDED: Fast tilemap example.
- ADDED: RectPack using stbrp_pack_rects. Atlas packer tutorial. - ADDED: RectPack using stbrp_pack_rects. Atlas packer tutorial.
- ADDED: SetImageData.
------------------------------------------------------------------------ ------------------------------------------------------------------------
Release: ReiLua version 0.8.0 Using Raylib 5.0 and Forked Raygui 4.0 Release: ReiLua version 0.8.0 Using Raylib 5.0 and Forked Raygui 4.0

View File

@@ -1,4 +1,5 @@
Current { Current {
* Check if DrawTextBoxedEx works correctly.
} }
Backlog { Backlog {

View File

@@ -60,6 +60,7 @@ int ltexturesLoadImagePalette( lua_State* L );
int ltexturesGetImageAlphaBorder( lua_State* L ); int ltexturesGetImageAlphaBorder( lua_State* L );
int ltexturesGetImageColor( lua_State* L ); int ltexturesGetImageColor( lua_State* L );
/* Image configuration functions. */ /* Image configuration functions. */
int ltexturesSetImageData( lua_State* L );
int ltexturesGetImageData( lua_State* L ); int ltexturesGetImageData( lua_State* L );
int ltexturesGetImageSize( lua_State* L ); int ltexturesGetImageSize( lua_State* L );
int ltexturesGetImageMipmaps( lua_State* L ); int ltexturesGetImageMipmaps( lua_State* L );

View File

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

View File

@@ -3,6 +3,7 @@
#include "textures.h" #include "textures.h"
#include "text.h" #include "text.h"
#include "lua_core.h" #include "lua_core.h"
#include "rmath.h"
/* /*
## Textures - Image loading functions ## Textures - Image loading functions
@@ -930,6 +931,23 @@ int ltexturesGetImageColor( lua_State* L ) {
## Textures - Image configuration functions ## 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 ) > 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 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 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 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) 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 Draw a triangle strip defined by points within an image
*/ */