From 8d438332411b05928ec9e508730253b985e00d66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Sun, 1 Jan 2017 19:57:13 +0000 Subject: [PATCH] [GB.SDL2] * BUG: Image.Load() automatically converts loaded image to default SDL image format. git-svn-id: svn://localhost/gambas/trunk@8035 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- gb.sdl2/src/c_image.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gb.sdl2/src/c_image.c b/gb.sdl2/src/c_image.c index ac0a94136..f157879e6 100644 --- a/gb.sdl2/src/c_image.c +++ b/gb.sdl2/src/c_image.c @@ -70,6 +70,7 @@ static void *temp_image(GB_IMG *img) if (img && img->data) surface = SDL_CreateRGBSurfaceFrom(img->data, img->width, img->height, 32, img->width * sizeof(int), RMASK, GMASK, BMASK, AMASK); + return SDL_CreateImage(surface); } @@ -157,6 +158,7 @@ BEGIN_METHOD(Image_Load, GB_STRING path) char *addr; int len; SDL_Surface *surface; + SDL_Surface *csurface; if (GB.LoadFile(STRING(path), LENGTH(path), &addr, &len)) return; @@ -170,6 +172,13 @@ BEGIN_METHOD(Image_Load, GB_STRING path) return; } + if (surface->format->format != DEFAULT_SDL_IMAGE_FORMAT) + { + csurface = SDL_ConvertSurfaceFormat(surface, DEFAULT_SDL_IMAGE_FORMAT, 0); + SDL_FreeSurface(surface); + surface = csurface; + } + GB.ReturnObject(IMAGE_create(SDL_CreateImage(surface))); END_METHOD