PNG transparent colour

BlitzPlus Forums/BlitzPlus Programming/PNG transparent colour

DrDerekDoctors(Posted 2006) [#1]
Started this in BlitzMAX by mistake <slaps forehead> - anyhoo, if I load a PNG with a transparent colour set, it just draws those pixels in the PNG as white rather than transparent. Any way around this?


Beaker(Posted 2006) [#2]
You can't do alpha in B+, but you can set a mask color:
http://www.blitzbasic.com/bpdocs/command.php?name=MaskImage&ref=2d_cat


Grey Alien(Posted 2006) [#3]
I answered this *again* but from a BlitzPlus viewpoint in the BlitzMax thread :-)


DrDerekDoctors(Posted 2006) [#4]
Yes, I know, but that isn't much use when I'm not making the images myself. Bit of a crap oversight on Mark's part to allow loading of PNGs and then ignore the palette transparency, doncher think?


Grey Alien(Posted 2006) [#5]
1) Make a normal image with a Magenta background
2) save without any transparency info
3) set the mask colour to 255,0,255
4) tada.


DrDerekDoctors(Posted 2006) [#6]
Er. Wuh?


Beaker(Posted 2006) [#7]
It would be *much* slower to draw with alpha (which is presumably why it was never included). You might find that you get more mileage out of doing 2D-in-3D in BlitzMax or Blitz3D (using hardware acceleration). Of course it will run on less machines that way.


DrDerekDoctors(Posted 2006) [#8]
I don't want proper 256 level alpha, I'm talking about clutted images which have had one colour nominated as transparent (ie, like GIFs).


Grey Alien(Posted 2006) [#9]
you never said that these were images that existed already. You need to convert them as per my tip in the MAx thread. Blitz Plus can't read PNG transparency so get over it and convert your images or get BlitzMax.


DrDerekDoctors(Posted 2006) [#10]
Can BMax do GUI stuff then? If so, that's a tempting proposition.


Grey Alien(Posted 2006) [#11]
yes, but you have to buy the GUI module.


DrDerekDoctors(Posted 2006) [#12]
Poot. :P


Robert Cummings(Posted 2006) [#13]
I think the gui module is free to b+ users.


DrDerekDoctors(Posted 2006) [#14]
Yeah, appears to be for a limited time only, however it's still $80 for BMAX and I don't think I can get work to pay for it. Also, it depend how well supported it's going to be - Blitz Plus and it's updates don't exactly represent a glowing paragon of customer support, do they?


Beaker(Posted 2006) [#15]
I dunno, giving a free maxGUI license if you own B+ seems like pretty good customer support to me.

Also, B+ "does exactly what it says on the tin". Its very stable and runs on a wide range of hardware.

Regarding support for BlitzMax: it is the future of Blitz, and unlike B+ and BB3D, can be made to do anything that users (or BRL itself) want it to do, because it is an almost completly open system.


Grey Alien(Posted 2006) [#16]
Dr Dr, I used BlitzPlus for over a year, it's really good and neat BUT it's no longer good enough to make professional games in that portals will accept due to lack of 3D card effects, so I'm using Max now. I have to unlearn all the PLus stuff and learn Max from scratch, wish I'd done that in the first place, but when I bought Plus, Max was ONLY available for Macs!!


DrDerekDoctors(Posted 2006) [#17]
S'not a game, it's an application.

As for giving a "free" version of the GUI stuff, it's only free if you plop down the $80 for BMax first. Just seems to me that B+ was abandoned really rather quickly in the headlong rush to make BMax.


tonyg(Posted 2006) [#18]
B+ was abandoned really rather quickly


What? It's been around for 3 years, is still going and still does what it said it would do 3 years ago for only $60. That's $20 per year of use you've got out of it plus the rest of it's life for free.
Anyway, are you making all these assumptions based on the fact it doesn't, never has and never will handle transparency?


DrDerekDoctors(Posted 2006) [#19]
It does handle nominating a transparent colour in an image via maskimage, though, doesn't it? And CLUT'd PNGs can contain a nominated transparent colour, don't they? So why can't B+ make use of this information?


tonyg(Posted 2006) [#20]
Because DirectDraw doesn't?


DrDerekDoctors(Posted 2006) [#21]
I don't believe that DirectDraw handles PNGs at all, so Mark would have had to use something else to load them anyway, so why ignore the transparent colour information?


Kuron(Posted 2006) [#22]
IIRC Blitz uses the freeimage lib for loading images?

so why ignore the transparent colour information?
Because that is not how DirectDraw works?

An easy fix for you would be to manually read the transparent color info and then set that color as the transparent color when the image is drawn. Make the function once and use it over and over. There is plenty of opensource info on the PNG format that should allow you to do this.


DrDerekDoctors(Posted 2006) [#23]
Well, thanks to Phil Snart I'm gonna' do that. I can use FreeImage to easy find the index of the transparent colour, although finding the RGB values for said colour is a little more complex.