Skip to content

Commit 59b8723

Browse files
committed
Fix nk_font_bake_convert() for big-endian machines
Fix the byte order for converting alpha images into RGBA by writing the destination byte-by-byte. The compiler should anyway be able to optimize this.
1 parent 7f406ee commit 59b8723

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

nuklear.h

+8-4
Original file line numberDiff line numberDiff line change
@@ -17230,7 +17230,7 @@ nk_font_bake_convert(void *out_memory, int img_width, int img_height,
1723017230
const void *in_memory)
1723117231
{
1723217232
int n = 0;
17233-
nk_rune *dst;
17233+
nk_byte *dst;
1723417234
const nk_byte *src;
1723517235

1723617236
NK_ASSERT(out_memory);
@@ -17239,10 +17239,14 @@ nk_font_bake_convert(void *out_memory, int img_width, int img_height,
1723917239
NK_ASSERT(img_height);
1724017240
if (!out_memory || !in_memory || !img_height || !img_width) return;
1724117241

17242-
dst = (nk_rune*)out_memory;
17242+
dst = (nk_byte*)out_memory;
1724317243
src = (const nk_byte*)in_memory;
17244-
for (n = (int)(img_width * img_height); n > 0; n--)
17245-
*dst++ = ((nk_rune)(*src++) << 24) | 0x00FFFFFF;
17244+
for (n = (int)(img_width * img_height); n > 0; n--) {
17245+
*dst++ = 0xff; // r
17246+
*dst++ = 0xff; // g
17247+
*dst++ = 0xff; // b
17248+
*dst++ = *src++; // a
17249+
}
1724617250
}
1724717251

1724817252
/* -------------------------------------------------------------

0 commit comments

Comments
 (0)