Graphics::drawImage

Description

void Graphics::drawImage( int16_t x , int16_t y , Image img [, int16_t w2 , int16_t h2 ] )

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 the image if you want to.

Keep in mind that you cannot draw full-color images onto indexed images!

Parameters

  • int16_t x: x-coordinate where to draw the image
  • int16_t y: y-coordinate where to draw the image
  • Image img: the image to draw
  • int16_t w2 (optional): new width (for scaling)
  • int16_t h2 (optional): new height (for scaling)

Returns

none

Example

#include <Gamebuino-Meta.h>

// create red-yellow checkerboard image
const uint8_t imgBuffer[] = {
  8, 8,
  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 = Image(imgBuffer);

void setup() {
  gb.begin();
}

void loop() {
  if (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);
  }
}