diff options
| author | Pokechu22 <Pokechu022@gmail.com> | 2021-11-24 14:39:07 -0800 |
|---|---|---|
| committer | Pokechu22 <Pokechu022@gmail.com> | 2021-11-24 14:56:12 -0800 |
| commit | 8cf841ecc7f53c20eeda80e5beb0f3430868d28e (patch) | |
| tree | 4df414e76edeadb1bcf606e56dde617394bbaf6a /Source/Core/Common/Image.cpp | |
| parent | 99e589cc980988197bd4f367fae8bc4a5d4c51a1 (diff) | |
Fix saving RGBA images
PNG_FORMAT_RGB and PNG_COLOR_TYPE_RGB both evaluate to 2, but PNG_FORMAT_RGBA evaluates to 3 while PNG_COLOR_TYPE_RGBA evaluates to 6; the bit indicating a palette is 1 while the bit indicating alpha is 4.
Diffstat (limited to 'Source/Core/Common/Image.cpp')
| -rw-r--r-- | Source/Core/Common/Image.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Source/Core/Common/Image.cpp b/Source/Core/Common/Image.cpp index 87a2cb7e1f..54efcf5e6d 100644 --- a/Source/Core/Common/Image.cpp +++ b/Source/Core/Common/Image.cpp @@ -68,18 +68,19 @@ bool SavePNG(const std::string& path, const u8* input, ImageByteFormat format, u timer.Start(); size_t byte_per_pixel; - int png_format; + int color_type; switch (format) { case ImageByteFormat::RGB: - png_format = PNG_FORMAT_RGB; + color_type = PNG_COLOR_TYPE_RGB; byte_per_pixel = 3; break; case ImageByteFormat::RGBA: - png_format = PNG_FORMAT_RGBA; + color_type = PNG_COLOR_TYPE_RGBA; byte_per_pixel = 4; break; default: + ASSERT_MSG(FRAMEDUMP, false, "Invalid format %d", static_cast<int>(format)); return false; } @@ -110,7 +111,7 @@ bool SavePNG(const std::string& path, const u8* input, ImageByteFormat format, u bool success = false; if (png_ptr != nullptr && info_ptr != nullptr) { - success = SavePNG0(png_ptr, info_ptr, png_format, width, height, level, &buffer, WriteCallback, + success = SavePNG0(png_ptr, info_ptr, color_type, width, height, level, &buffer, WriteCallback, const_cast<u8**>(rows.data())); } png_destroy_write_struct(&png_ptr, &info_ptr); |
