Page 1 of 1
Magick++ how to read bitmap 256 color, convert to RGBA
Posted: 2019-07-23T09:48:36-07:00
by axisofevil
Hi all,
[ somewhat new to IM ]
I need to read in various bitmaps ( 256 color, 16 , mono ) and convert to RGBA programmatically. I have code which works for converting jpeg, png, tiff, and 24 bit per pixel bitmaps; all that code does is pass a filename to image constructor then write out RGBA, but I'm thinking there's more to it for palletized bitmaps as I've had various artifacts with those. I started down a road using blob in the constructor but can't understand how palette gets into IM. Thanks, dB
Using version 7.0.8
Re: Magick++ how to read bitmap 256 color, convert to RGBA
Posted: 2019-07-23T10:49:22-07:00
by snibgo
wrote:... and convert to RGBA programmatically.
What does that mean? What is your output format, eg PNG, TIFF or what?
Re: Magick++ how to read bitmap 256 color, convert to RGBA
Posted: 2019-07-23T11:10:22-07:00
by axisofevil
output is *.rgba. The 256 bitmap actually looks correct, the 16 is rendered at quarter size - twice - in the upper half of the expected area, the bottom half is some noise pattern. The mono bitmap renders as a thin band across the top of the expected area.
Re: Magick++ how to read bitmap 256 color, convert to RGBA
Posted: 2019-07-23T11:26:55-07:00
by snibgo
The round-trip to and from rgba works fine at the command line, eg:
Code: Select all
f:\web\im>%IMG7%magick toes.png x.rgba
f:\web\im>%IMG7%magick -size 267x233 x.rgba t.png
t.png is identical to toes.png.
I suspect you are doing some weird processing. If you post your code, perhaps we can comment further.
Re: Magick++ how to read bitmap 256 color, convert to RGBA
Posted: 2019-07-23T13:31:29-07:00
by axisofevil
I'll reiterate:
1) Not using command line
2) Problem to be solved is reading in bitmaps, i.e. *.bmp
3) Current code is completely basic - image read in filename.* where * is jpg. png, etc, then write filename.rgba.
4) Code works for jpg. png, tiff, and 24 BPP bitmap files
Problem was with bitmap-16.bmp in here, then I'll try to get bitmap-mono.bmp working.
https://www.dropbox.com/s/f1x6ynahf88o7 ... s.zip?dl=0
It looks like this:
https://www.dropbox.com/s/7ecr6j0jv4jnq ... 9.jpg?dl=0
Re: Magick++ how to read bitmap 256 color, convert to RGBA
Posted: 2019-07-23T16:19:47-07:00
by snibgo
Your output file is very different to the input bitmap-16.bmp. The input has five shapes and a white background. The output also has a grid target and some pens or something in the bottom-right corner.
That output didn't come from that input.
At the command line, we can convert bitmap-16.bmp to 8-bit ("-depth 8") x.rgba, and convert that to PNG, and the result is as expected. Yes, I know you don't use the command line, but I suppose your program is doing something different.
bitmap-16.bmp has 960x540 pixels. With 4 channels, 1 byte/channel/pixel, the RGBA filesize should be 2073600 bytes. Is that your filesize?
EDIT to add: If it isn't, then perhaps you haven't set the depth to 8. Then you write 4 bits/channel/pixel, but your reader probably expects 8 bits/channel/pixel.
Re: Magick++ how to read bitmap 256 color, convert to RGBA
Posted: 2019-07-24T12:35:00-07:00
by axisofevil
Thanks - I have it working using depth 8. File sizes are the expected 2,073,600.
I believe I had some other system related issues - nfs/overlays - which had inhibited the correct file from being used.