123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|715|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Blitz -> Masking Anti Alias images

Sun, 10 May 2009, 04:47
LostUser
I recently got some photoshop shapes, which I like and look great, however when I mask them and pull them into Blitz I find that the image doesn't mask very well -- because the maskimage doesn't seem to handle anti-alias very well, if at all.

I'm wondering, is there something I can do in Blitz where it masks Anti Alias pixels, or at least treats it properly rather than me pixel editing every shape (they often look worse after pixel editing).

I'm wondering, does BlitzMax handle anti-aliased images better, or if there is another way to do this with Blitz 2D?

Thanks
Sun, 10 May 2009, 05:21
flying_cucco
I think Blitz 2D does not handle transparency very well. You can convert an anti-aliased image to a hard edged one (these instructions are for the gimp, but PS should be along the same lines)

Layer->Transparency->Color to Alpha and set the background color (if there is one) to be transparent

Layer->Transparency->Threshold Alpha to make all the pixels either fully opaque or transparent.

Set the foreground color to 255,0,255 or whatever you are using as the mask color

Layer->New Layer and select the foreground color to make the mask

Layer->Stack->Layer To Bottom to move the mask to underneath the sprite.

Done! Depending on the source, the result might look good, or crap, but experiment with the threshold.
Sun, 10 May 2009, 07:18
JL235
Blitz 2D only supports bitmasks in images, it does not support transparency.

Two BB alternatives:
1) If you load it as a texture it should support full transparency, but then you need to make it as a 3D game. Jay and I believe he has examples, but I hear it's not as straight forward as normal drawing.
2) There is a BB library somewhere which redid all the graphics commands. It was on BlitzCoder and I believe Jay has a copy or a link. It did support transparency, but I don't know if it was full transparency for loading/storing images (which is what you want) or for drawing a bitmasked image with a single global transparency for the whole image.
Sun, 10 May 2009, 07:40
Jayenkai
Yeah, B2d's not too great at transparency.
Your best bet is to avoid antialiased edges AT ALL COSTS..
Or, if you really need them, try to antialias to a background efficient colour, so they don't stand out as much. That is, render to sky blue if the sprites are in the sky, render to green if they're on grass, etc..

The "ExtendedBlitz2D.dll" does indeed work well, but unfortunately, it also tends to crash on a whole boatload of systems.
It's a shame, because otherwise it'd be fantastic.
It's here, but remember it crashes!

If you have Blitz3D, you can instead use one of the many "2D in 3D" engines available.
Basically, you load the sprite as a texture, pop the texture on poly's, then shift the poly's around.
It means you get the antialiasing, and you can also scale/rotate/alpha the sprites, too.
It's lovely stuff, but you do need B3d, first!
My version's here .. it's a very simple version of it, but it's done everything I need, so it's good enough

-=-=-
''Load, Next List!''
Sun, 10 May 2009, 08:16
LostUser
Unfortunately, I do not have B3D.

Yes, the whole anti-alias edges really does annoy me, although I understand that B2D was only ever really designed for those old school games where you did pixel sprites.

So what I've done so far is just basically go through every image and painstakingly get rid of the anti-aliased pixels and replace the semi-transparent anti-aliased pixels with the hard color (black).

Unfortunately, the result is not very good to look at.

However, I will try to follow flying_cucco's instructions on converting anti-alias to hard edged, or at the very least email the person I bought the shapes from to see if he can supply hard edged versions.

If this doesn't work, I'll just keep going ahead and finish the game I am building.
Sun, 10 May 2009, 08:55
JL235
If anti-aliased edges are essential, then there are two more options:

1) wrap your own graphics commands/library in a .dll and then use it with BB.
2) Switch to an alternative language, two BASICs that spring to mind are VB.NET and FreeBASIC.
Sun, 10 May 2009, 09:14
LostUser
Ok. I will keep this in mind.
Sun, 10 May 2009, 09:14
Phoenix


It will look a lot worse though, because the soft edges make a big difference.
Mon, 11 May 2009, 14:36
LostUser
Oh thanks for your help anyway Phoenix!

You're right. My pixel edited version was a bit better, so I am using that.