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

Author Topic: How to avoid alpha blending on .gif images?  (Read 2604 times)

0 Members and 1 Guest are viewing this topic.

Tigre Pablito

  • Full Member
  • ***
  • Posts: 226
    • View Profile
    • Email
How to avoid alpha blending on .gif images?
« on: May 20, 2013, 05:08:40 am »
Hi Ladies and Guys from SFML

Can you tell me how to turn off the alpha value on a .GIF image? That is, that it only should use RGB, not A, as is Alpha was 255 (opacity 100%)
I m guessing, but something like:
sprite.Alpha = false;    // I m using C# .NET, NOT C++
Actually, I tried to find some attribute or method that does this, but I didn t

I m making a better version of my Mario game, and one of the changes was to convert the .bmp images to .gif, as it is the same color quality and the .gif are smaller ...the .bmp displayed alright, but some of the .gif, mainly those converted from .png files, does nt display, or display with some transparency

Or could you tell how to delete phisically the alpha channel from the .gif files?
I m sorry, I m very bad as an artist. Programming I stand better.
Exactly my problem is being that Kuppa, at the castle end, started invisible, then semi-transparent, and many other enemies flashes, cos some .gif don t display, plus Mario sprite images transparent color is not transparent ...
is there any problems with .gif images?

What does work fine is the transparency effect of the water, and the lights in the cavern, that are .png files (cos they need alpha)

Thank you very much!

Pablo
Bs As Argentina

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
Re: How to avoid alpha blending on .gif images?
« Reply #1 on: May 20, 2013, 05:19:05 am »
First of all, GIFs are almost NEVER the same quality as BMPs or PNGs. They are limited to 256 colors at max. In your case, that's not too limiting, but in general it's a pretty strict limit. Secondly, GIFs do not have proper support for alpha transparency, so if your images have alpha transparency, GIFs are very bad.

In general, PNG is FAR better than GIF. It has very high compression rates, zero loss in quality, and very high decoding rates. The best option, honestly, is probably to just use PNGs and be done with it.

EDIT: Just realized I misread your post, you don't want alpha in your sprites. In that case, still use PNG, but use a program like GIMP to remove the alpha channel. If you do that, no alpha information is saved into the PNG.
I use the latest build of SFML2

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: How to avoid alpha blending on .gif images?
« Reply #2 on: May 20, 2013, 08:55:45 am »
If your image has few colors, with large areas of the same pixel (like screen captures), use PNG. It uses RLE compression: if there are 50 consecutive pixels of white color, for example, it will just encode "50x white".

If your image has no pattern, and 24 millions colors (like a photo), use JPEG.

To disable alpha-blending in SFML, do this:
window.draw(sprite, sf::BlendNone);
Laurent Gomila - SFML developer

 

anything