TFT_eSPI represents colours internally as 16-bit RGB565 values (5 red bits, 6 green bits, 5 blue bits), but provides a suite of conversion helpers for moving between RGB565, 8-bit RGB332, 24-bit RGB888, and alpha-blended composites. The library also exposes methods for reading individual pixels back from the display, pushing raw pixel buffers, and managing image stride and byte-swap settings. DMA-capable pushImage variants are available for high-throughput transfers on ESP32 and RP2040 targets.Documentation 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.
readPixel() — Read a Pixel from the Display
X coordinate of the pixel to read.
Y coordinate of the pixel to read.
uint16_t — the pixel colour in RGB565 format.
width() / height() — Display Dimensions
setRotation(1) (landscape), width() returns the longer dimension and height() the shorter, swapped relative to rotation 0.
Returns: int16_t — current display width or height in pixels.
color565() — Pack RGB Components to RGB565
Red channel intensity (0–255).
Green channel intensity (0–255).
Blue channel intensity (0–255).
uint16_t — packed RGB565 colour value.
color8to16() — RGB332 to RGB565
8-bit RGB332 packed colour value.
uint16_t — equivalent RGB565 colour.
color16to8() — RGB565 to RGB332
16-bit RGB565 colour to convert.
uint8_t — 8-bit RGB332 approximation.
color16to24() — RGB565 to RGB888
uint32_t.
16-bit RGB565 colour.
uint32_t — 24-bit RGB888 value (bits 23–0 contain the colour; bits 31–24 are 0).
color24to16() — RGB888 to RGB565
24-bit RGB888 colour value (upper byte ignored).
uint32_t — the RGB565 value in the lower 16 bits.
alphaBlend() — Alpha Composite Two RGB565 Colours
fgc over background colour bgc using an alpha value in the range 0–255. At alpha = 0 the result is fully bgc; at alpha = 255 the result is fully fgc. The dithered overload adds a small noise value to reduce colour banding.
Blend factor (0 = fully background, 255 = fully foreground).
Foreground RGB565 colour.
Background RGB565 colour.
Dither amplitude (overload 2 only). Higher values reduce banding.
uint16_t — blended RGB565 colour.
alphaBlend24() — Alpha Composite Two RGB888 Colours
alphaBlend() but operates on 24-bit RGB888 colours and returns a 24-bit result.
Blend factor (0–255).
Foreground 24-bit colour.
Background 24-bit colour.
Dither amplitude. Default 0.
uint32_t — blended 24-bit colour.
setBitmapColor() — Set Bitmap Foreground/Background
drawBitmap() and drawXBitmap(). Stored in the public members bitmap_fg and bitmap_bg.
Colour for set (1) bits.
Colour for clear (0) bits.
setSwapBytes() / getSwapBytes() — Byte Order for Image Data
pushImage() are swapped before rendering. This corrects the byte order for images stored in little-endian format (e.g. most BMP files on ESP32) versus the big-endian SPI display format.
true to swap bytes; false for native order.getSwapBytes() Returns: bool — current swap-bytes setting.
readRect() — Read a Pixel Rectangle into a Buffer
X coordinate of the top-left corner.
Y coordinate of the top-left corner.
Width of the rectangle in pixels.
Height of the rectangle in pixels.
Buffer to receive
w * h RGB565 values.pushRect() — Write a Pixel Rectangle from a Buffer
w * h RGB565 pixels to the display at position (x, y).
X destination coordinate.
Y destination coordinate.
Rectangle width.
Rectangle height.
Source buffer of
w * h RGB565 values.pushImage() — Push Image with Optional Transparency
X destination coordinate.
Y destination coordinate.
Image width in pixels.
Image height in pixels.
Pointer to pixel data.
Transparent colour key. Pixels matching this value are not rendered.
When
true, each uint8_t is a palette index; when false, it’s raw RGB332.Pointer to a 256-entry RGB565 colour-map array.
nullptr uses a default map.pushMaskedImage() — Push Image with Alpha Mask
X destination coordinate.
Y destination coordinate.
Image width.
Image height.
RGB565 pixel data.
1-bit mask data (1 = render pixel, 0 = skip).
setPivot() / getPivotX() / getPivotY() — Sprite Pivot Point
X coordinate of the pivot point.
Y coordinate of the pivot point.
getPivotX/Y): int16_t — pivot coordinate.