Skip to content

functions : drawImage

max mc costa edited this page Jun 18, 2016 · 1 revision

drawImage command will be used in all my future version of display libraries and images.c files can be interchanged between libraries.
Images are packed in file created by LCD Image converter by using a custom template and settings, the result is a series of 16bit 565 color chunks, this can use a lot of space!
To convert an image, this is the right page:
https://github.com/sumotoy/TFT_ST7735/wiki/Convert-images
To use an image in you sketch you first need to include it:
#include "_images/machine.c"
Then simply use this command: tft.drawImage(0, 0, &machine);

The drawImage command:


drawImage(pos X, pos Y, &Image, SPECIAL, background threshold);


where:

  • pos X: where to start draw the image in X axis (image width + pos X must less that screen width)
  • pos Y: where to start draw the image in Y axis (image height + pos Y must less that screen height)
  • &Image: the image (& must be present in fron name)
  • SPECIAL: NONE,TRANSPARENT,REPLACE,BOTH
    NONE: draw as is, background threshold ignored
    TRANSPARENT: colors less than background threshold will be transparent
    REPLACE: colors less than background threshold will be replaced by setBackground(color)
    BOTH: colors less than background threshold will be replaced by setBackground(color), all other will be replaced by setForeground(color)
  • background threshold: Used to trigger the background color, from this color to 0x0000
    You don't need to use always all parameters, the short (default) version is:
    drawImage(pos X, pos Y, &Image);, draw image as is!
    NOTE: Exceed the positioning will result in nothing draw! For example, if your screen is 128x128 and your image is 120x120, set the image at drawImage(30,30,&myImage); will result in nothing draw because 120+30 = 130, this exceed the screen size (128).
Clone this wiki locally