[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
This commit is contained in:
Benoît Minisini 2017-01-01 19:57:13 +00:00
parent 558f5f2271
commit 8d43833241

View File

@ -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