Adafruit ImageReader Library
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
Adafruit_Image Class Reference

Data bundle returned with an image loaded to RAM. Used by ImageReader.loadBMP() and Image.draw(), not ImageReader.drawBMP(). More...

#include <Adafruit_ImageReader.h>

Inheritance diagram for Adafruit_Image:
Adafruit_Image_EPD

Public Member Functions

 Adafruit_Image (void)
 Constructor. More...
 
 ~Adafruit_Image (void)
 Destructor. More...
 
int16_t width (void) const
 Get width of Adafruit_Image object. More...
 
int16_t height (void) const
 Get height of Adafruit_Image object. More...
 
void draw (Adafruit_SPITFT &tft, int16_t x, int16_t y)
 Draw image to an Adafruit_SPITFT-type display. More...
 
ImageFormat getFormat (void) const
 Return canvas image format. More...
 
void * getCanvas (void) const
 Return pointer to image's GFX canvas object. More...
 
uint16_t * getPalette (void) const
 Return pointer to color palette. More...
 
GFXcanvas1 * getMask (void) const
 Return pointer to 1bpp image mask canvas. More...
 

Protected Member Functions

void dealloc (void)
 Free/deinitialize variables. More...
 

Protected Attributes

union {
   GFXcanvas1 *   canvas1
 Canvas object if 1bpp format.
 
   GFXcanvas8 *   canvas8
 Canvas object if 8bpp format.
 
   GFXcanvas16 *   canvas16
 Canvas object if 16bpp.
 
canvas
 Union of different GFXcanvas types.
 
GFXcanvas1 * mask
 1bpp image mask (or NULL)
 
uint16_t * palette
 Color palette for 8bpp image (or NULL)
 
uint8_t format
 Canvas bundle type in use.
 

Friends

class Adafruit_ImageReader
 Loading occurs here.
 

Detailed Description

Data bundle returned with an image loaded to RAM. Used by ImageReader.loadBMP() and Image.draw(), not ImageReader.drawBMP().

Constructor & Destructor Documentation

◆ Adafruit_Image()

Adafruit_Image::Adafruit_Image ( void  )

Constructor.

Returns
'Empty' Adafruit_Image object.

◆ ~Adafruit_Image()

Adafruit_Image::~Adafruit_Image ( void  )

Destructor.

Returns
None (void).

Member Function Documentation

◆ width()

int16_t Adafruit_Image::width ( void  ) const

Get width of Adafruit_Image object.

Returns
Width in pixels, or 0 if no image loaded.

◆ height()

int16_t Adafruit_Image::height ( void  ) const

Get height of Adafruit_Image object.

Returns
Height in pixels, or 0 if no image loaded.

◆ draw()

void Adafruit_Image::draw ( Adafruit_SPITFT &  tft,
int16_t  x,
int16_t  y 
)

Draw image to an Adafruit_SPITFT-type display.

Parameters
tftScreen to draw to (any Adafruit_SPITFT-derived class).
xHorizontal 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.
yVertical offset in pixels; top edge = 0, positive = down.
Returns
None (void).

◆ getFormat()

ImageFormat Adafruit_Image::getFormat ( void  ) const
inline

Return canvas image format.

Returns
An ImageFormat type: IMAGE_1 for a GFXcanvas1, IMAGE_8 for a GFXcanvas8, IMAGE_16 for a GFXcanvas16, IMAGE_NONE if no canvas currently allocated.

◆ getCanvas()

void * Adafruit_Image::getCanvas ( void  ) const

Return pointer to image's GFX canvas object.

Returns
void* pointer, must be type-converted to a GFX canvas type consistent with the image's format (e.g. GFXcanvas16* if image format is IMAGE_16 – use image.format() to determine the image format). Returns NULL if no canvas allocated.
Note
Calling function must type-convert the result to one of the supported canvas object types, and must act accordingly with regard to calling functions on this object (e.g. doing the right thing with an 8- or 16-bit canvas, each has distinct drawing functions, things like that). This is here mostly to allow more advanced applications to get directly into an image's canvas object (and, in turn, its raw graphics buffer via canvas->getBuffer()) to move data in or out. Potential for a lot of mayhem here if used wrong.

◆ getPalette()

uint16_t* Adafruit_Image::getPalette ( void  ) const
inline

Return pointer to color palette.

Returns
Pointer to an array of 16-bit color values, or NULL if no palette associated with image.

◆ getMask()

GFXcanvas1* Adafruit_Image::getMask ( void  ) const
inline

Return pointer to 1bpp image mask canvas.

Returns
GFXcanvas1* pointer (1-bit RAM-resident image) if present, NULL otherwise.

◆ dealloc()

void Adafruit_Image::dealloc ( void  )
protected

Free/deinitialize variables.

Deallocates memory associated with Adafruit_Image object and resets member variables to 'empty' state.

Returns
None (void).

The documentation for this class was generated from the following files: