Page 1 of 1

Create a 8 bit image from scratch

Posted: 2009-09-13T09:02:00-07:00
by magick_user
Hi all,
can anyone tell me how can i create a 8 bit image from scratch, or to convert an existing 24 bit image to 8 bit and 1 bit?
I use follow code, but the image created is always 24 bit:

Code: Select all

::Magick::Image *img = new Magick::Image("2550x3300","white");			
img->depth(8);
img->write("c:/image_magick.bmp");	
Any help will be appreciated.
Best regards.

Re: Create a 8 bit image from scratch

Posted: 2009-09-13T11:22:17-07:00
by Bonzo
You only posted this about 2 hours ago and its a weekend - some people ( obviously not me or you ) have a life outside the forum.

Re: Create a 8 bit image from scratch

Posted: 2009-09-14T01:25:48-07:00
by magick_user
Anyone can help me?

Re: Create a 8 bit image from scratch

Posted: 2009-09-14T06:26:19-07:00
by magick
Add img->Quantize(256) to create a 8-bit colormapped image.

Re: Create a 8 bit image from scratch

Posted: 2009-09-14T07:56:26-07:00
by magick_user
with:

Code: Select all

::Magick::Image *img = new Magick::Image("2550x3300","white");
img->quantize(256);
img->depth(8);
img->write("c:/magick_image.bmp");
it create a 1 bit white image, not 8 bit.

Re: Create a 8 bit image from scratch

Posted: 2009-09-14T08:22:59-07:00
by magick_user
Solved in this way: by default, perhaps, the library uses some comrpession type in order to optimization.
with:
img->compressType(MagickCore::NoCompression);
it saves correct bit depth image.
Tank you
Best regards