Adafruit ImageReader Library
Adafruit_ImageReader.h
Go to the documentation of this file.
1 
15 #ifndef __ADAFRUIT_IMAGE_READER_H__
16 #define __ADAFRUIT_IMAGE_READER_H__
17 
18 #include "Adafruit_SPIFlash.h"
19 #include "Adafruit_SPITFT.h"
20 
23  IMAGE_SUCCESS, // Successful load (or image clipped off screen)
24  IMAGE_ERR_FILE_NOT_FOUND, // Could not open file
25  IMAGE_ERR_FORMAT, // Not a supported image format
26  IMAGE_ERR_MALLOC // Could not allocate image (loadBMP() only)
27 };
28 
31  IMAGE_NONE, // No image was loaded; IMAGE_ERR_* condition
32  IMAGE_1, // GFXcanvas1 image (NOT YET SUPPORTED)
33  IMAGE_8, // GFXcanvas8 image (NOT YET SUPPORTED)
34  IMAGE_16 // GFXcanvas16 image (SUPPORTED)
35 };
36 
42 public:
43  Adafruit_Image(void);
44  ~Adafruit_Image(void);
45  int16_t width(void) const; // Return image width in pixels
46  int16_t height(void) const; // Return image height in pixels
47  void draw(Adafruit_SPITFT &tft, int16_t x, int16_t y);
54  ImageFormat getFormat(void) const { return (ImageFormat)format; }
55  void *getCanvas(void) const;
61  uint16_t *getPalette(void) const { return palette; }
67  GFXcanvas1 *getMask(void) const { return mask; };
68 
69 protected:
70  // MOST OF THESE ARE NOT SUPPORTED YET -- WIP
71  union { // Single pointer, only one variant is used:
72  GFXcanvas1 *canvas1;
73  GFXcanvas8 *canvas8;
74  GFXcanvas16 *canvas16;
75  } canvas;
76  GFXcanvas1 *mask;
77  uint16_t *palette;
78  uint8_t format;
79  void dealloc(void);
80  friend class Adafruit_ImageReader;
81 };
82 
96 public:
97  Adafruit_ImageReader(FatFileSystem &fs);
98  ~Adafruit_ImageReader(void);
99  ImageReturnCode drawBMP(const char *filename, Adafruit_SPITFT &tft, int16_t x,
100  int16_t y, boolean transact = true);
101  ImageReturnCode loadBMP(const char *filename, Adafruit_Image &img);
102  ImageReturnCode bmpDimensions(const char *filename, int32_t *w, int32_t *h);
103  void printStatus(ImageReturnCode stat, Stream &stream = Serial);
104 
105 protected:
106  FatFileSystem *filesys;
107  File file;
108  ImageReturnCode coreBMP(const char *filename, Adafruit_SPITFT *tft,
109  uint16_t *dest, int16_t x, int16_t y,
110  Adafruit_Image *img, boolean transact);
111  uint16_t readLE16(void);
112  uint32_t readLE32(void);
113 };
114 
115 #endif // __ADAFRUIT_IMAGE_READER_H__
void * getCanvas(void) const
Return pointer to image's GFX canvas object.
Definition: Adafruit_ImageReader.cpp:159
GFXcanvas1 * mask
1bpp image mask (or NULL)
Definition: Adafruit_ImageReader.h:76
GFXcanvas8 * canvas8
Canvas object if 8bpp format.
Definition: Adafruit_ImageReader.h:73
uint16_t * getPalette(void) const
Return pointer to color palette.
Definition: Adafruit_ImageReader.h:61
ImageFormat
Definition: Adafruit_ImageReader.h:30
int16_t width(void) const
Get width of Adafruit_Image object.
Definition: Adafruit_ImageReader.cpp:115
An optional adjunct to Adafruit_SPITFT that reads RGB BMP images (maybe others in the future) from a ...
Definition: Adafruit_ImageReader.h:95
uint16_t * palette
Color palette for 8bpp image (or NULL)
Definition: Adafruit_ImageReader.h:77
ImageFormat getFormat(void) const
Return canvas image format.
Definition: Adafruit_ImageReader.h:54
union Adafruit_Image::@0 canvas
Union of different GFXcanvas types.
GFXcanvas16 * canvas16
Canvas object if 16bpp.
Definition: Adafruit_ImageReader.h:74
~Adafruit_Image(void)
Destructor.
Definition: Adafruit_ImageReader.cpp:76
GFXcanvas1 * getMask(void) const
Return pointer to 1bpp image mask canvas.
Definition: Adafruit_ImageReader.h:67
uint8_t format
Canvas bundle type in use.
Definition: Adafruit_ImageReader.h:78
File file
Current Open file.
Definition: Adafruit_ImageReader.h:107
FatFileSystem * filesys
FAT FileSystem Object.
Definition: Adafruit_ImageReader.h:106
Adafruit_Image(void)
Constructor.
Definition: Adafruit_ImageReader.cpp:67
Data bundle returned with an image loaded to RAM. Used by ImageReader.loadBMP() and Image...
Definition: Adafruit_ImageReader.h:41
void dealloc(void)
Free/deinitialize variables.
Definition: Adafruit_ImageReader.cpp:83
int16_t height(void) const
Get height of Adafruit_Image object.
Definition: Adafruit_ImageReader.cpp:131
GFXcanvas1 * canvas1
Canvas object if 1bpp format.
Definition: Adafruit_ImageReader.h:72
void draw(Adafruit_SPITFT &tft, int16_t x, int16_t y)
Draw image to an Adafruit_SPITFT-type display.
Definition: Adafruit_ImageReader.cpp:183
friend class Adafruit_ImageReader
Loading occurs here.
Definition: Adafruit_ImageReader.h:80
ImageReturnCode
Definition: Adafruit_ImageReader.h:22