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

Fix nk_font_bake_convert() for big-endian machines #758

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mardy
Copy link

@mardy mardy commented Dec 29, 2024

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.

*dst++ = 0xff; // r
*dst++ = 0xff; // g
*dst++ = 0xff; // b
*dst++ = *src++; // a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to have /* comments for C89.

Also, does this still work on non-big endian devices? The RGB bit order should be fine, but I am unclear.

@@ -17230,7 +17230,7 @@ nk_font_bake_convert(void *out_memory, int img_width, int img_height,
const void *in_memory)
{
int n = 0;
nk_rune *dst;
nk_byte *dst;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the update. Would you mind making this change in the src destroy? We use paq.sh to combine the files, so wouldn't want to lose your changes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I will do the needed changes today or tomorrow and I'll ping you back.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested the changes on a little endian machine, the conversion still works.

I added the changes to the src directory as well; should I remove them from nuklear.h, or is it OK like it is now?

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants