Page 1 of 1

Another BMP transparency issue

Posted: 2016-10-28T22:54:03-07:00
by petzi69
Since this is my first post here: hi folks!

I'm currently working on some BMP images to mod a game. Because of that, I'm tied to the very specific BMP format that this game accepts.

Step by step:
I take a source BMP of shall we say 800x600 pixel, I -extent it to add some borders (same color as the background). The borders are important!

Next step is to resize the image and turn the background transparent:

Code: Select all

convert source.bmp -fuzz 10% -alpha background -transparent #ec5b18 -resize 99x46 target.bmp
This works fine so far, but the target bmp has a different format as the game wants it. In-game, the whole picture is transparent, not just the background. I already found a solution for this on this forum:

Code: Select all

convert source.bmp  -alpha set -define bmp:format=bmp3 -define bmp3:alpha=true  target.bmp
But after this step, the borders are cropped down to zero pixel at the top and 1 pixel at the bottom border of the target.bmp. It defently happens in the final step, it looked perfect after the -resize.

What I'm I doing wrong, and more important, how I can solve this??

Re: Another BMP transparency issue

Posted: 2016-10-28T23:04:48-07:00
by fmw42
It would help if you provide your IM version and platform and also one of your bmp input images and one proper one from the game. You can upload to some place such as dropbox.com and put the URL here. Also provide all your commands for every step including the extending.

Please read the very top most post in this forum at viewtopic.php?f=1&t=9620

What do you mean by the whole picture is transparent?

It is possible if you are on an older version of IM, that one of the defines may be too new.

Also you should put -background #ec5b18 before -alpha background.

You could also try adding either -type truecoloralpha or -type palettealpha before your second command output. It is not yet clear without seeing your proper game image what type it expects for transparency and bit-depth.

This command seems to work for me to make all the background including the extended area transparent and saved as BMP3. Using IM 6.9.6.2 Q16 Mac OSX. Does that import into your game OK?

Code: Select all

convert logo: -background white -gravity center -extent 700x500 -fuzz 10% -transparent white -resize 140x100 -define bmp3:alpha=true BMP3:logo.bmp

Re: Another BMP transparency issue

Posted: 2016-10-29T01:48:29-07:00
by petzi69
Put -background #ec5b18 before -alpha background helped. Thanx a lot

Re: Another BMP transparency issue

Posted: 2016-10-29T03:38:42-07:00
by petzi69
Another question.
I would now like to select the non-transparent part of the my image and put a little 'drop-shadow' effect on it. The image should not change the size.

like this: Image

Re: Another BMP transparency issue

Posted: 2016-10-29T07:02:43-07:00
by snibgo

Re: Another BMP transparency issue

Posted: 2016-10-29T08:07:54-07:00
by petzi69
Yes, thanks you. The problem is not the shadow, I just don't understand how to select the non-transparent part

Re: Another BMP transparency issue

Posted: 2016-10-29T08:32:57-07:00
by snibgo
petzi69 wrote:The problem is not the shadow, I just don't understand how to select the non-transparent part
Why do you want to "select the non-transparent part"? What does that mean?

If the link I showed you doesn't give what you want, please supply an input image that you want a shadow to.

Re: Another BMP transparency issue

Posted: 2016-10-29T09:25:09-07:00
by petzi69
You are to kind. Please forgive me to be so noob!

The image I like to add shadows is this: Image

Since it's a BMP, the transparent parts are not shown in the browser. It seems that at least my firefox can't handle bmp transparency. Never mind, the image is not supossed to be used on the web.

Re: Another BMP transparency issue

Posted: 2016-10-29T09:56:09-07:00
by fmw42
try

Code: Select all

magick temp.bmp ^
( -clone 0 -background black -shadow 80x3+3+3 ) ^
-background none -layers merge +repage ^
-define bmp3:alpha=true ^
BMP3:result.bmp

Re: Another BMP transparency issue

Posted: 2016-10-29T10:23:10-07:00
by petzi69
I tested the settings as proposed, but changed after a first test to -shadow -shadow 50x1+1+1
Image
Two unexpected things happend: the new image is sized 103x50 pixel instead of 99x46, and the whole image looks much darker now. Just to mention both effects were stronger with the initial settings. Any ideas?

Re: Another BMP transparency issue

Posted: 2016-10-29T10:25:03-07:00
by fmw42
-shadow always increases the image size on the left and bottom, so you would have to crop back to the original size. I am not sure why it is darker. My guess is that your tank image is partially transparent everywhere. Let me check.

Re: Another BMP transparency issue

Posted: 2016-10-29T10:41:12-07:00
by fmw42
In my opinion, this is a bug in -shadow. If I use a red background, the whole tank becomes red. I do not think this should happen. I will report the bug. It also happens with a png input and output.

Re: Another BMP transparency issue

Posted: 2016-10-29T10:49:17-07:00
by fmw42
Not a bug. My mistake. I forgot the +swap. Try

Code: Select all

magick temp.bmp ^
( -clone 0 -background black -shadow 80x3+3+3 ) ^
+swap -background none -layers merge +repage ^
-define bmp3:alpha=true ^
BMP3:result.bmp

Re: Another BMP transparency issue

Posted: 2016-10-29T12:28:53-07:00
by petzi69

Code: Select all

temp.bmp ( -clone 0 -background black -shadow 80x1+1+1 ) ^
+swap -background none -layers merge +repage ^
-crop 99x46+0+0 -define bmp3:alpha=true BMP3:result.bmp

That's the magic formula! Now I run some hundred images through my batch process :)! Thank you very much!

Image