mirror of
https://github.com/minetest/irrlicht.git
synced 2024-11-05 18:00:41 +01:00
writeImageToFile param now used by CImageWriterPNG for compression level
A bit annoying that it kinda has the opposite meaning for png and jpg compression for same parameter (png compression goes up, jpg goes down). Also unfortunate we chose u32 instead of int here or we could at least use the usual zlib value range for png. But I think it still won't mess up in many cases. Defaults (value 0) stay the same as before. And setting a jpg range <= 10 is rarely done and even if so it just changes png sizes a bit now if people use writer for both. People just have to be careful now when they override defaults for png and then also write jpg - but can't help it. And it's too useful to not have this - this can massively change the write-speed for png's (like up to 3 times faster with no compression on my system). git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6570 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
parent
3fa020d03c
commit
8bf9cf5471
|
@ -1,6 +1,7 @@
|
|||
--------------------------
|
||||
Changes in 1.9 (not yet released)
|
||||
|
||||
- CImageWriterPNG now also supports the writeImageToFile param to allow setting compressing level. 0 stays default, 1-10 for range increasing compression level.
|
||||
- Add io::IUserData which can be set in SMaterial to make it easer passing additional material values to shaders
|
||||
- Add lens shift support for the camera and the perspective projection functions
|
||||
- TGA loader no longer reduces 24&32 bit TGA's with palettes to 16 bit. Thanks @erlehmann for report: https://irrlicht.sourceforge.io/forum/viewtopic.php?t=52925
|
||||
|
|
|
@ -1208,8 +1208,10 @@ namespace video
|
|||
for writing the image.
|
||||
\param image Image to write.
|
||||
\param filename Name of the file to write.
|
||||
\param param Control parameter for the backend (e.g. compression
|
||||
level).
|
||||
\param param Control parameter for the backend. Meaning depends on format:
|
||||
0 is always some default
|
||||
For jpg it's otherwise the quality level in range 1-100 (0=default is 75)
|
||||
For png it's the compression level in range 1-10 (0=default is converted to Z_DEFAULT_COMPRESSION)
|
||||
\return True on successful write. */
|
||||
virtual bool writeImageToFile(IImage* image, const io::path& filename, u32 param = 0) = 0;
|
||||
|
||||
|
@ -1219,8 +1221,10 @@ namespace video
|
|||
\param image Image to write.
|
||||
\param file An already open io::IWriteFile object. The name
|
||||
will be used to determine the appropriate image writer to use.
|
||||
\param param Control parameter for the backend (e.g. compression
|
||||
level).
|
||||
\param param Control parameter for the backend. Meaning depends on format:
|
||||
0 is always some default
|
||||
For jpg it's otherwise the quality level in range 1-100 (0=default is 75)
|
||||
For png it's the compression level in range 1-10 (0=default is converted to Z_DEFAULT_COMPRESSION)
|
||||
\return True on successful write. */
|
||||
virtual bool writeImageToFile(IImage* image, io::IWriteFile* file, u32 param =0) =0;
|
||||
|
||||
|
|
|
@ -87,6 +87,12 @@ bool CImageWriterPNG::writeImage(io::IWriteFile* file, IImage* image,u32 param)
|
|||
return false;
|
||||
}
|
||||
|
||||
// Set compression level
|
||||
// Sadly Irrlicht used param=0 as default and an u32 type
|
||||
// So to avoid breaking downward compatibility we keep 0 as default (which is -1 in zlib) and subtract 1 from param to everything into zlib range
|
||||
if (param <= 10) // Z_BEST_COMPRESSION is 9 - values above have so far no meaning
|
||||
png_set_compression_level(png_ptr, (int)param-1);
|
||||
|
||||
// Allocate the png info struct
|
||||
png_infop info_ptr = png_create_info_struct(png_ptr);
|
||||
if (!info_ptr)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Tests finished. 72 tests of 72 passed.
|
||||
Compiled as DEBUG
|
||||
Test suite pass at GMT Tue Nov 07 15:09:58 2023
|
||||
Test suite pass at GMT Mon Nov 13 14:43:47 2023
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user