png: fix gray pix formats (#35)
Some checks failed
Build & Test (Arch) / Arch: Build and Test (gcc) (push) Has been cancelled
Build & Test (Arch) / Arch: Build and Test (clang) (push) Has been cancelled
Build & Test / nix (hyprgraphics) (push) Has been cancelled
Build & Test / nix (hyprgraphics-with-tests) (push) Has been cancelled

This commit is contained in:
Maximilian Seidler 2025-09-10 22:21:04 +00:00 committed by GitHub
parent 621e2e00f1
commit aa9d14963b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -86,13 +86,13 @@ static std::expected<cairo_surface_t*, std::string> loadPNG(png_structp png, png
png_set_palette_to_rgb(png);
if (COLOR_TYPE == PNG_COLOR_TYPE_GRAY && BPP < 8)
png_set_expand_gray_1_2_4_to_8(png);
if (COLOR_TYPE == PNG_COLOR_TYPE_GRAY || COLOR_TYPE == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_gray_to_rgb(png);
if (png_get_valid(png, info, PNG_INFO_tRNS))
png_set_tRNS_to_alpha(png);
if (COLOR_TYPE == PNG_COLOR_TYPE_RGB || COLOR_TYPE == PNG_COLOR_TYPE_GRAY || COLOR_TYPE == PNG_COLOR_TYPE_PALETTE)
png_set_filler(png, 0xFF, PNG_FILLER_AFTER);
else if (COLOR_TYPE == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_gray_to_rgb(png);
png_read_update_info(png, info);