Image manipulation functions.
This commit is contained in:
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@@ -9,7 +9,7 @@
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/build/ReiLua",
|
||||
"args": ["/examples/heightmap/"],
|
||||
"args": ["/examples/image_draw/"],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
"environment": [],
|
||||
|
||||
316
API.md
316
API.md
@@ -2250,6 +2250,271 @@ Generate image: cellular algorithm. Bigger tileSize means bigger cells
|
||||
|
||||
---
|
||||
|
||||
## Textures - Image Manipulation Functions
|
||||
|
||||
---
|
||||
|
||||
> image = RL_ImageCopy( Image image )
|
||||
|
||||
Create an image duplicate ( useful for transformations )
|
||||
|
||||
- Failure return -1
|
||||
- Success return int
|
||||
|
||||
---
|
||||
|
||||
> image = RL_ImageFromImage( Image image, Rectangle rec )
|
||||
|
||||
Create an image from another image piece
|
||||
|
||||
- Failure return -1
|
||||
- Success return int
|
||||
|
||||
---
|
||||
|
||||
> image = RL_ImageText( Font font, string text, float fontSize, float spacing, Color tint )
|
||||
|
||||
Create an image from text ( custom sprite font )
|
||||
|
||||
- Failure return -1
|
||||
- Success return int
|
||||
|
||||
---
|
||||
|
||||
> success = RL_ImageFormat( Image image, int newFormat )
|
||||
|
||||
Convert image data to desired format
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL_ImageToPOT( Image image, Color fill )
|
||||
|
||||
Convert image to POT ( power-of-two )
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL_ImageCrop( Image image, Rectangle crop )
|
||||
|
||||
Crop an image to a defined rectangle
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL_ImageAlphaCrop( Image image, float threshold )
|
||||
|
||||
Crop image depending on alpha value
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL_ImageAlphaClear( Image image, Color color, float threshold )
|
||||
|
||||
Clear alpha channel to desired color
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL_ImageAlphaMask( Image image, Image alphaMask )
|
||||
|
||||
Apply alpha mask to image
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL_ImageAlphaPremultiply( Image image )
|
||||
|
||||
Premultiply alpha channel
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL_ImageResize( Image image, Vector2 size )
|
||||
|
||||
Resize image ( Bicubic scaling algorithm )
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL_ImageResizeNN( Image image, Vector2 size )
|
||||
|
||||
Resize image ( Nearest-Neighbor scaling algorithm )
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL_ImageResizeCanvas( Image image, Vector2 size, Vector2 offset, Color fill )
|
||||
|
||||
Resize canvas and fill with color
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL_ImageMipmaps( Image image )
|
||||
|
||||
Generate all mipmap levels for a provided image
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL_ImageDither( Image image, Color bpp )
|
||||
|
||||
Dither image data to 16bpp or lower ( Floyd-Steinberg dithering )
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL_ImageFlipVertical( Image image )
|
||||
|
||||
Flip image vertically
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL_ImageFlipHorizontal( Image image )
|
||||
|
||||
Flip image horizontally
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL_ImageRotateCW( Image image )
|
||||
|
||||
Rotate image clockwise 90deg
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL_ImageRotateCCW( Image image )
|
||||
|
||||
Rotate image counter-clockwise 90deg
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL_ImageColorTint( Image image, Color color )
|
||||
|
||||
Modify image color: tint
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL_ImageColorInvert( Image image )
|
||||
|
||||
Modify image color: invert
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL_ImageColorGrayscale( Image image )
|
||||
|
||||
Modify image color: grayscale
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL_ImageColorContrast( Image image, float contrast )
|
||||
|
||||
Modify image color: contrast ( -100 to 100 )
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL_ImageColorBrightness( Image image, int brightness )
|
||||
|
||||
Modify image color: brightness ( -255 to 255 )
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL_ImageColorReplace( Image image, Color color, Color replace )
|
||||
|
||||
Modify image color: replace color
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> colors = RL_LoadImageColors( Image image )
|
||||
|
||||
Load color data from image as a Color array ( RGBA - 32bit )
|
||||
|
||||
- Failure return false
|
||||
- Success return Color{}
|
||||
|
||||
---
|
||||
|
||||
> colors = RL_LoadImagePalette( Image image, int maxPaletteSize )
|
||||
|
||||
Load colors palette from image as a Color array ( RGBA - 32bit )
|
||||
|
||||
- Failure return false
|
||||
- Success return Color{}
|
||||
|
||||
---
|
||||
|
||||
> rectangle = RL_GetImageAlphaBorder( Image image, float threshold )
|
||||
|
||||
Get image alpha border rectangle
|
||||
|
||||
- Failure return false
|
||||
- Success return Rectangle
|
||||
|
||||
---
|
||||
|
||||
> color = RL_GetImageColor( Image image, Vector2 pixelPos )
|
||||
|
||||
Get image pixel color at ( x, y ) position
|
||||
|
||||
- Failure return false
|
||||
- Success return Color
|
||||
|
||||
---
|
||||
|
||||
## Textures - Image Drawing
|
||||
|
||||
---
|
||||
@@ -2326,6 +2591,37 @@ Draw text ( Custom sprite font ) within an image ( Destination )
|
||||
|
||||
---
|
||||
|
||||
## Textures - Image Configuration
|
||||
|
||||
---
|
||||
|
||||
> size = RL_GetImageSize( Image image )
|
||||
|
||||
Get image size
|
||||
|
||||
- Failure return nil
|
||||
- Success return Vector2
|
||||
|
||||
---
|
||||
|
||||
> mipmaps = RL_GetImageMipmaps( Image image )
|
||||
|
||||
Get image mipmaps. Mipmap levels, 1 by default
|
||||
|
||||
- Failure return false
|
||||
- Success return int
|
||||
|
||||
---
|
||||
|
||||
> format = RL_GetImageFormat( Image image )
|
||||
|
||||
Get image data format ( PixelFormat type )
|
||||
|
||||
- Failure return false
|
||||
- Success return int
|
||||
|
||||
---
|
||||
|
||||
## Textures - Texture Drawing
|
||||
|
||||
---
|
||||
@@ -2416,7 +2712,7 @@ Get current texture source type ( TEXTURE_SOURCE_TEXTURE or TEXTURE_SOURCE_RENDE
|
||||
|
||||
---
|
||||
|
||||
## Textures - Configure
|
||||
## Textures - Texture Configuration
|
||||
|
||||
---
|
||||
|
||||
@@ -2456,6 +2752,24 @@ Get texture size
|
||||
|
||||
---
|
||||
|
||||
> mipmaps = RL_GetTextureMipmaps( Texture2D texture )
|
||||
|
||||
Get texture mipmaps. Mipmap levels, 1 by default
|
||||
|
||||
- Failure return false
|
||||
- Success return int
|
||||
|
||||
---
|
||||
|
||||
> format = RL_GetTextureFormat( Texture2D texture )
|
||||
|
||||
Get texture mipmaps. Mipmap levels, 1 by default
|
||||
|
||||
- Failure return false
|
||||
- Success return int
|
||||
|
||||
---
|
||||
|
||||
## Textures - Color/pixel
|
||||
|
||||
---
|
||||
|
||||
@@ -7,8 +7,10 @@ project( ReiLua )
|
||||
set( CMAKE_C_STANDARD 99 ) # Requires C99 standard
|
||||
|
||||
if( DEBUG )
|
||||
message( Debug )
|
||||
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -ggdb -std=c99 -Wall -pedantic -fno-common" )
|
||||
else()
|
||||
message( Release )
|
||||
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -std=c99 -Wall -pedantic -fno-common" )
|
||||
endif()
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ List of some MISSING features that are planned to be included. For specific func
|
||||
* Files drop
|
||||
* VR stereo config functions for VR simulator
|
||||
* Textures
|
||||
* Image manipulation functions
|
||||
* Texture update functions
|
||||
* Text
|
||||
* Some font loading/unloading functions
|
||||
|
||||
@@ -2,6 +2,8 @@ local monitor = 0
|
||||
local texture = -1
|
||||
local image = -1
|
||||
local catImage = -1
|
||||
local catCopy = -1
|
||||
local textImage = -1
|
||||
|
||||
function init()
|
||||
local mPos = RL_GetMonitorPosition( monitor )
|
||||
@@ -21,6 +23,17 @@ function init()
|
||||
RL_ImageDraw( image, catImage, { 143, 25, 230, 250 }, { 200, 200, 230, 250 }, WHITE )
|
||||
RL_ImageDrawTextEx( image, 0, "Hello", { 300, 32 }, 48.0, 1.0, WHITE )
|
||||
|
||||
-- catCopy = RL_ImageCopy( catImage )
|
||||
local src = { 80, 70, 96, 96 }
|
||||
catCopy = RL_ImageFromImage( catImage, src )
|
||||
|
||||
RL_ImageDraw( image, catCopy, src, { 600, 200, src[3], src[4] }, WHITE )
|
||||
-- RL_ImageDraw( image, catCopy, src, src, WHITE )
|
||||
|
||||
textImage = RL_ImageText( 0, "Cat", 10, 4, WHITE )
|
||||
local imageSize = RL_GetImageSize( textImage )
|
||||
RL_ImageDraw( image, textImage, { 0, 0, imageSize[1], imageSize[2] }, { 250, 40, imageSize[1], imageSize[2] }, WHITE )
|
||||
|
||||
texture = RL_LoadTextureFromImage( image )
|
||||
end
|
||||
|
||||
|
||||
@@ -28,6 +28,36 @@ int ltexturesGenImageGradientRadial( lua_State *L );
|
||||
int ltexturesGenImageChecked( lua_State *L );
|
||||
int ltexturesGenImageWhiteNoise( lua_State *L );
|
||||
int ltexturesGenImageCellular( lua_State *L );
|
||||
/* Image Manipulation Functions. */
|
||||
int ltexturesImageCopy( lua_State *L );
|
||||
int ltexturesImageFromImage( lua_State *L );
|
||||
int ltexturesImageText( lua_State *L );
|
||||
int ltexturesImageFormat( lua_State *L );
|
||||
int ltexturesImageToPOT( lua_State *L );
|
||||
int ltexturesImageCrop( lua_State *L );
|
||||
int ltexturesImageAlphaCrop( lua_State *L );
|
||||
int ltexturesImageAlphaClear( lua_State *L );
|
||||
int ltexturesImageAlphaMask( lua_State *L );
|
||||
int ltexturesImageAlphaPremultiply( lua_State *L );
|
||||
int ltexturesImageResize( lua_State *L );
|
||||
int ltexturesImageResizeNN( lua_State *L );
|
||||
int ltexturesImageResizeCanvas( lua_State *L );
|
||||
int ltexturesImageMipmaps( lua_State *L );
|
||||
int ltexturesImageDither( lua_State *L );
|
||||
int ltexturesImageFlipVertical( lua_State *L );
|
||||
int ltexturesImageFlipHorizontal( lua_State *L );
|
||||
int ltexturesImageRotateCW( lua_State *L );
|
||||
int ltexturesImageRotateCCW( lua_State *L );
|
||||
int ltexturesImageColorTint( lua_State *L );
|
||||
int ltexturesImageColorInvert( lua_State *L );
|
||||
int ltexturesImageColorGrayscale( lua_State *L );
|
||||
int ltexturesImageColorContrast( lua_State *L );
|
||||
int ltexturesImageColorBrightness( lua_State *L );
|
||||
int ltexturesImageColorReplace( lua_State *L );
|
||||
int ltexturesLoadImageColors( lua_State *L );
|
||||
int ltexturesLoadImagePalette( lua_State *L );
|
||||
int ltexturesGetImageAlphaBorder( lua_State *L );
|
||||
int ltexturesGetImageColor( lua_State *L );
|
||||
/* Image Drawing. */
|
||||
int ltexturesImageClearBackground( lua_State *L );
|
||||
int ltexturesImageDrawPixel( lua_State *L );
|
||||
@@ -37,6 +67,10 @@ int ltexturesImageDrawRectangle( lua_State *L );
|
||||
int ltexturesImageDrawRectangleLines( lua_State *L );
|
||||
int ltexturesImageDraw( lua_State *L );
|
||||
int ltexturesImageDrawTextEx( lua_State *L );
|
||||
/* Image Configuration. */
|
||||
int ltexturesGetImageSize( lua_State *L );
|
||||
int ltexturesGetImageMipmaps( lua_State *L );
|
||||
int ltexturesGetImageFormat( lua_State *L );
|
||||
/* Texture Drawing. */
|
||||
int ltexturesDrawTexture( lua_State *L );
|
||||
int ltexturesDrawTextureRec( lua_State *L );
|
||||
@@ -48,11 +82,13 @@ int ltexturesBeginTextureMode( lua_State *L );
|
||||
int ltexturesEndTextureMode( lua_State *L );
|
||||
int ltexturesSetTextureSource( lua_State *L );
|
||||
int ltexturesGetTextureSource( lua_State *L );
|
||||
/* Conf. */
|
||||
/* Texture Configuration. */
|
||||
int ltexturesGenTextureMipmaps( lua_State *L );
|
||||
int ltexturesSetTextureFilter( lua_State *L );
|
||||
int ltexturesSetTextureWrap( lua_State *L );
|
||||
int ltexturesGetTextureSize( lua_State *L );
|
||||
int ltexturesGetTextureMipmaps( lua_State *L );
|
||||
int ltexturesGetTextureFormat( lua_State *L );
|
||||
/* Color/pixel */
|
||||
int ltexturesFade( lua_State *L );
|
||||
int ltexturesColorToInt( lua_State *L );
|
||||
|
||||
@@ -666,6 +666,36 @@ void luaRegister() {
|
||||
lua_register( L, "RL_GenImageChecked", ltexturesGenImageChecked );
|
||||
lua_register( L, "RL_GenImageWhiteNoise", ltexturesGenImageWhiteNoise );
|
||||
lua_register( L, "RL_GenImageCellular", ltexturesGenImageCellular );
|
||||
/* Image Manipulation Functions. */
|
||||
lua_register( L, "RL_ImageCopy", ltexturesImageCopy );
|
||||
lua_register( L, "RL_ImageFromImage", ltexturesImageFromImage );
|
||||
lua_register( L, "RL_ImageText", ltexturesImageText );
|
||||
lua_register( L, "RL_ImageFormat", ltexturesImageFormat );
|
||||
lua_register( L, "RL_ImageToPOT", ltexturesImageToPOT );
|
||||
lua_register( L, "RL_ImageCrop", ltexturesImageCrop );
|
||||
lua_register( L, "RL_ImageAlphaCrop", ltexturesImageAlphaCrop );
|
||||
lua_register( L, "RL_ImageAlphaClear", ltexturesImageAlphaClear );
|
||||
lua_register( L, "RL_ImageAlphaMask", ltexturesImageAlphaMask );
|
||||
lua_register( L, "RL_ImageAlphaPremultiply", ltexturesImageAlphaPremultiply );
|
||||
lua_register( L, "RL_ImageResize", ltexturesImageResize );
|
||||
lua_register( L, "RL_ImageResizeNN", ltexturesImageResizeNN );
|
||||
lua_register( L, "RL_ImageResizeCanvas", ltexturesImageResizeCanvas );
|
||||
lua_register( L, "RL_ImageMipmaps", ltexturesImageMipmaps );
|
||||
lua_register( L, "RL_ImageDither", ltexturesImageDither );
|
||||
lua_register( L, "RL_ImageFlipVertical", ltexturesImageFlipVertical );
|
||||
lua_register( L, "RL_ImageFlipHorizontal", ltexturesImageFlipHorizontal );
|
||||
lua_register( L, "RL_ImageRotateCW", ltexturesImageRotateCW );
|
||||
lua_register( L, "RL_ImageRotateCCW", ltexturesImageRotateCCW );
|
||||
lua_register( L, "RL_ImageColorTint", ltexturesImageColorTint );
|
||||
lua_register( L, "RL_ImageColorInvert", ltexturesImageColorInvert );
|
||||
lua_register( L, "RL_ImageColorGrayscale", ltexturesImageColorGrayscale );
|
||||
lua_register( L, "RL_ImageColorContrast", ltexturesImageColorContrast );
|
||||
lua_register( L, "RL_ImageColorBrightness", ltexturesImageColorBrightness );
|
||||
lua_register( L, "RL_ImageColorReplace", ltexturesImageColorReplace );
|
||||
lua_register( L, "RL_LoadImageColors", ltexturesLoadImageColors );
|
||||
lua_register( L, "RL_LoadImagePalette", ltexturesLoadImagePalette );
|
||||
lua_register( L, "RL_GetImageAlphaBorder", ltexturesGetImageAlphaBorder );
|
||||
lua_register( L, "RL_GetImageColor", ltexturesGetImageColor );
|
||||
/* Image Drawing. */
|
||||
lua_register( L, "RL_ImageClearBackground", ltexturesImageClearBackground );
|
||||
lua_register( L, "RL_ImageDrawPixel", ltexturesImageDrawPixel );
|
||||
@@ -675,6 +705,10 @@ void luaRegister() {
|
||||
lua_register( L, "RL_ImageDrawRectangleLines", ltexturesImageDrawRectangleLines );
|
||||
lua_register( L, "RL_ImageDraw", ltexturesImageDraw );
|
||||
lua_register( L, "RL_ImageDrawTextEx", ltexturesImageDrawTextEx );
|
||||
/* Image Configuration. */
|
||||
lua_register( L, "RL_GetImageSize", ltexturesGetImageSize );
|
||||
lua_register( L, "RL_GetImageMipmaps", ltexturesGetImageMipmaps );
|
||||
lua_register( L, "RL_GetImageFormat", ltexturesGetImageFormat );
|
||||
/* Texture Drawing. */
|
||||
lua_register( L, "RL_DrawTexture", ltexturesDrawTexture );
|
||||
lua_register( L, "RL_DrawTextureRec", ltexturesDrawTextureRec );
|
||||
@@ -686,11 +720,13 @@ void luaRegister() {
|
||||
lua_register( L, "RL_EndTextureMode", ltexturesEndTextureMode );
|
||||
lua_register( L, "RL_SetTextureSource", ltexturesSetTextureSource );
|
||||
lua_register( L, "RL_GetTextureSource", ltexturesGetTextureSource );
|
||||
/* Conf. */
|
||||
/* Texture Configuration. */
|
||||
lua_register( L, "RL_GenTextureMipmaps", ltexturesGenTextureMipmaps );
|
||||
lua_register( L, "RL_SetTextureFilter", ltexturesSetTextureFilter );
|
||||
lua_register( L, "RL_SetTextureWrap", ltexturesSetTextureWrap );
|
||||
lua_register( L, "RL_GetTextureSize", ltexturesGetTextureSize );
|
||||
lua_register( L, "RL_GetTextureMipmaps", ltexturesGetTextureMipmaps );
|
||||
lua_register( L, "RL_GetTextureFormat", ltexturesGetTextureFormat );
|
||||
/* Color/pixel */
|
||||
lua_register( L, "RL_Fade", ltexturesFade );
|
||||
lua_register( L, "RL_ColorToInt", ltexturesColorToInt );
|
||||
|
||||
1131
src/textures.c
1131
src/textures.c
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user