image size when using SaveBrush or SaveSnapshot

Discuss any general programming issues here
Post Reply
pecaN
Posts: 124
Joined: Thu Jun 10, 2010 4:15 pm

image size when using SaveBrush or SaveSnapshot

Post by pecaN »

Hi,
when coding my progs in the past I realised an interesting thing (then I forgot about it) and now I encountered it again so I am asking : when using SaveSnapshot or SaveBrush and saving an image as PNG e.g. SaveBrush(1,"brush1.png", #IMGFMT_PNG) when resolution of the brush is 1358 x 1020 24bit, the output size is over 4 MB !! When I load it into uPaint (very Deluxe Paint like proggy I use on Windows) and then save it without any change, the output size is... 700 kb !!! And this is so great difference... is it a bug or am I using these commands incorrectly ? Thanx pecaN
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: image size when using SaveBrush or SaveSnapshot

Post by airsoftsoftwair »

First guess is that uPaint doesn't save the image as 24-bit but as 8-bit chunky... this would explain the smaller file size.
pecaN
Posts: 124
Joined: Thu Jun 10, 2010 4:15 pm

Re: image size when using SaveBrush or SaveSnapshot

Post by pecaN »

Thank you for your reply !

But I am not convinced yet... I tried it again with uPaint with the same result... Saved PNG from Hollywood 4MB, then loaded and saved in uPaint : True24bit cca 700kb, True 32bit 800kb - I am not a graphics professional but must say again that this is quite a big difference, especially when taken in mind that PNG was created to be as small as possible as a web format... And it's not only uPaint, I remember when creating BoingPairs on MorphOS, 252 x 252 brushes saved as JPG (24bit, 100percent quality) from Hollywood were then MUCH smaller when loaded in TVPaint and saved with the same parameters...

I also made a quick test with a JPG picture with same parameters as that PNG pic mentioned above... saved from Hollywood 3,96MB (24bit, 100%quality), then saved from uPaint (24bit, 100'% quality) and the size is 2,26 MB...

Please don't get me wrong I love Hollywood and I can't find the right words to praise you much for your work on Hollywood, I am just asking because I am now working on a proggy which should save more than 30 pictures and in such case it it a very BIG difference if each of them is 4 MB or 800kb... !! And I am using PNG format because according to my experience JPGs or GIFs may lose quality on different operating systems and resolutions....

pecaN
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: image size when using SaveBrush or SaveSnapshot

Post by airsoftsoftwair »

What platform are you on? When I try the following code to save a snapshot of my desktop on a Windows 7 system, the resulting PNG in 24-bit and 1920x1080pixels is just 120kb, not anywhere near 4MB or something.

Code: Select all

SaveSnapshot("snap.png",#SNAPDESKTOP,#IMGFMT_PNG)
pecaN
Posts: 124
Joined: Thu Jun 10, 2010 4:15 pm

Re: image size when using SaveBrush or SaveSnapshot

Post by pecaN »

Well I am sorry but still the same... :-(

I am on Win7 as well with Hollywood6, your code works as it should so when I grab a png snapshot of my 1366x768 24bit windows desktop it is really just 100kb BUT when I load this 100kb PNG as a brush to Hollywood and then just save it as PNG brush with the SAME properties (1366x768x24bitú now I get 3MB for the very same picture !!! So I really don't understand it... :-((
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: image size when using SaveBrush or SaveSnapshot

Post by airsoftsoftwair »

Can't reproduce this here. Test script:

Code: Select all

SaveSnapshot("snap.png",#SNAPDESKTOP,#IMGFMT_PNG)
LoadBrush(1,"snap.png")
SaveBrush(1,"snap2.png",#NOTRANSPARENCY,#IMGFMT_PNG)
DebugPrint(FileSize("snap.png"),FileSize("snap2.png"))
This prints:

Code: Select all

135785 135785
Both files are exactly the same. Tested on Windows.

Do you have a small test script that shows the problem?
pecaN
Posts: 124
Joined: Thu Jun 10, 2010 4:15 pm

Re: image size when using SaveBrush or SaveSnapshot

Post by pecaN »

YES NOW YOU I GOT IT !!!

I guess you won't believe what the problem was... :-( :-) I tried you code and it worked great, both files were of the same size! And I can tell you I used exactly the same code as you with ONE exception - I didin't use the "#NOTRANSPARENCY" argument !!! So that was the problem !!

So when grab a PNG snapshot of my desktop (1366x768x24bit) is around 76kb

then SaveBrush(1, "snap2.png", #IMGFMT_PNG) results in a filesize around 3MB

while SaveBrush(1, "snap2.png", #NOTRANSPARENCY, #IMGFMT_PNG) is exactly of the same size as that grab as you proved me... !!!

This is my fault as I never used any transparency stuff and I hardly know what exactly it is... so I will have to learn some more about this and why using transparency enlarges filesize so much...

I would like to thank you so much for your patience and I am very angry that I've wasted so much of your time, please accept my sincere apologies... :-(

pecaN
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: image size when using SaveBrush or SaveSnapshot

Post by airsoftsoftwair »

Well, you can just "leave out" a parameter. What you're essentially doing then is passing the value of #IMGFMT_PNG as the transparent color and the format argument will use its default value which is #IMGFMT_BMP. And that's why you're getting an uncompressed BMP picture instead of a PNG one.
pecaN
Posts: 124
Joined: Thu Jun 10, 2010 4:15 pm

Re: image size when using SaveBrush or SaveSnapshot

Post by pecaN »

airsoftsoftwair wrote:Well, you can just "leave out" a parameter. What you're essentially doing then is passing the value of #IMGFMT_PNG as the transparent color and the format argument will use its default value which is #IMGFMT_BMP. And that's why you're getting an uncompressed BMP picture instead of a PNG one.
yes now I know it, I just missed it in the docs... :-) anyway thank you again ! :-)

pecaN
Post Reply