BitBlt Bitmaps
Interactive BitBlt raster operation tool. Apply all 16 Boolean ROP codes to bitmaps with real-time pixel-level bit block transfer visualization.
About
BitBlt (Bit Block Transfer) is the foundational raster operation behind every graphics system from GDI to modern compositors. It copies a rectangular block of pixels from a source bitmap to a destination bitmap, combining them through one of 16 Boolean raster operation codes (ROPs) derived from the two-input truth table of source pixel S and destination pixel D. Getting the wrong ROP code in driver-level graphics code produces corrupted display output, invisible sprites, or inverted UI elements that are notoriously difficult to debug. This tool performs actual pixel-level BitBlt on real image data using Uint32Array buffer manipulation. It does not simulate the operation. It applies the selected Boolean function to every pixel in the transfer region. Note: operations treat each color channel independently as an 8-bit value. Alpha is preserved from the destination unless SRCCOPY is used.
Formulas
BitBlt operates on a rectangular region defined by position (x, y) and dimensions (w, h). For each pixel at coordinate (i, j) within the region, the output pixel value R is computed per-channel from the source pixel S and destination pixel D using the selected Boolean function f.
The 16 possible Boolean functions arise from the 2-input truth table. Each ROP code k (0 - 15) encodes which of the 4 input combinations produces a 1 bit.
Per-channel application uses bitwise operators on 8-bit unsigned integer values. For example, SRCINVERT (ROP 6, XOR):
Where Rc is the result channel value, Sc is the source channel value, Dc is the destination channel value, c is the color channel index (Red, Green, Blue), k is the ROP code (0 - 15), and f is the Boolean combination function selected by k.
Reference Data
| ROP Code | Name | Boolean Formula | Hex Code | Effect Description |
|---|---|---|---|---|
| 0 | BLACKNESS | 0 | 0x000042 | Fills destination with black |
| 1 | DPSon (NOR) | ¬(S ∨ D) | 0x000289 | NOR of source and destination |
| 2 | DPSna | D ∧ ¬S | 0x000C89 | Destination AND NOT source |
| 3 | NOTSRCCOPY | ¬S | 0x330008 | Inverted copy of source |
| 4 | SRCERASE | S ∧ ¬D | 0x440328 | Source AND NOT destination |
| 5 | DSTINVERT | ¬D | 0x550009 | Inverts destination pixels |
| 6 | SRCINVERT (XOR) | S ⊕ D | 0x660046 | XOR blend - classic sprite trick |
| 7 | DSPna (NAND) | ¬(S ∧ D) | 0x7700E6 | NAND of source and destination |
| 8 | SRCAND | S ∧ D | 0x8800C6 | AND blend - darkening mask |
| 9 | DSPnx (XNOR) | ¬(S ⊕ D) | 0x990066 | XNOR - pixels match = white |
| 10 | D (NOP) | D | 0xAA0029 | No operation - destination unchanged |
| 11 | MERGEPAINT | ¬S ∨ D | 0xBB0226 | NOT source OR destination |
| 12 | SRCCOPY | S | 0xCC0020 | Direct copy - most common BitBlt |
| 13 | SDPno | S ∨ ¬D | 0xDD0228 | Source OR NOT destination |
| 14 | SRCPAINT (OR) | S ∨ D | 0xEE0086 | OR blend - lightening merge |
| 15 | WHITENESS | 1 | 0xFF0062 | Fills destination with white |