Convert BMPs for use in SFML.

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
Dus
Posts: 9
Joined: 2013-04-16T04:57:39-07:00
Authentication code: 6789

Convert BMPs for use in SFML.

Post 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!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert BMPs for use in SFML.

Post 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.
snibgo's IM pages: im.snibgo.com
Dus
Posts: 9
Joined: 2013-04-16T04:57:39-07:00
Authentication code: 6789

Re: Convert BMPs for use in SFML.

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert BMPs for use in SFML.

Post by snibgo »

I don't know what SFML is. What types of files does it accept?
snibgo's IM pages: im.snibgo.com
Dus
Posts: 9
Joined: 2013-04-16T04:57:39-07:00
Authentication code: 6789

Re: Convert BMPs for use in SFML.

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert BMPs for use in SFML.

Post 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.
snibgo's IM pages: im.snibgo.com
Post Reply