[rcore] add 'GetClipboardImage' for windows

This commit is contained in:
evertonse 2024-11-01 16:20:44 -03:00
commit 7880670597
2 changed files with 539 additions and 1 deletions

View file

@ -516,7 +516,8 @@ CORE = \
core/core_window_flags \
core/core_window_letterbox \
core/core_window_should_close \
core/core_world_screen
core/core_world_screen \
core/core_clipboard_image
SHAPES = \
shapes/shapes_basic_shapes \

View file

@ -0,0 +1,34 @@
#include "raylib.h"
#include <stdio.h>
#include <stdlib.h>
static Image img = {0};
int main(int argc, char *argv[]) {
InitWindow(800, 450, "[core] raylib clipboard image");
SetTraceLogLevel(LOG_TRACE);
SetTargetFPS(60);
Texture tex = {0};
while(!WindowShouldClose()) {
if (IsKeyDown(KEY_LEFT_CONTROL) && IsKeyPressed(KEY_V)) {
#ifdef _WIN32
img = GetClipboardImage();
tex = LoadTextureFromImage(img);
if(!IsTextureValid(tex)) {
exit(98);
} else {
ExportImage(img, "Debug.bmp");
}
#endif
}
BeginDrawing();
ClearBackground(RAYWHITE);
if (IsTextureValid(tex)) {
DrawTexture(tex, 0, 0, WHITE);
}
DrawText("Print Screen and Crtl+V", 10, 10, 21, BLACK);
EndDrawing();
}
}