TFT_eSPI provides several complementary mechanisms for putting image data on the display. Monochrome icons stored as packed bit arrays in flash (PROGMEM) are drawn withDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Marcussacapuces91/doc-TFT_eSPI/llms.txt
Use this file to discover all available pages before exploring further.
drawBitmap or drawXBitmap. Full-color images — whether generated at runtime or decoded from JPEG/PNG — are pushed as raw RGB565 pixel buffers with pushImage or pushRect. You can also read a region of the display back into a buffer with readRect, enabling sprite-style operations. Understanding which API to use for each scenario is key to getting the best performance and the correct byte order.
Monochrome PROGMEM Bitmaps
drawBitmap
Draw a 1-bit-per-pixel bitmap stored in PROGMEM. Each 1 bit maps to the foreground color; each 0 bit is either skipped (transparent) or mapped to a background color.
X coordinate of the top-left corner.
Y coordinate of the top-left corner.
Pointer to a byte array in PROGMEM. Bits are packed MSB-first, row by row.
Bitmap width in pixels.
Bitmap height in pixels.
Color used where the bit is
1.Color used where the bit is
0. When omitted those pixels are skipped (transparent over the existing display content).drawXBitmap
Same as drawBitmap but expects data in XBM format, where bits are packed LSB-first (as produced by the GIMP Export as XBM option).
drawBitmap. The only difference is the LSB-first bit order of the data.
drawBitmap vs drawXBitmap — drawBitmap expects MSB-first packed data (as produced by most online bitmap converters for Arduino). drawXBitmap expects LSB-first XBM data (as exported directly from GIMP or the xbm format standard). If your image appears mirrored, you are using the wrong function.Example — PROGMEM Icon
Full-Color Pixel Buffers
pushImage
Copy a block of RGB565 pixel data from a RAM (or PROGMEM) buffer directly to a rectangular region of the display. This is the primary method for drawing decoded images, sprite frames, and generated pixel art.
Top-left corner of the destination rectangle.
Width and height of the image in pixels.
Pointer to the pixel buffer. For RGB565 images each pixel is a
uint16_t. For 8-bit images each byte is a palette index or raw 8-bit color.Color key: pixels with this value are not written to the display, leaving the existing background visible.
For 8-bit buffers:
true = 8-bit palette index (use cmap), false = 1-bit per pixel.Optional 256-entry RGB565 color map for 8-bit indexed images.
pushRect
Push a uint16_t pixel buffer to a display rectangle. Functionally equivalent to the plain pushImage overload — use whichever name feels more descriptive in your code.
Top-left corner of the destination.
Width and height in pixels.
RGB565 pixel buffer,
w × h entries.Reading Pixels from the Display
readRect
Read a rectangular region of the display into a uint16_t buffer. Useful for saving a background region before drawing a sprite, then restoring it afterward.
Top-left corner of the source rectangle.
Width and height in pixels.
Destination buffer. Must be at least
w × h entries of uint16_t.Bitmap Helper Functions
setBitmapColor
Override the foreground and background colors that drawBitmap / drawXBitmap use. This is an alternative to passing colors directly to each call.
Color for
1-bits.Color for
0-bits.setSwapBytes and getSwapBytes
TFT_eSPI internally stores colors in the display-native byte order. Image data loaded from external sources (e.g. JPEG decoders, BMP files) may have the bytes swapped. Calling setSwapBytes(true) tells pushImage to swap the high and low bytes of every pixel as it writes.
true — swap bytes before writing (required for most externally-sourced RGB565 bitmaps). false — no swap (default).drawBitmap vs pushImage — Choosing the Right Function
drawBitmap / drawXBitmap
Use when: you have a monochrome (1-bit) icon or logo stored in PROGMEM as a packed byte array. Memory-efficient — 1 pixel per bit. Supports transparent (skip) or filled background rendering.
pushImage / pushRect
Use when: you have a full-color RGB565 image decoded at runtime or stored in a
uint16_t array. Every pixel has its own 16-bit color value, so the buffer is w × h × 2 bytes. Fastest path to the display for pre-decoded imagery.Complete Example — Animated Sprite
Store your bitmap in PROGMEM
Declare the array with the
PROGMEM keyword and static const uint8_t. This keeps the data in flash rather than consuming precious RAM.Choose the correct bit order
Use
drawBitmap for MSB-first data (most Arduino converters) and drawXBitmap for LSB-first XBM data (GIMP exports).Check byte order for color images
Call
tft.setSwapBytes(true) before pushImage if your decoded RGB565 data comes from a BMP file or a JPEG decoder library that outputs big-endian pixels.