An optional adjunct to Adafruit_SPITFT that reads RGB BMP images (maybe others in the future) from a flash filesystem (SD card or SPI/QSPI flash). It's purposefully been made an entirely separate class (rather than part of SPITFT or GFX classes) so that Arduino code that uses GFX or SPITFT without image loading does not need to incur the RAM overhead and additional dependencies of the Adafruit_SPIFlash library by its mere inclusion. The syntaxes can therefore be a bit bizarre (passing display object as an argument), see examples for use.
More...
#include <Adafruit_ImageReader.h>
|
ImageReturnCode | coreBMP (const char *filename, Adafruit_SPITFT *tft, uint16_t *dest, int16_t x, int16_t y, Adafruit_Image *img, boolean transact) |
| BMP-reading function common both to the draw function (to TFT) and load function (to canvas object in RAM). BMP code has been centralized here so if/when more BMP format variants are added in the future, it doesn't need to be implemented, debugged and kept in sync in two places. More...
|
|
uint16_t | readLE16 (void) |
| Reads a little-endian 16-bit unsigned value from currently- open File, converting if necessary to the microcontroller's native endianism. (BMP files use little-endian values.) More...
|
|
uint32_t | readLE32 (void) |
| Reads a little-endian 32-bit unsigned value from currently- open File, converting if necessary to the microcontroller's native endianism. (BMP files use little-endian values.) More...
|
|
|
FatVolume * | filesys |
| FAT FileSystem Object.
|
|
File32 | file |
| Current Open file.
|
|
An optional adjunct to Adafruit_SPITFT that reads RGB BMP images (maybe others in the future) from a flash filesystem (SD card or SPI/QSPI flash). It's purposefully been made an entirely separate class (rather than part of SPITFT or GFX classes) so that Arduino code that uses GFX or SPITFT without image loading does not need to incur the RAM overhead and additional dependencies of the Adafruit_SPIFlash library by its mere inclusion. The syntaxes can therefore be a bit bizarre (passing display object as an argument), see examples for use.
◆ Adafruit_ImageReader()
Adafruit_ImageReader::Adafruit_ImageReader |
( |
FatVolume & |
fs | ) |
|
Constructor.
- Returns
- Adafruit_ImageReader object.
- Parameters
-
fs | FAT filesystem associated with this Adafruit_ImageReader instance. Any images to load will come from this filesystem; if multiple filesystems are required, each will require its own Adafruit_ImageReader object. The filesystem does NOT need to be initialized yet when passed in here (since this will often be in pre-setup() declaration, but DOES need initializing before any of the image loading or size functions are called! |
◆ ~Adafruit_ImageReader()
Adafruit_ImageReader::~Adafruit_ImageReader |
( |
void |
| ) |
|
Destructor.
- Returns
- None (void).
◆ drawBMP()
ImageReturnCode Adafruit_ImageReader::drawBMP |
( |
const char * |
filename, |
|
|
Adafruit_SPITFT & |
tft, |
|
|
int16_t |
x, |
|
|
int16_t |
y, |
|
|
boolean |
transact = true |
|
) |
| |
Loads BMP image file from SD card directly to SPITFT screen.
- Parameters
-
filename | Name of BMP image file to load. |
tft | Adafruit_SPITFT object (e.g. one of the Adafruit TFT or OLED displays that subclass Adafruit_SPITFT). |
x | Horizontal offset in pixels; left edge = 0, positive = right. Value is signed, image will be clipped if all or part is off the screen edges. Screen rotation setting is observed. |
y | Vertical offset in pixels; top edge = 0, positive = down. |
transact | Pass 'true' if TFT and SD are on the same SPI bus, in which case SPI transactions are necessary. If separate peripherals, can pass 'false'. |
- Returns
- One of the ImageReturnCode values (IMAGE_SUCCESS on successful completion, other values on failure).
◆ loadBMP()
Loads BMP image file from SD card into RAM (as one of the GFX canvas object types) for use with the bitmap-drawing functions. Not practical for most AVR microcontrollers, but some of the more capable 32-bit micros can afford some RAM for this.
- Parameters
-
filename | Name of BMP image file to load. |
img | Adafruit_Image object, contents will be initialized, allocated and loaded on success (else cleared). |
- Returns
- One of the ImageReturnCode values (IMAGE_SUCCESS on successful completion, other values on failure).
◆ bmpDimensions()
ImageReturnCode Adafruit_ImageReader::bmpDimensions |
( |
const char * |
filename, |
|
|
int32_t * |
width, |
|
|
int32_t * |
height |
|
) |
| |
Query pixel dimensions of BMP image file on SD card.
- Parameters
-
filename | Name of BMP image file to query. |
width | Pointer to int32_t; image width in pixels, returned. |
height | Pointer to int32_t; image height in pixels, returned. |
- Returns
- One of the ImageReturnCode values (IMAGE_SUCCESS on successful completion, other values on failure).
◆ printStatus()
void Adafruit_ImageReader::printStatus |
( |
ImageReturnCode |
stat, |
|
|
Stream & |
stream = Serial |
|
) |
| |
Print human-readable status message corresponding to an ImageReturnCode type.
- Parameters
-
stat | Numeric ImageReturnCode value. |
stream | Output stream (Serial default if unspecified). |
- Returns
- None (void).
◆ coreBMP()
ImageReturnCode Adafruit_ImageReader::coreBMP |
( |
const char * |
filename, |
|
|
Adafruit_SPITFT * |
tft, |
|
|
uint16_t * |
dest, |
|
|
int16_t |
x, |
|
|
int16_t |
y, |
|
|
Adafruit_Image * |
img, |
|
|
boolean |
transact |
|
) |
| |
|
protected |
BMP-reading function common both to the draw function (to TFT) and load function (to canvas object in RAM). BMP code has been centralized here so if/when more BMP format variants are added in the future, it doesn't need to be implemented, debugged and kept in sync in two places.
- Parameters
-
filename | Name of BMP image file to load. |
tft | Pointer to TFT object, if loading to screen, else NULL. |
dest | Working buffer for loading 16-bit TFT pixel data, if loading to screen, else NULL. |
x | Horizontal offset in pixels (if loading to screen). |
y | Vertical offset in pixels (if loading to screen). |
img | Pointer to Adafruit_Image object, if loading to RAM (or NULL if loading to screen). |
transact | Use SPI transactions; 'true' is needed only if loading to screen and it's on the same SPI bus as the SD card. Other situations can use 'false'. |
- Returns
- One of the ImageReturnCode values (IMAGE_SUCCESS on successful completion, other values on failure).
◆ readLE16()
uint16_t Adafruit_ImageReader::readLE16 |
( |
void |
| ) |
|
|
protected |
Reads a little-endian 16-bit unsigned value from currently- open File, converting if necessary to the microcontroller's native endianism. (BMP files use little-endian values.)
- Returns
- Unsigned 16-bit value, native endianism.
◆ readLE32()
uint32_t Adafruit_ImageReader::readLE32 |
( |
void |
| ) |
|
|
protected |
Reads a little-endian 32-bit unsigned value from currently- open File, converting if necessary to the microcontroller's native endianism. (BMP files use little-endian values.)
- Returns
- Unsigned 32-bit value, native endianism.
The documentation for this class was generated from the following files: