diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-10-09 22:45:58 +0200 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-10-09 22:45:58 +0200 |
| commit | cae2b2883bba3b666cfa5b8ba95eecbf0b8e2dea (patch) | |
| tree | 8b75273a578e5f147b478b42981161daf32c86a1 /src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx | |
| parent | 2a856dafd40c01dce42747fd0f07b9e448e44f0e (diff) | |
Fl_Cairo_Graphics_Driver: make image drawing correct whatever the host endianness.
Diffstat (limited to 'src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx')
| -rw-r--r-- | src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx | 13 |
1 files 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; } } |
