How do I invert the colormap (1bpp bmp)?

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
gohanman
Posts: 3
Joined: 2011-09-16T07:22:19-07:00
Authentication code: 8675308

How do I invert the colormap (1bpp bmp)?

Post by gohanman »

I'm trying to convert 8bpp bitmaps to 1bpp for use with a receipt printer. I can get the correct depth thusly:

Code: Select all

convert -monochrome -colors 2 -depth 1 source.bmp out.bmp
However, this gives me a colormap where 0 => black and 1 => white. The printer, stupidly, ignores the palette in the file and assumes 1 is black. Is there any way to either invert the colormap in the 1bpp file, or explicitly define the colormap during conversion from 8bpp to 1bpp?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How do I invert the colormap (1bpp bmp)?

Post by fmw42 »

What about just inverting the colors?

convert -monochrome -colors 2 -depth 1 -negate source.bmp out.bmp
gohanman
Posts: 3
Joined: 2011-09-16T07:22:19-07:00
Authentication code: 8675308

Re: How do I invert the colormap (1bpp bmp)?

Post by gohanman »

Negate actually inverts the colormap as well as the pixels - so the print out doesn't change, unfortunately. I want to switch just the pixels OR just the colormap, not both.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How do I invert the colormap (1bpp bmp)?

Post by fmw42 »

try converting to tiff, then set the min is white or black flag to swap that and then convert to bmp. see http://www.imagemagick.org/Usage/formats/#tiff


toggle the photometric interpretation (Added IM 6.3.2-10)
-define quantum:polarity=min-is-black
-define quantum:polarity=min-is-white

Also note that proper IM 6 syntax generally has the input image right after convert, except for things like controls for vector to raster format, such a colorspace and density. see http://www.imagemagick.org/Usage/basics/#why
nerdx86
Posts: 4
Joined: 2012-05-01T08:28:52-07:00
Authentication code: 13

Re: How do I invert the colormap (1bpp bmp)?

Post by nerdx86 »

Are you using a foxjet or similar monochrome printhead?

I played with this and I found that -remap test.bmp, where test.bmp has the right palette works well..
Post Reply