u8g2 Bitmap Converter — Image to u8g2 XBM Array

Convert any PNG, JPG or BMP into a paste-ready u8g2 bitmap byte array for SSD1306, SH1106 and other monochrome OLED/LCD displays. XBM byte order, drawXBMP()-ready, 4 dithering algorithms — 100% in your browser.

1
Step 1

Upload Your Image

PNG · JPG · BMP · GIF
📷

Click or drag & drop to upload

Tip: high-contrast art dithers cleanest

2
Step 2

Preview

🖼Upload an image to see the live preview
3
Step 3

Generate u8g2 Array

This u8g2 bitmap converter turns any image into a paste-ready XBM byte array for the u8g2 library — the de-facto standard graphics library for monochrome OLED and LCD displays on Arduino, ESP32, ESP8266 and RP2040. Drop in a PNG, JPG or BMP, match the canvas to your screen, and copy a static const unsigned char array you can render with u8g2.drawXBMP() in seconds. It is the missing companion to the classic image2cpp converter, tuned specifically for u8g2's XBM byte order.

What is u8g2 and why XBM byte order matters

u8g2 (by olikraus) is a full-featured monochrome graphics library that drives almost every 1-bit display a maker is likely to use: SSD1306 and SH1106 OLEDs (128×64 and 128×32), ST7565/ST7567 LCDs, the Nokia 5110 (PCD8544), and dozens more. Its drawXBMP() function expects bitmap data in the X BitMap (XBM) format, where the bits inside each byte are packed least-significant-bit first and every row is padded out to a whole number of bytes. This converter emits exactly that layout, so the image you see in the preview is the image u8g2 draws — no mirrored 8-pixel blocks, no off-by-one row shifts.

If you have ever pasted an array from a generic tool into u8g2 and watched it render as garbled vertical stripes, the cause is almost always a byte-order mismatch. Generic Adafruit-GFX-style arrays are MSB-first; u8g2's drawXBMP() is LSB-first. Toggle the Swap bits option here if your particular u8g2 build or a hand-edited array expects the opposite order.

Wiring an SSD1306 OLED for u8g2 (I2C)

The most common u8g2 target is a 0.96" SSD1306 OLED over I2C. Wire it to an Arduino Uno/Nano like this:

Install U8g2 from the Arduino Library Manager (Sketch → Include Library → Manage Libraries → search "U8g2"). The library bundles every display constructor, so you only pick the one matching your panel.

Full Arduino sketch — display your bitmap with u8g2

Generate your array above, then drop it into this skeleton. Replace myBitmap with the variable name you chose:

#include <U8g2lib.h>
#include <Wire.h>

// Full-buffer constructor for a 128x64 SSD1306 on I2C
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE);

// <-- paste the generated bitmap array here -->

void setup() {
  u8g2.begin();
}

void loop() {
  u8g2.clearBuffer();
  u8g2.drawXBMP(0, 0, myBitmap_width, myBitmap_height, myBitmap);
  u8g2.sendBuffer();
  delay(2000);
}

On a memory-constrained AVR board, the U8X8_PROGMEM qualifier (already added to the generated array) keeps the bitmap in flash so it does not eat your 2 KB of SRAM. On ESP32, ESP8266 and RP2040 the array is stored in flash automatically. If you have many large bitmaps and run low on flash, consider the page-buffer constructors (the 1 or 2 variants instead of F) to trade RAM for draw passes.

Choosing a dithering algorithm

Monochrome OLEDs can only show pixels fully on or off, so converting a photo or gradient requires dithering — scattering black and white dots to simulate grey. Floyd-Steinberg (the default) gives the most faithful result for photos. Atkinson produces a cleaner, higher-contrast look favoured for logos and UI icons. Bayer 4×4 gives a retro, regular cross-hatch. Binary threshold does no dithering at all — ideal for line art, fonts and one-colour logos. Adjust the threshold slider to push more pixels on or off.

Need the Adafruit GFX flavour instead, or color/RGB565 output for a TFT? Use the full image2cpp converter. Building an LVGL UI on an ESP32? Try the LVGL image converter. Driving a Waveshare e-ink panel? See the e-paper converter.

Frequently Asked Questions

What is a u8g2 bitmap converter? +
A u8g2 bitmap converter turns an image (PNG, JPG, BMP) into a C/C++ byte array you can draw with the u8g2 library on monochrome OLED and LCD displays. u8g2 (by olikraus) is the most popular Arduino/ESP32 graphics library for SSD1306, SH1106, ST7565 and similar 1-bit screens. This tool generates an XBM-style array compatible with u8g2.drawXBMP().
How do I draw the bitmap with u8g2? +
Paste the generated array into your sketch, then in your draw loop call u8g2.drawXBMP(x, y, width, height, bitmap_name); inside a u8g2.firstPage()/nextPage() loop or after u8g2.clearBuffer()/u8g2.sendBuffer(). The width and height are printed in the comment above the array.
What is the difference between drawXBMP and drawBitmap in u8g2? +
drawXBMP() reads bytes in XBM order — bits are packed least-significant-bit-first (LSB first) within each byte, which matches the XBM file format and the output of this converter. drawBitmap() in u8g2 expects MSB-first packing. If your image looks mirrored within each 8-pixel block, switch between the XBM and MSB output using the Swap bits option.
Does u8g2 store the bitmap in flash (PROGMEM)? +
Yes. On AVR boards (Arduino Uno/Nano) add the U8X8_PROGMEM / static const unsigned char ... U8X8_PROGMEM qualifier so the array lives in flash, not the tiny 2 KB RAM. On ESP32/ESP8266/RP2040 a plain const array is already stored in flash. This converter emits a const array ready for both.
Is the u8g2 converter free and private? +
Yes. It runs 100% in your browser using the Canvas API. Your image is never uploaded to any server. There is no signup, no watermark, and no limit on the number of conversions.
Which displays work with u8g2 bitmaps? +
Any 1-bit monochrome display u8g2 supports: SSD1306 and SH1106 OLEDs (128x64, 128x32), ST7565/ST7567 LCDs, Nokia 5110 (PCD8544), SSD1325/SSD1327 grayscale OLEDs, and many more. Set the canvas size to match your display resolution before generating.

More embedded converters

Image to C++ Converter
The classic image2cpp — SSD1306, ST7735, Adafruit GFX & u8g2 byte arrays.
LVGL Image Converter
Image to LVGL lv_img_dsc_t C array for ESP32 GUIs.
E-Paper Image Converter
Image to Waveshare e-paper byte array, incl. black/white/red 3-color.
Adafruit GFX Font Converter
Convert a font to an Adafruit GFX font header (.h) in your browser.
Developer Calculators ↗
Bit/byte, hex, base, color & sizing calculators for embedded work.
JSON & Dev Tools ↗
Format, validate & convert JSON, CSV, base64 and more — 15 tools.