Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rcore] Clipboard Image Support #4459

Merged
merged 17 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
34 changes: 34 additions & 0 deletions examples/core/core_clipboard_image.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include "raylib.h"
#include <stdio.h>
#include <stdlib.h>

static Image img = {0};
Fixed Show fixed Hide fixed
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();
}
}
21 changes: 21 additions & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
// Enabling this flag allows manual control of the frame processes, use at your own risk
//#define SUPPORT_CUSTOM_FRAME_CONTROL 1


// rcore: Configuration values
//------------------------------------------------------------------------------------
#define MAX_FILEPATH_CAPACITY 8192 // Maximum file paths capacity
Expand Down Expand Up @@ -272,4 +273,24 @@
//------------------------------------------------------------------------------------
#define MAX_TRACELOG_MSG_LENGTH 256 // Max length of one trace-log message


// Enable partial support for clipboard image, only working on SDL3 or
// being on both Windows OS + GLFW or Windows OS + RGFW
#define SUPPORT_CLIPBOARD_IMAGE 1

#if defined(SUPPORT_CLIPBOARD_IMAGE)
#ifndef STBI_REQUIRED
#define STBI_REQUIRED
#endif

#ifndef SUPPORT_FILEFORMAT_BMP
#define SUPPORT_FILEFORMAT_BMP 1
#endif

#ifndef SUPPORT_MODULE_RTEXTURES
#define SUPPORT_MODULE_RTEXTURES 1
#endif

#endif

#endif // CONFIG_H
Loading
Loading