Mercurial > molko
changeset 112:40f22a8188d2
image: set dimensions
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sun, 12 Apr 2020 16:55:26 +0200 |
parents | f17890fe144b |
children | c5dcf51f5f1e |
files | src/core/image.c src/core/image.h |
diffstat | 2 files changed, 18 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/core/image.c Wed Apr 08 20:05:00 2020 +0200 +++ b/src/core/image.c Sun Apr 12 16:55:26 2020 +0200 @@ -26,6 +26,19 @@ #include "window.h" #include "window_p.h" +static void +dimensions(struct texture *tex) +{ + int w, h; + + if (SDL_QueryTexture(tex->handle, NULL, NULL, &w, &h) < 0) + tex->w = tex->h = 0; + else { + tex->w = w; + tex->h = h; + } +} + bool image_open(struct texture *tex, const char *path) { @@ -35,6 +48,8 @@ if (!(tex->handle = IMG_LoadTexture(RENDERER(), path))) return error_sdl(); + dimensions(tex); + return true; } @@ -48,5 +63,7 @@ if (!ops || !(tex->handle = IMG_LoadTexture_RW(RENDERER(), ops, true))) return error_sdl(); + dimensions(tex); + return true; }