Re: Issue using an Image to resize a 1-bit (two colour) mask in DIB format

Bob Friesenhahn <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.help
Message-ID <[email protected]>
On Mon, 11 Jul 2016, Julian Male wrote:

> Hi,
>
> We are using DIBs as an internal format. I am using GraphicsMagick v1.3.19.
>
> My issue occurs when I try to resize a 1-bit mask DIB, when I write it back out to a DIB it has become an 8-bit image with multiple colours.
>
> Debugging through the source would seem to suggest that the GM internal image is ok upto the point the image.write( blob) function is called.
>
> Any ideas ?

I think that you are on the right path.  If the image is PseudoClass 
and tests (based on current colormap) to be monochrome, then it should 
be saved as one bit.

To accomplish what you need, this should work:

   image.type(Magick::BilevelType);

This would replace your existing lines:

   image.monochrome(true);
   image.classType( PseudoClass );
   image.depth(1);

You can test this from the command line like

   gm convert infile.bmp -type Bilevel outfile.dib

It seems that the logic for selecting the DIB subformat could be a 
little more user-friendly.  DIB is usually only used within 
applications or embedded within other formats (e.g. WMF) and is not 
normally stored as its own file.

Bob

-- 
Bob Friesenhahn
[email protected], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/

------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.