Hello, I am having some weird problems with my Image handling class. The code here I copied from my previous project and it worked there so I am unsure of the problem.
Imagehandler.h
//This class handlers loading, optimizing, colour keying, and blitting images
#ifndef IMAGE_HANDLER_H
#define IMAGE_HANDLER_H
#include "SDL.h"
#include "SDL_image.h"
#include <string>
class ImageHandler{
public:
SDL_Surface* LoadImage(std::string Filename);
void BlitImage(int x, int y, SDL_Surface* Image, SDL_Surface* Destination, SDL_Rect* SpriteClip);
private:
SDL_Rect mOffset;
Uint32 mColourKey;
SDL_Surface* mLoadedImage;
SDL_Surface* mOpdImage;
};
#endif //IMAGE_HANDLER_H
Imagehandler.cpp
#include "ImageHandler.h"
SDL_Surface* ImageHandler::LoadImage(std::string Filename){
mLoadedImage = IMG_Load(Filename.c_str());
mOpdImage = NULL;
if(mLoadedImage != NULL){
mOpdImage = SDL_DisplayFormat(mLoadedImage);
SDL_FreeSurface(mLoadedImage);
} else return NULL;
if(mOpdImage != NULL){
mColourKey = SDL_MapRGB(mOpdImage->format, 255, 0, 255);
SDL_SetColorKey(mOpdImage, SDL_SRCCOLORKEY, mColourKey);
}
return mOpdImage;
}
Thank you for any help.