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.
U8g2 constructors used
| Display | Full buffer constructor | Page buffer constructor (Uno) |
|---|---|---|
| 0.96" SSD1306 128x64 | U8G2_SSD1306_128X64_NONAME_F_HW_I2C | U8G2_SSD1306_128X64_NONAME_1_HW_I2C |
| 1.3" SH1106 128x64 | U8G2_SH1106_128X64_NONAME_F_HW_I2C | U8G2_SH1106_128X64_NONAME_1_HW_I2C |
| 0.91" SSD1306 128x32 | U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C | U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C |
| 1.5" SH1107 128x128 | U8G2_SH1107_128X128_F_HW_I2C | U8G2_SH1107_128X128_2_HW_I2C |
| 1.5" SSD1327 128x128 | U8G2_SSD1327_WS_128X128_F_HW_I2C | U8G2_SSD1327_WS_128X128_2_HW_I2C |
| 0.66" SSD1306 64x48 | U8G2_SSD1306_64X48_ER_F_HW_I2C | U8G2_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
- OLED Troubleshooting Hub: Fix Scrambled, Mirrored, Shifted or Blank Displays
- How to Display an Image on an SSD1306 OLED with Arduino
- image2cpp Alternative, Compared Honestly
- Smaller Than a Bitmap: Vector Drawing Code Shrinks OLED Flash
- Adafruit GFX vs U8g2: Which OLED Library Should You Use?
- SH1106 vs SSD1306: Which OLED Do You Actually Have?
More OLED converters
- OLED Bitmap Converter - Full conversion tool for static images, logos, and vector code
- GIF to OLED Animation - Split animated GIFs into frames with millis() timing
- SSD1306 Bitmap Generator - Adafruit GFX drawBitmap code for 0.96" and 0.91" displays