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

Author Topic: Transparency  (Read 18182 times)

0 Members and 1 Guest are viewing this topic.

dabo

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
    • http://www.dabostudios.net
Transparency
« on: October 01, 2007, 09:37:20 pm »
Is it possible to set an entire image to become half transparent, not only a certain color?

zarka

  • Jr. Member
  • **
  • Posts: 81
    • View Profile
Transparency
« Reply #1 on: October 01, 2007, 10:10:09 pm »
Yes you can do like this

Code: [Select]

myDrawable.SetColor(sf::Color(255,255,255,128));


then it will be the original image with 50% transparency.

you will need to use white to not pollute the image with any color
//Zzzarka

dabo

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
    • http://www.dabostudios.net
Transparency
« Reply #2 on: October 01, 2007, 11:40:22 pm »
Quote from: "zarka"
Yes you can do like this

Code: [Select]

myDrawable.SetColor(sf::Color(255,255,255,128));


then it will be the original image with 50% transparency.

you will need to use white to not pollute the image with any color


Thanks a lot, it worked great.

jimboTL60

  • Newbie
  • *
  • Posts: 22
    • View Profile
File formats
« Reply #3 on: July 08, 2009, 02:49:35 am »
I just tried the PNG format, but Photoshop didn't allow me to export the alpha channel. It works with the TGA. What I don't understand is why I can't use BMPs for transparency with SFML. I mean, I can export the alpha channel, and load the image, and display it, but SFML doesn't care about its alpha channel. There's nothing new with 32-bits BMPs, so maybe someone should fix this.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Transparency
« Reply #4 on: July 08, 2009, 07:49:28 am »
BMPs don't have an alpha channel. Only TGA and PNG formats do.

And Photoshop allows to export alpha in PNG ;)
Laurent Gomila - SFML developer

jimboTL60

  • Newbie
  • *
  • Posts: 22
    • View Profile
Alpha channels
« Reply #5 on: July 08, 2009, 08:48:06 am »
Yes they do,

"An alpha channel (for transparency) may be stored in a separate file, where it is similar to a grayscale image, or in a fourth channel that converts 24-bit images to 32 bits per pixel." -Wiki

And that's what Photoshop allows, yet it doesn't allow alpha channels in PNG files.

Edit: Actually it allows you to export PNGs for Web with transparency, if you have a transparent background, but that's not the same at all. I'm using CS2, so I can't say if it changed in CS3...

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Transparency
« Reply #6 on: July 08, 2009, 10:32:49 am »
It seems that you're right, but I've never seen this before. Everybody always say "BMPs don't have alpha channel".

Anyway, BMP is probably the worst format, you shouldn't use it ;)
Laurent Gomila - SFML developer

jimboTL60

  • Newbie
  • *
  • Posts: 22
    • View Profile
Transparency
« Reply #7 on: July 08, 2009, 11:28:32 am »
Well, you shouldn't listen to everybody, since most of them are dumb cowards.

Why is BMP the worst format? I'd say it's pretty much deprecated, but sometimes useful. They are bit maps ... the purpose is obvious. And the header is so simple...

I use Tiffs for professional exportation (when psd isn't supported), it's more flexible. PNGs are for web exchange. Gifs are lightweight and can be animated. JPGs are the best for photo compression. And, well, now I use Targats to get support for the alpha channel. Yet, it would have been so simple to implement alpha management for the bitmaps.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Transparency
« Reply #8 on: July 08, 2009, 11:51:33 am »
I use an external library to load images, I can't fix it.

Anyway, PNGs and TGAs are like BMPs except they use RLE compression to save space. So I can't see any situation where BMP would be useful.
Laurent Gomila - SFML developer

jimboTL60

  • Newbie
  • *
  • Posts: 22
    • View Profile
Transparency
« Reply #9 on: July 08, 2009, 12:19:24 pm »
Well, now that I now TARGAs, I guess I'll never use bitmaps again  :cry: I wonder why Vista can't give me a preview of these files though... it sucks.

 

anything