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

The color channel of the palette, red and blue reverse,Only the following code is the correct color result #95

Closed
horch-E opened this issue Aug 15, 2022 · 4 comments

Comments

@horch-E
Copy link

horch-E commented Aug 15, 2022

    LodePNGState state;
    lodepng_state_init(&state);
    state.info_raw.colortype = LCT_PALETTE;
    state.info_raw.bitdepth = 8;
    state.info_png.color.colortype = LCT_PALETTE;
    state.info_png.color.bitdepth = 8;
    state.encoder.auto_convert = 0;

    for(int i=0; i < palette->count; i++) {
        auto r = palette->entries[i].b;
        auto g = palette->entries[i].g;
        auto b = palette->entries[i].r;
        auto a = palette->entries[i].a;
        lodepng_palette_add(&state.info_png.color, r, g, b, a);
        lodepng_palette_add(&state.info_raw, r, g, b, a);
    }
@kornelski
Copy link
Member

auto r = palette->entries[i].b; note r != b

@horch-E
Copy link
Author

horch-E commented Aug 15, 2022

auto r = palette->entries[i].b; note r != b

yes, but only by writing like this can I get the correct output file.
i have send email about the problem detail

@kornelski
Copy link
Member

kornelski commented Aug 15, 2022

In that case you have a BGR <> RGB mixup elsewhere. I'm 100% sure the library handles color order correctly.

Note that pixels must be in the RGBA order. There are operating systems and graphics frameworks which operate with ABGR or ARGB and other such combinations. Make sure you pass RGBA data in.

@horch-E
Copy link
Author

horch-E commented Aug 15, 2022

I understand, thank you

@horch-E horch-E closed this as completed Aug 15, 2022
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