β Bitmap Invert
Swap black and white on a bitmap
- BITMAP
- BITMAP
Bitmap Invert does exactly one thing: swaps white and black. Every white pixel becomes black, every black pixel becomes white, and the bitmap comes out flipped. It's the simplest node in the whole Dream Painter pack - and one of the most quietly useful, because polarity is a problem you will hit constantly.
The issue is that "background" and "foreground" are conventions, not facts. Dream Painter draws shapes white on black by default, and its converters map blackβcolor_0, whiteβcolor_1. But the moment you start mixing sources - an image you thresholded, a mask from another pack, a ControlNet that expects dark lines on light - the convention can be backwards from what you need. Invert is the one-node fix: no resampling, no quality loss, just a flip.
How it works
Under the hood it's Pillow's ImageChops.invert on the one-bit image, which is a per-pixel bitwise NOT. 1 becomes 0, 0 becomes 1. There's no threshold involved and nothing approximate about it - the output is the exact mirror of the input, same size, same everything except the color of every pixel.
Where this earns its keep:
- ControlNet polarity. Some preprocessors and models read dark-on-light differently than light-on-dark. If your lineart guide comes out backwards, invert before the ControlNet.
- Mask inversion. The pack's Bitmap To Image & Mask hands you both an IMAGE and a MASK, and mask semantics are notoriously easy to get backwards in ComfyUI (1 = kept region, but which region is "kept" depends on the tool). Invert is the fast way to flip which region a mask covers.
Inputs and outputs
- BITMAP - the bitmap to invert.
Output:
- BITMAP - the inverted bitmap.
In the butterfly example workflow you can see it used in exactly this role: inverting a mask so a negative space becomes positive. It's the kind of node you reach for when a result is "almost right but backwards," which is most of the time in bitmap land.
Installing
From the Dream Painter pack (comfyui-dream-painter, alt-key-project). ComfyUI Manager β Install Custom Nodes β search Dream Painter β install β restart. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/alt-key-project/comfyui-dream-painter
cd comfyui-dream-painter
pip install -r requirements.txt
No models, no downloads.
Common issues
The only real trap is applying it twice and forgetting you did. Invert is its own inverse, so an inverted inverted bitmap is the original - if you're chasing a polarity problem and nothing changes, check whether there's an Invert hiding upstream of the thing you're looking at. And remember it only operates on bitmaps: if you're working with a grayscale MASK tensor from another pack, you'll want ComfyUI's own invert-mask node instead of this one.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| BITMAP | BITMAP | β |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| BITMAP | BITMAP | β |