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

Misleading naming conventions regarding channel ordering #34

Open
stohrendorf opened this issue Jan 15, 2023 · 2 comments
Open

Misleading naming conventions regarding channel ordering #34

stohrendorf opened this issue Jan 15, 2023 · 2 comments

Comments

@stohrendorf
Copy link

The encoding expects a channel ordering of BGRA, whereas every function argument or function name uses RGBA. Even more confusing, the decoding returns RGBA, and not BGRA, which means that the semantics of the data suddenly changes when doing a simple encode/decode roundtrip (given you could put in in-memory data as mentioned in #33), as the channel ordering gets changed.

@wolfpld
Copy link
Owner

wolfpld commented Jan 15, 2023

This is true, but what is the issue here?

@stohrendorf
Copy link
Author

It makes it error-prone to write and understand code. For example,

    const uint8_t b = *data++;
    const uint8_t g = *data++;
    const uint8_t r = *data++;
    data++;

    const int dr = a[bid][0] - r;
    const int dg = a[bid][1] - g;
    const int db = a[bid][2] - b;

can easily be considered a bug when one assumes the data is in RGBA order, as every identifier suggests, or it can lead to wrong channel extraction when writing some custom code.

The issue here is that the variables do not contain what they say.

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

No branches or pull requests

2 participants