Image Loading problems

Started by
2 comments, last by Federico Barlotti 11 years, 1 month ago

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.

Advertisement

Weird problems?

What weird problems?

Weird problems?

What weird problems?

He double posted this topic, in the other one are replies already. http://www.gamedev.net/topic/639672-image-loading-problems/

Oh, okay

This topic is closed to new replies.

Advertisement