Plugin Question: SetSpriteAlphaBlended()

Started by Janik, Sat 16/09/2006 04:17:01

Previous topic - Next topic

Janik

Hi,

I'm having trouble understanding how to use the plugin function SetSpriteAlphaBlended properly. Here is what I am trying to accomplish:


  • 1.  Import sprites in 32-bits, with alpha channel (the sprites have anti-aliased edges).

  • 2.  In rooms where the walkable area scaling is different than 100%, I would like the sprites to be displayed as though they had been imported without an alpha channel. The area around the edge, with opacity < 100%, becomes black. The rest of the sprite is scaled smoothly.

  • 3.  In rooms where the scaling is 100%, the sprites are drawn normally, that is, using the alpha channel. This keeps the edges looking nice.

I have tried using SetSpriteAlphaBlended on the sprites that were imported in the editor, and as the documentation says the result was unpredictable. The same sprite, if switched from blended to not blended, would appear differently at different times. As well, the non-alpha blended sprite was not scaled smoothly.

I was able to get something working by copying the original (alpha) sprite to a dynamic sprite, and using SetSpriteAlphaBlended on this. However this requires copying ALL the character sprites, so it is a little clunky and uses up memory.

Is there a way to do what I describe directly, or could it be added?

Thanks!
Play pen and paper D&D? Then try DM Genie - software for Dungeons and Dragons!

Pumaman

Forgive me if I"m missing something but the functionality you describe sounds like AGS's default behaviour with regards to alpha channels, so I'm not sure what you're trying to accomplish?

Janik

Since a picture is worth 1000 words :), I've prepared a image showing what I want to do:

All 4 images come from the same file.
The 2 on the left are imported with the alpha channel.
For the 2 on the right, when importing the file I specified NOT to use the alpha channel when AGS asks. The antialiased edge shows up as pure black instead.

What I would like to do is circled on the picture. I want to use the same sprite (the one imported with the alpha channel) to produce both effects. At 100% scaling, use the alpha channel to keep edges anti-aliased, and at other scalings, use only the pink color for transparency, and so be able to smoothly scale the sprites.

Play pen and paper D&D? Then try DM Genie - software for Dungeons and Dragons!

Pumaman

Ah ok, sorry yeah I forgot that AGS didn't do the smooth scaling with alpha blended images. Really it would be better to fix that than to change how SetSpriteAlphaBlended works, but it needs more investigation.

SMF spam blocked by CleanTalk