Page 1 of 1

Convert BMPs for use in SFML.

Posted: 2013-04-16T05:30:40-07:00
by Dus
Hi,
I'm trying to convert some old DirectX 6 files I made to PNGs to be used in SFML.
I have a car.bmp and a car.MASK.bmp where the MASK file has only the colors white, black and gray. Those indicate no transparency, full transparency and semi-transparency respectively.
So I'd like to see the colors of the mask to be converted to alpha values and the colors of the picture copied into it.

I thought I was on the right track with:

Code: Select all

convert c:\path\car.MASK.bmp -transparent black PNG8:textlogo.png
but now there's only 1 bit transparency and if I don't use 'PNG8:' the file won't load in SFML.

Being new to IM and seeing the many possibilities of ImageMagick-6.8.4-Q8 (on win xp) I could be looking for a while. So what is the best way to tackle this problem please?

Edit: Damn! Wrong forum, sorry!

Re: Convert BMPs for use in SFML.

Posted: 2013-04-16T08:01:15-07:00
by snibgo
Not sure if I understand what you want, but perhaps ...

Code: Select all

convert car.bmp car.MASK.bmp -compose CopyOpacity -composite PNG8:textlogo.png
... which will use the greyscale from the mask file for the alpha. Black in the mask becomes transparent in the output.

Re: Convert BMPs for use in SFML.

Posted: 2013-04-16T08:50:12-07:00
by Dus
Thanks, this copies the colors OK but the gray areas (hex 808080) in the mask are now fully transparent too. And I would like those to be 50%.
PNG8: always has only one bit for transparency I understand now. If so, that's not what I need.

I started experimenting with things like '-type Palette' and '-depth 8' (I have ImageMagick-6.8.4-Q16 installed as well) but that never gives a PNG which SFML accepts. (And any alpha value can be used in SFML)
I don't know what to try next.

Re: Convert BMPs for use in SFML.

Posted: 2013-04-16T09:57:55-07:00
by snibgo
I don't know what SFML is. What types of files does it accept?

Re: Convert BMPs for use in SFML.

Posted: 2013-04-16T14:11:17-07:00
by Dus
Files like BMP, JPG, PNG, TGA, PSD, and DDS.
But if you mean a specific type of PNG, I haven't been able to find that.

I do have an answer however; using -Q16 i do:

Code: Select all

convert car.bmp car.MASK.bmp -compose CopyOpacity -composite textlogo.png
I leave out PNG8:, it'll be a PNG32: then. This seems to be what I want, thanks.

Re: Convert BMPs for use in SFML.

Posted: 2013-04-16T14:41:26-07:00
by snibgo
It's always best to leave off any PNG specifiers, if you can. IM will then generally use the smallest format that keeps all the data.