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

Author Topic: does sfml support 16 bit images ?  (Read 2058 times)

0 Members and 1 Guest are viewing this topic.

gaz99

  • Newbie
  • *
  • Posts: 7
    • View Profile
does sfml support 16 bit images ?
« on: November 20, 2013, 07:03:11 pm »
Hi,

I've been creating terrain from a height map in open gl using sfml to load the image in. I know you can't load in a 16 bit png so i've been trying jpeg but my terrain still get's the stair effect. Does sfml support 16 bit images ?

G.

  • Hero Member
  • *****
  • Posts: 1592
    • View Profile
Re: does sfml support 16 bit images ?
« Reply #1 on: November 20, 2013, 07:39:35 pm »
If your terrain gets a stairs effect, maybe your image resolution isn't high enough in comparison to the resolution of your terrain.
Like sf::Image, sf::Texture can handle a unique internal representation of pixels, which is RGBA 32 bits. This means that a pixel must be composed of 8 bits red, green, blue and alpha channels – just like a sf::Color.
Why don't you load a 32 bits PNG?

wintertime

  • Sr. Member
  • ****
  • Posts: 255
    • View Profile
Re: does sfml support 16 bit images ?
« Reply #2 on: November 20, 2013, 09:18:02 pm »
I think he wants 16bit per color channel and for that he needs to use libPNG+zlib himself. Using jpg is even worse than 8bit color channels, its commonly known it introduces artifacts from lossy compression.
Better try to modify the heightmap such that its not 0 at depth of the Mariana Trench and 255 on Mount Everest height.
That means you could for example partition the map into squares and save the lowest and highest height of each map square separately (for example in another low resolution heightmap) and using the full map (or many smaller ones) only for additional details.
Or you could split a 32bit number into 4 bytes manually, put them in the 4 channels of an 8 bit PNG (but still avoid loosing too much of the number range from including middle of earth and beginning of outer space ;) ), then load the image with SFML and reconstruct the number.

 

anything