Page 2 of 2

Re: Convert a 32-bit ARGB BMP to PNG

Posted: 2010-03-26T20:22:32-07:00
by snibgo
I've had success reading V3 ARGB uncompressed files as raw bytes. I've forgotten the syntax, but you tell IM the header size and dimensions, and away it goes.

Re: Convert a 32-bit ARGB BMP to PNG

Posted: 2010-03-26T20:25:49-07:00
by gnuwtey
fmw42 wrote:You can change the white to transparent
meh, guess I'll have to do that for now.

Re: Convert a 32-bit ARGB BMP to PNG

Posted: 2010-03-26T20:37:23-07:00
by gnuwtey
Actually, an even better solution to this problem would be to simply cut the large image I had into its smaller 16 x 16 tiles, which is what I did this for in the first place. Now that I know ImageMagick exists, I'm trying to find something that will do that.

Re: Convert a 32-bit ARGB BMP to PNG

Posted: 2010-03-26T20:42:03-07:00
by fmw42

Re: Convert a 32-bit ARGB BMP to PNG

Posted: 2010-03-26T20:51:28-07:00
by gnuwtey
Well, I already found those, but thanks anyway...

Re: Convert a 32-bit ARGB BMP to PNG

Posted: 2010-03-26T21:08:32-07:00
by fmw42
Does that not do what you want? If not, please explain and perhaps we can help further.

Re: Convert a 32-bit ARGB BMP to PNG

Posted: 2010-03-27T17:10:14-07:00
by gnuwtey
fmw42 wrote:Does that not do what you want? If not, please explain and perhaps we can help further.
No, no, as in, I had already found those myself, and they did what I wanted them to do. Thanks for it anyway.

Re: Convert a 32-bit ARGB BMP to PNG

Posted: 2010-09-23T00:56:21-07:00
by mammadori
Since I was caught with a ton of images in this format and since gimp (which handles those alpha bmp format) scripting isn't easy as using imagemagick, I find my way with dd by skipping the header and then treating the image like a raw rgba.

bmp needs to be flipped, I also needed to invert blue with red, so I used a recolor matrix to do that.

It is a bit hackish, but it worked for me.

Code: Select all

#!/bin/sh

MATRIX='0 0 1 0
        0 1 0 0
        1 0 0 0
        0 0 0 1'

IN_IMG="$1"
BASENAME="${IN_IMG%.*}"
RGBAIMG="${BASENAME}.rgba"
OUT_IMG="${BASENAME}.png"
HEADER_SIZE=54

width=$(identify -format "%w" "${IN_IMG}")
height=$(identify -format "%h" "${IN_IMG}")

dd if="${IN_IMG}" of="${RGBAIMG}" bs="${HEADER_SIZE}" skip=1

convert -size ${width}x${height} -depth 8 -flip "${RGBAIMG}" -recolor "${MATRIX}" "${OUT_IMG}"