Home › Tools › Image to Byte Array › Converter

Image to Byte Array Converter

Drop an image, set the size and threshold, then copy the bytes. It works for Arduino OLED bitmaps (Adafruit GFX, U8g2, SSD1306), MicroPython, colour TFTs in RGB565, and the raw file bytes in C, Python, Java or C#. Nothing is uploaded: the image stays in your browser.

1. Image

PNG, JPG, GIF, WEBP, BMP or SVG. You can also drag it here or paste with Ctrl+V.

No image yet

2. Size and position

Canvas preset
0
0

3. Black and white

128
0
0

Bright pixels become lit OLED pixels. Use Invert for dark artwork on a white background.

Preview

Pixels (1 = on)128 × 64
OLED look

4. Output

Bytes: 0

Settings guide: getting a clean bitmap first time

Most conversion problems come from two settings: the canvas size and the black-and-white step. Get those right and the output format is just a matter of matching your library. Here is what each control does and the values that work for common jobs.

Quick recipes

What you are convertingScalingDitheringThresholdTip
Logo or icon with flat coloursFitNone100 to 160Turn on Invert if the logo is dark on a white background.
Photo or faceFillFloyd–Steinberg or Atkinson~128Raise Contrast to +20 or +30 before dithering so the subject stands out.
Line art or text screenshotFitNone180 to 220A high threshold keeps thin strokes from vanishing.
Gradient or skyFillBayer 4×4~128Bayer gives an even pattern that animates without flicker.
Small 16×16 or 32×32 iconOriginal sizeNone~128Draw icons at the exact size; scaling down tiny art loses detail.

Size and position

Pick the preset that matches your screen, not the size of your picture. A 0.96 inch or 1.3 inch module is 128×64, the thin 0.91 inch bar is 128×32 and an SH1107 is 128×128. Fit keeps the whole image with empty bars, Fill crops to use every pixel, and Stretch distorts. If the screen is mounted upside down or sideways in your build, fix it here with Rotate or Flip so you don't have to change the code later. The Offset sliders nudge the picture when the subject sits off centre after cropping.

Black and white

An OLED pixel is either on or off, so every colour has to become one of the two. Threshold decides where that cut happens: pixels brighter than the value light up. Brightness and Contrast are applied before the cut, so use them to rescue a dull photo instead of pushing the threshold to an extreme. Dithering mixes on and off pixels to fake grey; it looks great on photos but makes text and logos fuzzy. Background controls what transparent PNG areas become, and Invert swaps everything, which you need when your art is black on white.

Which output format to choose

Before you upload

Keep PROGMEM ticked on an Arduino Uno or Nano: a full 128×64 image is 1,024 bytes, half of the Uno's 2 KB of RAM. On ESP32 and ESP8266 it is harmless either way. Tick Full ready-to-upload sketch if you want a complete program with the display set up, and choose SH1106 under Sketch display for 1.3 inch modules, which are usually SH1106 rather than SSD1306. If you need several frames for an animation, the OLED Animation Maker builds the frame array and playback loop for you.