From 5b2fde1c744c9cc5d1a62c5177b8fb23dfee8378 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Mon, 17 Jan 2005 22:10:32 +0000 Subject: Loaded images now converted to display format for speed, and added support for masking on magic pink. --- src/resources/image.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/resources/image.cpp') diff --git a/src/resources/image.cpp b/src/resources/image.cpp index f3af2790..624036cf 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -25,6 +25,7 @@ #include "image.h" #include #include +#include "../graphic/graphic.h" Image::Image(SDL_Surface *image): image(image) @@ -42,7 +43,12 @@ Image* Image::load(const std::string &filePath) std::cout << "Image::load(" << filePath << ")\n"; #endif // Attempt to use SDL_Image to load the file. - SDL_Surface *image = IMG_Load(filePath.c_str()); + SDL_Surface *tmpImage = IMG_Load(filePath.c_str()); + SDL_Surface *image = SDL_ConvertSurface( + tmpImage, screen->format, SDL_SWSURFACE); + SDL_FreeSurface(tmpImage); + SDL_SetColorKey(image, SDL_SRCCOLORKEY | SDL_RLEACCEL, + SDL_MapRGB(image->format, 255, 0, 255)); // Check if the file was opened and return the appropriate value. if (!image) { -- cgit v1.2.3-60-g2f50