void Graphics::drawImage( int16_t x , int16_t y , Image img [, int16_t w2 , int16_t h2 ] ) void Graphics::drawImage( int16_t x , int16_t y , Image img , int16_t source_x , int16_t source_y , int16_t source_width , int16_t source_height )
Graphics::drawImage draws an image to the display/light/other image etc. If the image is animated it automatically progresses the animation, based on the set parameters. You can also re-scale or crop the image if you want to.
Keep in mind that you cannot draw full-color images onto indexed images!
Read the Image tutorial.
With source parameters:
none
#include <Gamebuino-Meta.h>// create red-yellow checkerboard image const uint8_t imgBuffer[] = { 8, 8, 1, 0, 0, 0xFF, 1, 0x6A, 0x6A, 0x6A, 0x6A, 0xA6, 0xA6, 0xA6, 0xA6, 0x6A, 0x6A, 0x6A, 0x6A, 0xA6, 0xA6, 0xA6, 0xA6, 0x6A, 0x6A, 0x6A, 0x6A, 0xA6, 0xA6, 0xA6, 0xA6, 0x6A, 0x6A, 0x6A, 0x6A, 0xA6, 0xA6, 0xA6, 0xA6, }; Image img(imgBuffer);
void setup() { gb.begin(); }
void loop() { while(!gb.update()); gb.display.clear();
// draw the image onto the screen gb.display.drawImage(0, 0, img);
// and now draw and upscale at the same time gb.display.drawImage(8, 0, img, img.width()*2, img.height()*2);
// and now only draw the middle 4x4 part of the image gb.display.drawImage(24, 0, img, 2, 2, 4, 4); }