1. Guides
  2. Creating and using images

Guides

Creating and using images

You handle images similarly as you handle other shapes, except that to use an image you have to load it before hand.

Loading an image

You can use gm_image_open, and passing the path to the image you want to open, you are adviced to use png images since I ensure that at least them should be supported everywhere.

the function returns a gmimage object, which has properties like height and width which are the actual image's dimensions.

drawing the image

easy, use gm_image_draw, passing image dimensins, if you want to draw only part of an image(that's what sprites do) you can use gm_image_draw_part.

Example

        gmImage person = gm_image_open("assets/images/person.png");
int width = person.width;
    height = person.height;
gm_image_draw(person, 0, 0, 1, 1);

      

Reference

image.h reference