Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: why screenshot weight more than original picture? and why i get black image?  (Read 2155 times)

0 Members and 1 Guest are viewing this topic.

owl721

  • Newbie
  • *
  • Posts: 10
    • View Profile
image weight
(click to show/hide)
black image + if you minimize a window it turns black or white
(click to show/hide)
i tested it on this image https://en.wikipedia.org/wiki/Portable_Network_Graphics#/media/File:PNG_transparency_demonstration_1.png
original: 214 KB
screenshot: 330KB

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
I'm fully sure what your question is or what you are experiencing but I have two points which may answer your question or help you figure out the answer:
  • SFML windows have no alpha channel so clearing with sf::Color::Transparent is the same as clearing with sf::Color::Black (not technically accurate - see my post below)
  • The file size difference could just be because of compression used on the original
« Last Edit: July 09, 2016, 04:27:48 pm by Hapax »
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

owl721

  • Newbie
  • *
  • Posts: 10
    • View Profile
first
black=none = 297KB
Transparent = 330KB(Transparent is supported in sfml window)
second
i try with bmp
original 24 88KB(painted in paint)

2 - not supported
16 original 15KB screenshot 88KB
24 original 88KB screenshot 88KB
256 original 31KB screenshot 88KB

so sfml suport only 24 bmp
what compression used in sfml?
« Last Edit: July 08, 2016, 11:00:21 pm by owl721 »

owl721

  • Newbie
  • *
  • Posts: 10
    • View Profile
why second program make black screenshot?

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Remember to post code inside [code=cpp] [/code] tags.

I may have been slightly wrong about the window alpha layer. It's possible that it stores the alpha layer in the colours; it just does not use that alpha when displaying the window.

I suppose the compression would be related to the image loading library that SFML uses. Just so you know, Photoshop also saves the PNG image larger when re-saving it.

The second code makes black screenshot (actually, a transparent screenshot) because when you try to clear, draw and display to the window, it's probably not finished being opened so has nothing to work with and therefore you're capturing the window before it's even there.
You can see this by adding:
while (!window.isOpen()) { }
before window.clear

EDIT: added missing "not" to the phrase "it just does 'not' use that alpha"
« Last Edit: July 09, 2016, 04:26:53 pm by Hapax »
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

owl721

  • Newbie
  • *
  • Posts: 10
    • View Profile
thank  :)

 

anything