The problem comes from the "IMG_load" fonction of the SDL_image, with language C. It raises no error during execution, but when it comes to the line
SDL_Surface* image1 = IMG_Load("image.bmp");
the function returns a data that I can't use: for instance, SDL_BlitSurface(image1, NULL, screen, &position)
won't do anything.
However, it works fine when using the function SDL_LoadBMP.
I have used the debugger to try to understand the difference between the data returned by the two functions:
Here is what IMG_Load("image.bmp") returns:
{ //Doesn't work
flags = 0,
format = 0x3c07c0,
w = 40,
h = 40,
pitch = 120,
pixels = 0x3c07f0,
offset = 0,
hwdata = 0x0,
clip_rect = {
x = 0,
y = 0,
w = 0,
h = 0
},
unused1 = 0,
locked = 40,
map = 0x28,
format_version = 3939000,
refcount = 1
}
And here is what SDL_LoadBMP("image.bmp") returns:
{ //Works fine
flags = 0,
hwdata = 0x0,
clip_rect = {
x = 0,
y = 0,
w = 40,
h = 40
},
unused1 = 0,
locked = 0,
map = 0x3458e8,
format_version = 7,
refcount = 1
}
(Note that the image is the same, and it is a 40x40px square).
Why can't I use SDL_BlitSurface on a SDL_Surface returned by the function IMG_Load?
edit: you also have to know that this is the first time a function from the SDL_Image package is used in the program.