Binary image (1 bit per pixel) c++ API

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
bronstein87
Posts: 5
Joined: 2017-01-14T21:56:44-07:00
Authentication code: 1151

Binary image (1 bit per pixel) c++ API

Post by bronstein87 »

Is there an opportunity to construct binary (1bit) images and convert other images to this format using c++ api? I coudnt find any information about this.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Binary image (1 bit per pixel) c++ API

Post by fmw42 »

I do not program in C++, but see depth and monochrome at https://www.imagemagick.org/Magick++/Image++.html
bronstein87
Posts: 5
Joined: 2017-01-14T21:56:44-07:00
Authentication code: 1151

Re: Binary image (1 bit per pixel) c++ API

Post by bronstein87 »

fmw42 wrote: 2017-01-14T22:36:20-07:00 I do not program in C++, but see depth and monochrome at https://www.imagemagick.org/Magick++/Image++.html
I have already seen that and If I correctly understand, depth can be only from 8 to 32 bit, and what about monochrome(), it looks like grayscale transform, so I need exact answer
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Binary image (1 bit per pixel) c++ API

Post by fmw42 »

depth can be 1 if the output file format supports it

monochrome converts to black/white (1-bit)

See http://www.imagemagick.org/script/comma ... monochrome

You can also use the equivalent of -type bilevel

Or you can use the equivalent of -threshold to convert to 1-bit result.

All these depend upon whether the image format supports 1-bit; otherwise, though it is only black and white, the type will show as either grayscale or palette.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Binary image (1 bit per pixel) c++ API

Post by snibgo »

bronstein87 wrote:Is there an opportunity to construct binary (1bit) images and convert other images to this format using c++ api? ... so I need exact answer
But the question is vague.

Images can be saved in files that are one bit per pixel, and read from those files.

Images can be processed as black and white only, or as grayscale, or as colour.

When processing an image, it is stored in memory as either palette or non-palette. For non-palette processing, the minimum storage is 8 bits/channel/pixel. The processing might use only two of the possible 256 values.
snibgo's IM pages: im.snibgo.com
bronstein87
Posts: 5
Joined: 2017-01-14T21:56:44-07:00
Authentication code: 1151

Re: Binary image (1 bit per pixel) c++ API

Post by bronstein87 »

fmw42 wrote: 2017-01-15T00:14:17-07:00 depth can be 1 if the output file format supports it

monochrome converts to black/white (1-bit)

See http://www.imagemagick.org/script/comma ... monochrome

You can also use the equivalent of -type bilevel

Or you can use the equivalent of -threshold to convert to 1-bit result.

All these depend upon whether the image format supports 1-bit; otherwise, though it is only black and white, the type will show as either grayscale or palette.
Ok, I will try, thank you. But, I probably incorrectly expressed, I talking about pixel format, not image. Look at this link: http://doc.qt.io/qt-4.8/qimage.html#Format-enum. So, I am talking about creating image with some pixel format, not image.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Binary image (1 bit per pixel) c++ API

Post by fmw42 »

I do not know to what in that reference you are considering. IM has many image out data types that range from 32-bits per pixel total color for all channels, to 1-bit per pixel total color for all channels. Most images are 8-bits per channel per pixel, but you can have 1-bit for only 1 channel per pixel (binary black/white data)
Post Reply