Page 1 of 2
is it duplicated library code in final exe ?
Posted: Sat May 10, 2025 7:46 am
by moricode
Zlib provides functions like deflate (compress) and inflate (decompress)
ZIP files often use deflate compression internally to compress individual files
if they worked more or less the same in decode/encode functions ,
then my program use PNG encoder/decoder and also useZIP encoder/decoder
so , my EXE size is huge because they included both function .
can this PNG and ZIP is share use the deflate (compress) and inflate (decompress) function ? so will reduce the redundant binary size ?
Re: is it duplicated library code in final exe ?
Posted: Sat May 10, 2025 11:12 am
by boddhi
To the best of my knowledge, the UsePNGImageEncoder() and UsePNGImageDecoder() functions don't compress/decompress PNG images, but only allow this type of image to be written and read.
So, to compress/decompress them in size, you need to use too the appropriate functions provided by the Packer lib or other external lib/program.
Re: is it duplicated library code in final exe ?
Posted: Sat May 10, 2025 12:18 pm
by Fred
It's already shared between libs which use the same components
Re: is it duplicated library code in final exe ?
Posted: Tue May 13, 2025 4:26 am
by moricode
In PB 5.72 x86, compiled to final exe size :
Code: Select all
MessageRequester("","")
exe = 5 KB
Code: Select all
UseZipPacker()
MessageRequester("","")
exe = 201 KB
Code: Select all
UsePNGImageEncoder()
UsePNGImageDecoder()
MessageRequester("","")
exe = 148 KB
Code: Select all
UseZipPacker()
UsePNGImageEncoder()
UsePNGImageDecoder()
MessageRequester("","")
exe = 303 KB
so it look like duplicated code in binary
it is clear that has 303 - 148 = 155 KB more ?
Re: is it duplicated library code in final exe ?
Posted: Tue May 13, 2025 5:53 am
by Demivec
moricode wrote: Tue May 13, 2025 4:26 am
it is clear that has 303 - 148 = 155 KB more ?
Am I wrong or does your math looks a little wonky?
I see 303 KB - (148 KB) - (201 KB - 5 KB) = -41 KB. So combining everything into the exe sized 303 KB seems to save 41 KB.
@Edit: corrected a minor error.
Re: is it duplicated library code in final exe ?
Posted: Tue May 13, 2025 6:26 am
by Fred
Re: is it duplicated library code in final exe ?
Posted: Tue May 13, 2025 7:43 am
by moricode
Demivec wrote: Tue May 13, 2025 5:53 am
moricode wrote: Tue May 13, 2025 4:26 am
it is clear that has 303 - 148 = 155 KB more ?
Am I wrong or does your math looks a little wonky?
I see 303 KB - (148 KB - 5 KB) - (201 KB - 5 KB) = -36 KB. So combining everything into the exe sized 303 KB seems to save 36 KB.
so you mean the PNG format placeholder without the deflate (compress) and inflate (decompress) code cause a large binary of 140+KB ?
so to use a PNG function needed 303K in total or just 148KB enough ?
dose this just will work without the zippacker ?
Code: Select all
UsePNGImageEncoder()
UsePNGImageDecoder()
MessageRequester("","")
exe = 148 KB
Re: is it duplicated library code in final exe ?
Posted: Tue May 13, 2025 8:24 am
by AZJIO
You don't need a ZIP for PNGs. You can use PNGGauntlet to compress PNG files as much as possible
Re: is it duplicated library code in final exe ?
Posted: Tue May 13, 2025 8:33 am
by Fred
moricode wrote: Tue May 13, 2025 7:43 am
Demivec wrote: Tue May 13, 2025 5:53 am
moricode wrote: Tue May 13, 2025 4:26 am
it is clear that has 303 - 148 = 155 KB more ?
Am I wrong or does your math looks a little wonky?
I see 303 KB - (148 KB - 5 KB) - (201 KB - 5 KB) = -36 KB. So combining everything into the exe sized 303 KB seems to save 36 KB.
so you mean the PNG format placeholder without the deflate (compress) and inflate (decompress) code cause a large binary of 140+KB ?
so to use a PNG function needed 303K in total or just 148KB enough ?
dose this just will work without the zippacker ?
Code: Select all
UsePNGImageEncoder()
UsePNGImageDecoder()
MessageRequester("","")
exe = 148 KB
You just need UsePNGImageEncoder() and UsePNGImageDecoder() to use PNG, why do you want to add the zip lib ? The zip lib large because it use libarchive which handle a lot of file format. But if you use both, it uses a common libzip defalte as both need it, that's why 36KB are saved.
Re: is it duplicated library code in final exe ?
Posted: Tue May 13, 2025 8:51 am
by moricode
Fred wrote: Tue May 13, 2025 8:33 am
You just need UsePNGImageEncoder() and UsePNGImageDecoder() to use PNG, why do you want to add the zip lib ? The zip lib large because it use libarchive which handle a lot of file format. But if you use both, it uses a common libzip defalte as both need it, that's why 36KB are saved.
it comes to a points that , i want to use PNG , and i want to use the deflate/inflate method to compress the memory buffer (other that image buffer),
so i use UsePNGImageEncoder() and UsePNGImageDecoder() ,
without the zippacker , can i use the PNG deflate/inflate method ?
just like PNGdeflateMemory() and PNGinflateMemory() ? then i do not need Zip lib
Re: is it duplicated library code in final exe ?
Posted: Tue May 13, 2025 9:02 am
by Fred
You can already use the deflate zip method if you include PNG, please post a code showing what you are trying to do
Re: is it duplicated library code in final exe ?
Posted: Tue May 13, 2025 9:13 am
by Demivec
so you mean the PNG format placeholder without the deflate (compress) and inflate (decompress) code cause a large binary of 140+KB ?
so to use a PNG function needed 303K in total or just 148KB enough ?
[/quote]
it looks like I was off in my math by 5 KB. I've redone it to show how it works a little better.
Looking at what was in each file you compiled it looks like this:
Code: Select all
Program Elements:
A ------- MessageRequester("","")
B ------- UseZipPacker()
C ------- UsePNGImageEncoder()
D ------- UsePNGImageDecoder()
Prog_1 Prog_2 Prog_3 Prog_4
A A A A
B B
C C
D D
-----------------------------------------------------------
Size 5 KB 201 KB 148 KB 303 KB
(A= 5 KB) 196 KB - A 143 KB - A 298 KB
(B= 196 KB) - B 102 KB
(C+D= 143 KB) (C+D= 102 KB)
- 102 KB - 102 KB
-----------------------------------------------------------
41 KB extra
Prog_4 had more in it but took up 41 KB less than Prog_3 even though Prog_3 doesn't include UseZipPacker().
Fred and others have given some explanation as to why this might be so.
Re: is it duplicated library code in final exe ?
Posted: Tue May 13, 2025 9:15 am
by moricode
Result = CompressMemory(*Buffer, Size, *Output, OutputSize [, Plugin [, Level]])
Description
Compress the buffer content into the output buffer. The output buffer length needs to be at least as long as the buffer to compress.
Parameters
*Buffer The memory buffer to compress.
Size The size of the memory to compress.
*Output The memory buffer to store the compressed data.
OutputSize The memory buffer size to store the compressed data.
Plugin (optional) The plugin to use, if more than one packer plugin has been registered. It can be one of the following value:
#PB_PackerPlugin_BriefLZ: use the BriefLZ packer to compress the memory. UseBriefLZPacker() has to be called to register the plugin.
#PB_PackerPlugin_Zip : use the Zip packer to compress the memory. UseZipPacker() has to be called to register the plugin.
#PB_PackerPlugin_LZMA : use the LZMA packer to compress the memory. UseLZMAPacker() has to be called to register the plugin.
CompressMemory() ---> can i use the #PB_PackerPlugin_PNG or #PB_PackerPlugin_Deflate ?
since the PNG is already Deflate/inflate enable
Re: is it duplicated library code in final exe ?
Posted: Tue May 13, 2025 9:23 am
by moricode
it doesn't matter how the math is ,
when i UsePNGEncode() and UsePNGDecoder() , could i use the Deflate methor in CompressMemory() function ?
in Doc help file , the CompreeMemory() only support #PB_PackerPlugin_BriefLZ , #PB_PackerPlugin_Zip , #PB_PackerPlugin_LZMA
how to use the deflate/inflate method in CompressMemory() ?
Thanks .
Re: is it duplicated library code in final exe ?
Posted: Tue May 13, 2025 11:26 am
by jacdelad
AZJIO wrote: Tue May 13, 2025 8:24 am
You don't need a ZIP for PNGs. You can use PNGGauntlet to compress PNG files as much as possible
OxiPNG ist even better.