Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Merge pull request #10143 from Pokechu22/png-compression-level
Add option for setting the PNG zlib compression level
- Loading branch information
Showing
12 changed files
with
122 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -64,6 +64,8 @@ add_library(common | ||
| HttpRequest.h | ||
| Image.cpp | ||
| Image.h | ||
| ImageC.c | ||
| ImageC.h | ||
| IniFile.cpp | ||
| IniFile.h | ||
| Inline.h | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| // Copyright 2021 Dolphin Emulator Project | ||
| // SPDX-License-Identifier: GPL-2.0-or-later | ||
|
|
||
| #include "Common/ImageC.h" | ||
|
|
||
| // Since libpng requires use of setjmp, and setjmp interacts poorly with destructors and other C++ | ||
| // features, this is in a separate C file. | ||
|
|
||
| // The main purpose of this function is to allow specifying the compression level, which | ||
| // png_image_write_to_memory does not allow. row_pointers is not modified by libpng, but also isn't | ||
| // const for some reason. | ||
| bool SavePNG0(png_structp png_ptr, png_infop info_ptr, int png_format, png_uint_32 width, | ||
| png_uint_32 height, int level, png_voidp io_ptr, png_rw_ptr write_fn, | ||
| png_bytepp row_pointers) | ||
| { | ||
| if (setjmp(png_jmpbuf(png_ptr)) != 0) | ||
| return false; | ||
|
|
||
| png_set_compression_level(png_ptr, level); | ||
| png_set_IHDR(png_ptr, info_ptr, width, height, 8, png_format, PNG_INTERLACE_NONE, | ||
| PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); | ||
| png_set_rows(png_ptr, info_ptr, row_pointers); | ||
| png_set_write_fn(png_ptr, io_ptr, write_fn, NULL); | ||
| png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL); | ||
|
|
||
| return true; | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| // Copyright 2021 Dolphin Emulator Project | ||
| // SPDX-License-Identifier: GPL-2.0-or-later | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <png.h> | ||
| #include <stdbool.h> | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" | ||
| #endif | ||
| bool | ||
| SavePNG0(png_structp png_ptr, png_infop info_ptr, int png_format, png_uint_32 width, | ||
| png_uint_32 height, int level, png_voidp io_ptr, png_rw_ptr write_fn, | ||
| png_bytepp row_pointers); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters