From 5aa50db3e7710659250b66a6b3eda54a29f21224 Mon Sep 17 00:00:00 2001 From: Christian C Date: Sun, 2 Mar 2025 19:09:22 -0800 Subject: Drawing image with Raylib --- src/main.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 221deb1..02697aa 100644 --- a/src/main.c +++ b/src/main.c @@ -37,6 +37,19 @@ int main() return 1; } + Image RaylibImage; + RaylibImage.data = raster; + RaylibImage.format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8; + RaylibImage.width = width; + RaylibImage.height = height; + RaylibImage.mipmaps = 1; + Texture2D RaylibTexture = LoadTextureFromImage(RaylibImage); + + Rectangle sourceRec = { 0.0f, 0.0f, (float)width, (float)height }; + Rectangle destRec = { 0.0f, 0.0f, (float)80, (float)80 }; + + Vector2 origin = { (float)0, (float)-10 }; + SetTargetFPS(60); Camera2D camera = { 0 }; camera.zoom = 1.0f; @@ -49,7 +62,8 @@ int main() ClearBackground(RAYWHITE); BeginMode2D(camera); EndMode2D(); - DrawText("Image Manip", 0, 0, 0, DARKGRAY); + DrawText("Image Manip", 0, 0, 10, DARKGRAY); + DrawTexturePro(RaylibTexture, sourceRec, destRec, origin, (float)0, RAYWHITE); EndDrawing(); //----------------------------------------------- } -- cgit v1.2.1