Home
OLED Bitmap Converter

Image, GIF or byte array to Arduino code for SSD1306, SH1106 & U8g2 OLED displays

Home / Guides / Adafruit vs U8g2
Library Comparison

Adafruit GFX vs U8g2: Which OLED Library Should You Use?

Short answer: on an Arduino Uno or Nano, U8g2 is usually the better choice. In our compile tests the same sketch used about 4.8 KB less flash, and U8g2's page mode needs only 128 bytes of RAM for the screen. On an ESP32 or ESP8266 either works: pick Adafruit GFX if you follow Adafruit tutorials, and U8g2 if you want lots of fonts or one library for many display chips.

By Bilal Ramzan · Measured 29 October 2026 · Arduino Uno · Arduino AVR compiler (avr-gcc 7.3) · Adafruit SSD1306 2.5.17 + GFX 1.13.0 · U8g2 2.37.1

Adafruit GFX vs U8g2 at a glance

Adafruit SSD1306 + GFXU8g2
Flash, same 16x16 icon sketch (Uno)13,172 bytes (11,698 without the start-up logo)8,378 bytes full buffer, 8,406 bytes page mode
RAM for a 128x64 screen1,024-byte buffer, taken when begin() runs1,024 bytes (_F_), 256 bytes (_2_) or 128 bytes (_1_)
Bitmap formatdrawBitmap: rows of bytes, leftmost pixel in the highest bit (MSB first)drawXBMP: XBM, leftmost pixel in the lowest bit (LSB first)
FontsOne built-in 5x7 font plus 57 font files in its Fonts folderOver 2,000 fonts, counting each character-set version
Display chipsOne library per chip family: Adafruit_SSD1306, Adafruit_SH110X (SH1106, SH1107), Adafruit_SSD1327 and othersOne library for many controllers (91 driver files in version 2.37.1)
How you drawDraw into the buffer, then display.display()clearBuffer() / sendBuffer(), or a firstPage() / nextPage() loop
Help and examplesAdafruit Learn guides and most beginner tutorialsThe U8g2 wiki, with a reference page for every function

Flash and RAM, measured

We compiled the same small sketches with both libraries for an Arduino Uno, using the compiler the Arduino IDE uses. Flash is the "Sketch uses" number; RAM is the "Global variables use" number the IDE prints.

SketchAdafruit SSD1306U8g2 full buffer (_F_)U8g2 page mode (_1_)
16x16 icon13,172 B flash
344 B RAM + 1,024 B at begin()
8,378 B flash
1,556 B RAM
8,406 B flash
660 B RAM
"Hello, OLED!" in a small font
(Adafruit built-in 5x7, U8g2 6x10)
13,136 B flash
358 B RAM + 1,024 B at begin()
9,546 B flash
1,568 B RAM
9,568 B flash
672 B RAM
"Hello, OLED!" in a larger font
(FreeSans 9pt, U8g2 helvR12)
14,962 B flash
358 B RAM + 1,024 B at begin()
10,032 B flash
1,568 B RAM
-

Three things the table shows:

Same image, both libraries

Both libraries store a 1-bit picture as bytes in flash (PROGMEM), and a 128x64 image is 1,024 bytes in both. But they read the bits of each byte in opposite order:

Bit order: Adafruit drawBitmap reads bit 7 as the leftmost pixel, U8g2 drawXBMP reads bit 0 as the leftmost pixel
// Adafruit GFX: horizontal rows, leftmost pixel = highest bit (0x80)
display.drawBitmap(x, y, logo, 128, 64, SSD1306_WHITE);
display.display();

// U8g2: XBM rows, leftmost pixel = lowest bit (0x01). Note the argument order.
u8g2.clearBuffer();
u8g2.drawXBMP(x, y, 128, 64, logo_xbm);
u8g2.sendBuffer();

If you use an array made for the other library, the picture looks mirrored inside every 8-pixel strip. You do not need the original image to fix it: paste the array into OLED Bitmap Converter, choose the other library, and it writes the bytes in the right order. The U8g2 Image Converter does the same from an image.

Speed

