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

Author Topic: Internal image storage question  (Read 3136 times)

0 Members and 1 Guest are viewing this topic.

quasius

  • Full Member
  • ***
  • Posts: 166
    • View Profile
Internal image storage question
« on: March 27, 2008, 08:36:44 pm »
Hey and thanks for the great library.  I have a question about the internal storage of an image.  (The data you get with sf::Image.GetPixelsPtr())
Is this data always guaranteed to be 4 bytes-per-pixel (RGBA, as far as I can tell), right-to-left, top-to-bottom with 0000 always being transparent?
Is it's true now, will this possibly change in the future?  (I'm trying to decide exactly how deeply to embed this assumption into my code.)
Thanks again and happy Easter.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Internal image storage question
« Reply #1 on: March 28, 2008, 01:56:50 am »
Quote
Is this data always guaranteed to be 4 bytes-per-pixel (RGBA, as far as I can tell), right-to-left, top-to-bottom with 0000 always being transparent?

Except that it's left-to-right, yes it is. SFML uses a unique internal representation for textures, it's not going to change. So you can safely rely on it.
Laurent Gomila - SFML developer

quasius

  • Full Member
  • ***
  • Posts: 166
    • View Profile
Internal image storage question
« Reply #2 on: March 28, 2008, 09:18:06 pm »
Quote from: "Laurent"
Quote
Is this data always guaranteed to be 4 bytes-per-pixel (RGBA, as far as I can tell), right-to-left, top-to-bottom with 0000 always being transparent?

Except that it's left-to-right, yes it is. SFML uses a unique internal representation for textures, it's not going to change. So you can safely rely on it.


The transparent pixels seem to be RGB0, not 0000- at least with .png.  I'll just check for the A byte being 0.

Edit:  It would still be nice to have a consistent pattern to transparent pixels, in case A is 0 for some other reason, but I guess it doesn't matter for my current use.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Internal image storage question
« Reply #3 on: March 29, 2008, 04:38:46 am »
Yes, sorry I forgot to tell you about alpha. Transparency is only given by the Alpha chanel, independently of the RGB ones. It allows to have colored pixels partially transparent, for example.

Note that transparency can also be influenced by RGB chanels if you change the blending mode to multiplicative or additive.
Laurent Gomila - SFML developer

 

anything