Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
nm-osm
Posts: 6 Joined: 2015-04-21T03:11:23-07:00
Authentication code: 6789
Post
by nm-osm » 2015-04-21T03:37:33-07:00
The PNG has 31 colors as reported from totalColors(). My code is:
Code: Select all
// img has a type with const char *data() and size_t length()
Magick::Blob inblob( img.data(), img.length() );
Magick::Image image;
image.read( inblob );
image.compressType( MagickCore::NoCompression );
image.type( MagickCore::PaletteType );
image.colorMapSize( 256 );
Magick::Blob outblob;
image.write( &outblob, "bmp3" );
The resulting image is barely visible, the colors are reduced to a dark grey. The CLI-tool convert works OK.
$ convert x.png -type Palette -depth 8 -compress none bmp3:x.bmp
I have tried with various combinations of
image.quantizeColors( 256 )
image.depth( 8 )
image.depth( 24 )
image.classType( MagickCore::DirectClass )
image.classType( MagickCore::PseudoClass )
image.colorSpace( MagickCore::sRGBColorspace )
image.colorspaceType( MagickCore::sRGBColorspace )
image.quantize()
Has anyone an idea how to transfer the 31 colors from the PNR into the colormap with fidelity?
TIA
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2015-04-21T09:28:25-07:00
I would suggest you provide your version of IM and platform and also post your PNG image so others can test using the command line.
nm-osm
Posts: 6 Joined: 2015-04-21T03:11:23-07:00
Authentication code: 6789
Post
by nm-osm » 2015-04-22T08:55:31-07:00
The version is ImageMagick-6.9.1-1, platform is SUSE Linux Enterprise Server 11.
How do I post an image? I have seen images posted by others but not found a way to do it myself
. There is no button to add an attachment.
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2015-04-22T12:31:31-07:00
You must post to some free service such as dropbox.com and then put the URL here.
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2015-04-29T08:50:22-07:00
This seems to work for me on IM 6.9.1.3 Q16 Mac OSX in the command line.
Note your png file has a totally opaque alpha channel which I removed.
Code: Select all
convert 17310395011_f1a497f25f_o.png -alpha off -type palette BMP3:17310395011_f1a497f25f_o.bmp
Sorry, I do not know the Magick++ API equivalent.
nm-osm
Posts: 6 Joined: 2015-04-21T03:11:23-07:00
Authentication code: 6789
Post
by nm-osm » 2015-04-29T09:03:49-07:00
As I wrote it's works for me on the command-line too. The problem is with the C++-API.
nm-osm
Posts: 6 Joined: 2015-04-21T03:11:23-07:00
Authentication code: 6789
Post
by nm-osm » 2015-05-12T03:35:43-07:00
We have ceased to use IM for this -> problem solved.
cuongvn08
Posts: 6 Joined: 2017-01-09T23:50:54-07:00
Authentication code: 1151
Post
by cuongvn08 » 2017-01-10T19:38:53-07:00
nm-osm wrote: ↑ 2015-05-12T03:35:43-07:00
We have ceased to use IM for this -> problem solved.
I also have same problem as your issue. I would like to convert the original image to 8-bit palette bmp.
I am thinking to stop using IM and change to another library. My programming platform is Ubuntu, php.
So what is the library you are using now?
And how can you fix this issue.
Thanks.
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2017-01-10T20:23:43-07:00
If it works from the command line, then there should be an equivalent for Magick++. Did you try prefacing your output image with BMP3:output.bmp? Sorry, I do not know Magick++, but someone should be able to help.
nm-osm
Posts: 6 Joined: 2015-04-21T03:11:23-07:00
Authentication code: 6789
Post
by nm-osm » 2017-01-11T01:51:42-07:00
cuongvn08 wrote: ↑ 2017-01-10T19:38:53-07:00
So what is the library you are using now?
Sorry, no library. We convert the pictures with an external script before the c++ program has to handle them.