On I2C, both libraries send the whole 1,024-byte screen at 400 kHz, which takes about 25-30 ms per full frame, so both top out at roughly 30-40 FPS for full-screen animation. Adafruit GFX and U8g2 full-buffer mode run your drawing code once per frame. U8g2 page mode runs it once per strip, 8 times per frame with _1_ or 4 times with _2_. That costs processor time on a slow board, and is the price of the tiny RAM use.

Which one should you use?

Your projectPickWhy
Arduino Uno or Nano with a full-screen image or animationU8g2About 4.8 KB less flash in our tests leaves room for more frames
Uno or Nano showing "SSD1306 allocation failed"U8g2 page mode (_1_)A 128-byte buffer instead of 1,024 bytes
Menus, readings and lots of textU8g2Hundreds of font designs in many sizes
ESP32, ESP8266 or PicoEitherPlenty of flash and RAM; use the one you know
Following an Adafruit Learn guide or using an Adafruit OLED boardAdafruit GFXYour code will match the guide line by line
1.3" SH1106 moduleEitherAdafruit SH110X or a U8g2 SH1106 constructor; see SH1106 vs SSD1306
1.5" 128x128 SSD1327U8g2 (in this converter)Our converter writes SSD1327 code for U8g2 only
Several different display chips in one projectU8g2One library and one set of functions for all of them

Switching from Adafruit GFX to U8g2

Most drawing functions have a direct match. Both lists below compile for an Arduino Uno.

Adafruit GFXU8g2
display.clearDisplay();u8g2.clearBuffer();
display.display();u8g2.sendBuffer();
display.drawPixel(x, y, SSD1306_WHITE);u8g2.drawPixel(x, y);
display.drawLine(x0, y0, x1, y1, SSD1306_WHITE);u8g2.drawLine(x0, y0, x1, y1);
display.fillRect(x, y, w, h, SSD1306_WHITE);u8g2.drawBox(x, y, w, h);
display.drawRect(x, y, w, h, SSD1306_WHITE);u8g2.drawFrame(x, y, w, h);
display.drawBitmap(x, y, bmp, w, h, SSD1306_WHITE);u8g2.drawXBMP(x, y, w, h, xbm); (convert the bytes to XBM first)
display.setCursor(x, y); display.print("Hi");u8g2.setFont(u8g2_font_6x10_tr); u8g2.drawStr(x, y, "Hi"); (y is the text baseline)
display.setRotation(2);u8g2.setDisplayRotation(U8G2_R2);

Frequently Asked Questions

Is U8g2 better than Adafruit GFX?

Neither is better for everything. On an Arduino Uno, U8g2 used about 4.8 KB less flash than Adafruit SSD1306 in our compile tests, and its page mode needs only 128 bytes of RAM for the screen. Adafruit GFX has simpler code and matches most tutorials. On an ESP32 or ESP8266 either is fine.

Why does my image look wrong after switching from Adafruit to U8g2?

The two libraries read bitmap bytes in opposite bit order: drawBitmap expects the leftmost pixel in the highest bit, drawXBMP in the lowest. The picture looks mirrored in 8-pixel strips. Convert the image again for the library you use, or paste the old array into the converter and choose the other library.

How much RAM does each library need for a 128x64 OLED?

Adafruit SSD1306 takes a 1,024-byte screen buffer when display.begin() runs. U8g2 needs 1,024 bytes in full-buffer mode (_F_), 256 bytes with _2_ and 128 bytes with _1_. An Arduino Uno has 2,048 bytes of RAM in total.

Does U8g2 work with the SH1106?

Yes. Use U8G2_SH1106_128X64_NONAME_F_HW_I2C, or the _1_ / _2_ version for page mode. With Adafruit you need the separate Adafruit SH110X library and the Adafruit_SH1106G class.

Can I make the Adafruit SSD1306 library smaller?

Yes, a little. About 1.5 KB of flash is the Adafruit logo that begin() draws at start-up. Uncomment #define SSD1306_NO_SPLASH in Adafruit_SSD1306.h to remove it; in our Uno test the sketch went from 13,172 to 11,698 bytes.

Get code for either library

Upload an image or GIF, choose Adafruit GFX or U8g2, and get a complete sketch with the right byte order and constructor. Sources: Adafruit SSD1306, Adafruit GFX, U8g2 wiki.

Open OLED Bitmap Converter