Create a 8 bit image from scratch

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
magick_user

Create a 8 bit image from scratch

Post 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.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Create a 8 bit image from scratch

Post 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.
magick_user

Re: Create a 8 bit image from scratch

Post by magick_user »

Anyone can help me?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Create a 8 bit image from scratch

Post by magick »

Add img->Quantize(256) to create a 8-bit colormapped image.
magick_user

Re: Create a 8 bit image from scratch

Post 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.
magick_user

Re: Create a 8 bit image from scratch

Post 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
Post Reply