2 Commits

Author SHA1 Message Date
8571d445e9 [rtextures] Fix ImageDrawImageEx() blending on transparent destinations (#6224) 2026-10-06 20:55:35 +02:00
Ray
4722c9fa58 Minor tweaks 2026-10-06 18:35:06 +02:00
3 changed files with 5 additions and 22 deletions

View File

@ -285,7 +285,6 @@ static int android_close(void *cookie);
// CMake: handled automatically — the PUBLIC flag propagates as INTERFACE_LINK_OPTIONS
// to the consumer's final link via target_link_libraries
// Make: pass -Wl,--wrap=fopen to the linker command producing the final artifact
// build.zig: pass -Wl,--wrap=fopen to the linker command producing the final artifact
// custom: pass -Wl,--wrap=fopen to the linker command producing the final artifact
//
// SHARED library (.so) — wrapping is self-contained:
@ -296,8 +295,6 @@ static int android_close(void *cookie);
// only raylib internals are wrapped, app code requires a separate flag
// Make: handled automatically — src/Makefile sets LDFLAGS += -Wl,--wrap=fopen;
// only raylib internals are wrapped, app code requires a separate flag
// build.zig: NOT supported — std.Build has no dedicated linker wrap helper, the flag
// is not correctly applied at the .so link step
// custom: apply -Wl,--wrap=fopen to the linker command producing the .so
FILE *__real_fopen(const char *fileName, const char *mode); // Real fopen, provided by the linker (--wrap=fopen)
FILE *__wrap_fopen(const char *fileName, const char *mode); // Replacement for fopen()

View File

@ -2093,7 +2093,7 @@ static void WindowDropCallback(GLFWwindow *window, int count, const char **paths
// GLFW3: Keyboard callback, runs on key pressed
static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods)
{
if ((key < 0) || (key >= MAX_KEYBOARD_KEYS)) return; // Security check, macOS fn key generates -1
if ((key < 0) || (key >= MAX_KEYBOARD_KEYS)) return; // Security check, macOS fn key generates -1
// WARNING: GLFW could return GLFW_REPEAT, it needs to be considered as 1
// to work properly with our implementation (IsKeyDown/IsKeyUp checks)

View File

@ -4242,29 +4242,15 @@ void ImageDrawImageEx(Image *dst, Image src, Vector2 position, float rotation, f
Color srcColor = GetImageColor(src, srcX, srcY);
// Apply tint
srcColor.r = (unsigned char)(srcColor.r*tint.r/255.0f);
srcColor.g = (unsigned char)(srcColor.g*tint.g/255.0f);
srcColor.b = (unsigned char)(srcColor.b*tint.b/255.0f);
srcColor.a = (unsigned char)(srcColor.a*tint.a/255.0f);
// Skip fully transparent pixels
if (srcColor.a == 0) continue;
// Read destination pixel for alpha blending
// Read destination pixel and blend source over it, applying tint
// NOTE: ColorAlphaBlend() takes destination alpha into account,
// same as ImageDrawImagePro(), required to draw on transparent images
Color dstColor = GetImageColor(*dst, x, y);
unsigned int alpha = srcColor.a;
unsigned int invA = 255 - alpha;
Color out = {
(unsigned char)((srcColor.r*alpha + dstColor.r*invA)/255), // red
(unsigned char)((srcColor.g*alpha + dstColor.g*invA)/255), // green
(unsigned char)((srcColor.b*alpha + dstColor.b*invA)/255), // blue
(unsigned char)(alpha + (dstColor.a*invA)/255) // alpha
};
ImageDrawPixel(dst, x, y, out);
ImageDrawPixel(dst, x, y, ColorAlphaBlend(dstColor, srcColor, tint));
}
}
}