From cae2b2883bba3b666cfa5b8ba95eecbf0b8e2dea Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Sun, 9 Oct 2022 22:45:58 +0200 Subject: [PATCH] Fl_Cairo_Graphics_Driver: make image drawing correct whatever the host endianness. --- src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx index 48c6120c6..4421bd610 100644 --- a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx +++ b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx @@ -831,10 +831,8 @@ void Fl_Cairo_Graphics_Driver::cache(Fl_RGB_Image *rgb) { A = *(r+3); f = float(A)/0xff; } - *q = B * f; - *(q+1) = G * f; - *(q+2) = R * f; - *(q+3) = A; + // this produces ARGB data in native endian + *(uint32_t *)q = A << 24 | (uchar)(R*f) << 16 | (uchar)(G*f) << 8 | (uchar)(B*f); r += rgb->d(); q += 4; } } @@ -848,10 +846,9 @@ void Fl_Cairo_Graphics_Driver::cache(Fl_RGB_Image *rgb) { A = *(r+1); f = float(A)/0xff; } - *(q) = G * f; - *(q+1) = G * f; - *(q+2) = G * f; - *(q+3) = A; + G = (uchar)(G * f); + // this produces ARGB data in native endian + *(uint32_t *)q = A << 24 | G << 16 | G << 8 | G; r += rgb->d(); q += 4; } }