Home

U8g2 Image Converter (XBM)

Convert images to U8g2 drawXBMP code for SSD1306, SH1106, SH1107 & SSD1327 displays - no upload, no signup.

Guide

U8g2 draws images with drawXBMP(), which uses the XBM format: rows of bytes where the leftmost pixel is in the lowest bit. That is the opposite of Adafruit's drawBitmap, which is why pasted arrays often look mirrored. This converter outputs correct XBM arrays - or smaller drawBox / drawLine code - with the right U8g2 constructor for your display, from SSD1306 and SH1106 to SH1107 and SSD1327. On boards with little RAM, such as an Arduino Uno with a 128x128 screen, it switches to the page-buffer version and a firstPage() / nextPage() loop, so you do not have to work out the constructor yourself. Paste an Adafruit or image2cpp array, choose U8g2, and it will be rewritten as XBM for you.

ESP32 Flash Check

Rectangles: 3486 B · Rects + lines: 2906 B · Run-length: 3030 B · Bitmap: 4096 B

Uses 0.2% of the ESP32's 1.25 MB app space flash. Sizes are image data plus any extra drawing code each method needs (measured on Arduino Uno; the display library itself is not counted). ✓ Output checked pixel-for-pixel against your bitmap.

As bitmap 4,096 B 8 × 64x64
Rects + lines (auto) 2,906 B 308 rects + 292 lines · incl. ~470 B code
Memory saved
1,190 B 29.1%

Input Bitmap Code

ESP32

Arduino code (.ino .h .c .cpp .xbm), images (PNG JPG BMP WebP) or an animated GIF. Select several images to make an animation, or drop files here.

Image size (px)
×
Position on screen
X Y

OLED Live Preview

0 Frames
0.96" 128x64 SSD1306
FPS: 15 I2C 0x3C
Playback
15 FPS
Frames Frame 0 / 0
No frames yet

Arduino Code

// Paste bitmap code and press Convert.

Images and animations for the U8g2 library

U8g2 draws images with drawXBMP(), which uses the XBM format: rows of bytes where the leftmost pixel is in the lowest bit. That is the opposite of Adafruit's drawBitmap, which is why pasted arrays often look mirrored. This converter outputs correct XBM arrays, or smaller drawBox / drawLine code, with the right U8g2 constructor for your display.

Diagram comparing U8g2 XBM least-significant-bit-first byte order with Adafruit most-significant-bit-first order
Bit order comparison: Adafruit drawBitmap (MSB-first) vs U8g2 drawXBMP (LSB-first).

U8g2 constructors used

DisplayFull buffer constructorPage buffer constructor (Uno)
0.96" SSD1306 128x64U8G2_SSD1306_128X64_NONAME_F_HW_I2CU8G2_SSD1306_128X64_NONAME_1_HW_I2C
1.3" SH1106 128x64U8G2_SH1106_128X64_NONAME_F_HW_I2CU8G2_SH1106_128X64_NONAME_1_HW_I2C
0.91" SSD1306 128x32U8G2_SSD1306_128X32_UNIVISION_F_HW_I2CU8G2_SSD1306_128X32_UNIVISION_1_HW_I2C
1.5" SH1107 128x128U8G2_SH1107_128X128_F_HW_I2CU8G2_SH1107_128X128_2_HW_I2C
1.5" SSD1327 128x128U8G2_SSD1327_WS_128X128_F_HW_I2CU8G2_SSD1327_WS_128X128_2_HW_I2C
0.66" SSD1306 64x48U8G2_SSD1306_64X48_ER_F_HW_I2CU8G2_SSD1306_64X48_ER_1_HW_I2C

On boards with little RAM, such as an Arduino Uno with a 128x128 screen, the converter switches to the page-buffer version and a firstPage() / nextPage() loop.

When should you choose U8g2 over Adafruit?

Comparison Factor Adafruit GFX U8g2 Library Winner
SRAM Consumption (Uno / Nano) Needs 1,024 bytes (50% total RAM) Page mode uses only 128 or 256 bytes U8g2 for Uno/Nano
Built-in Font Variety One built-in 5x7 font plus the FreeFont set Hundreds of fonts in many sizes, some with Unicode U8g2
Multi-Controller Driver Support Requires separate libraries per chip Single unified library for SSD1306, SH1106, SH1107, SSD1327 U8g2
Flash used on an Uno (same 16x16 icon, our compile test) 13,172 bytes 8,378 bytes (full buffer) U8g2
Animation speed Draws into a full screen buffer, then sends it Full buffer (_F_) works the same way; page mode (_1_/_2_) redraws the picture once per strip, which is slower Adafruit or U8g2 _F_

Full flash and RAM measurements, font sizes and a pick for each kind of project are in our Adafruit GFX vs U8g2 guide.

Example: drawXBMP with page mode

u8g2.firstPage();
do {
  u8g2.drawXBMP(0, 0, 128, 64, logo);
} while (u8g2.nextPage());

Caption: Page mode redraws the picture in strips, using only 128 or 256 bytes of RAM instead of the full 1,024-byte buffer - the reason U8g2 suits an Arduino Uno.

Smaller than a bitmap: vector drawing code

A normal OLED bitmap stores every pixel: a full 128x64 screen is always 1,024 bytes. Most OLED graphics are outlines, icons and simple shapes, which take far less space as drawing commands (drawBox, drawLine). Auto mode compares every method and picks the smallest. See full data in our vector code flash guide.

Frequently asked questions

What is an XBM image and why does U8g2 use it?

XBM is a simple 1-bit image format stored as a C array. Each row is padded to whole bytes and the leftmost pixel is the lowest bit. U8g2 reads it from flash with drawXBMP(x, y, width, height, array).

Should I use the U8g2 full buffer or page buffer mode?

Full buffer (_F_) is simplest and fastest but needs width x height / 8 bytes of RAM, 1,024 bytes for 128x64. Page mode (_1_ or _2_) uses only 128 or 256 bytes and redraws the picture in strips, which suits an Arduino Uno.

Can I convert Adafruit or image2cpp arrays to XBM?

Yes. Paste the arrays, choose the U8g2 library and the “Keep as bitmap” method. The converter detects the original format and writes XBM data for drawXBMP.

Does U8g2 work with SH1106 and SSD1327 displays?

Yes. U8g2 supports SSD1306, SH1106, SH1107, SSD1327, and many more controllers. The converter picks the matching constructor when you select your display.

Are my images uploaded to a server?

No. The converter runs entirely in your web browser. Your images, GIFs, and code never leave your computer.

OLED Guides & Tutorials

More OLED converters