Hi, Patrick
Sorry for the lack of information. The BMP image that I said cannot be
loaded was the one in this link:
http://www.kekkai.org/roger/sdl/rwops/penguin.bmp
I’m using Windows 7 32-bit and compiling with the MingW with this line:
g++ -o test.exe main.cpp -lmingw32 libSDLmain.a SDL.dll
My code:
#include “SDL/SDL.h”
#include <stdio.h>
int main(int argc, char *argv){
SDL_Init(SDL_INIT_VIDEO);
atexit(SDL_Quit);
SDL_Surface *screen = SDL_SetVideoMode(640, 480, 16, SDL_DOUBLEBUF);
FILE *file = fopen(“penguin.bmp”, “r”);
if(!file) {
printf(“Couldn’t load penguin.bmp\n”);
exit(1);
}
SDL_RWops *rw = SDL_RWFromFP(file, 0);
SDL_Surface *one = SDL_LoadBMP_RW(rw, 0);
printf(“%s”, SDL_GetError());
SDL_FreeRW(rw);
fclose(file);
SDL_Rect rect;
rect.x = rect.y = 20;
rect.w = one → w;
rect.y = one → h;
SDL_BlitSurface(one, NULL, screen, &rect);
SDL_Flip(screen);
SDL_Delay(3000);
}
Remembering that this worked in Linux Ubuntu 10.04 with g++ and the same
image. Ok, this is for BMPs.
But for PNGs, I haven’t get any image to work in Windows. Again, in this
case, I loaded PNGs in Linux without problem, but in Windows I get the
message: “Error reading the PNG file”. The code used was:
char pBuffer[2157];
FILE* file = fopen(“cursor.png”, “r”);
fseek(file, 0, SEEK_SET);
fread(pBuffer, sizeof(char), 2157, file);
SDL_RWops* rw = SDL_RWFromMem(pBuffer, 2157);
SDL_Surface* two = IMG_Load_RW(rw, 1);
printf(“%s\n”, SDL_GetError());
And built with:
g++ -o test.exe main.cpp -lmingw32 libSDLmain.a SDL.dll SDL_image.dll
I have tested with the PNG file attached in this message. It works in Linux
but not in Windows. It’s strange because loading the PNG file directly with
IMG_Load, it works even in Windows.
I’m trying to use SDL_RWops to load all my resources from one file, but I
can’t find any Windows working example.
I’m grateful for any help.
Thnaks in advance!
2011/10/14 Patrick Baggett <baggett.patrick at gmail.com>> Yuri,
It might be more productive if you can create a minimal test case that
fails and links to PNG/BMP images that fail. For example a program that does
something like:
#define FILENAME “myfile.png”
int main() {
if(!TryIMG_Load(FILENAME)) {
printf("IMG_Load() for %s failed!\n", FILENAME);
return 1;
}
if(!TryIMG_Load_RW(FILENAME)) {
printf("IMG_Load() for %s failed!\n", FILENAME);
return 2;
}
printf("Test case success!\n");
return 0;
}
The problem with saying that it fails for some images and not others, and
then not providing test cases is that if I were to test 1,000 images right
now, how would I know if I was testing the “right kind” to trigger this bug?
After trying 1,000 images, I’d sooner believe the problem is with your code
or maybe with *your * compiler that you used to build SDL/libpng/your app,
even if it was in fact a bug in someone else’s code. Help us help you, give
us the tools and data we need to figure out what the problem might be.
Patrick Baggett
On Fri, Oct 14, 2011 at 1:23 PM, Yuri David Santos wrote:
I found that this problem occurs just for some BMP files, not all. Some 8
bits BMP.
Another problem I’m having is to load PNG files. With IMG_Load it works,
but using the IMG_Load_RW to load from memory or from a memory pointer, the
SDL_GetError() says “Error reading the PNG file”. I don’t know what this can
be. The libpng.dll is in the same folder that the SDL_image.dll, and is
loading successfully directly from the file (with IMG_Load).
Anybody get this problem too?
Thanks in advance!
2011/10/14 Yuri David Santos
Hi!
I’m new to this mailing list. I have googled arround but I’ve found no
answers to this. I followed the first tutorial in this link:
http://www.kekkai.org/roger/sdl/rwops/rwops.html
In Linux it works great (all the 4 parts), but in Windows, the same code
results in the error message “error reading from datastream”. The code is
exactly as in the tutorial above. Anyone have any ideas?
Thanks in advance!
–
Yuri
–
Yuri David Santos
Aleva - Solu??es em Software
www.aleva.com.br
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
–
Yuri David Santos
Aleva - Solu??es em Software
www.aleva.com.br
-------------- next part --------------
A non-text attachment was scrubbed…
Name: cursor.png
Type: image/png
Size: 2157 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20111014/90334457/attachment.png