rev 1.0 of the lib - now working

This commit is contained in:
Sylvain PILLOT 2022-05-03 23:22:22 +02:00
parent a87c39daa8
commit 400397aded
2 changed files with 8 additions and 16 deletions

14
IMG.c
View File

@ -124,7 +124,7 @@ static int IMG_string_equals(const char *str1, const char *str2)
SDL_Surface *IMG_Load(const char *file)
{
///cSDL_LogToFile( "IMG_Load : %s", file );
cSDL_LogToFile( "IMG_Load : %s", file );
SDL_RWops *src = SDL_RWFromFile(file, "rb");
char buf[256];
@ -149,7 +149,7 @@ SDL_Surface *IMG_Load_RW(SDL_RWops *src, int freesrc)
/* Load an image from an SDL datasource, optionally specifying the type */
SDL_Surface *IMG_LoadTyped_RW(SDL_RWops *src, int freesrc, char *type)
{
///cSDL_LogToFile( "IMG_LoadTypeRW : %p - %d - %s", src, freesrc, type );
cSDL_LogToFile( "IMG_LoadTypeRW : %p - %d - %s", src, freesrc, type );
int i;
SDL_Surface *image;
@ -157,18 +157,14 @@ SDL_Surface *IMG_LoadTyped_RW(SDL_RWops *src, int freesrc, char *type)
/* Make sure there is something to do.. */
if ( src == NULL ) {
IMG_SetError("Passed a NULL data source");
///cSDL_LogToFile( "IMG_LoadTypeRW : src is NULL !!!" );
cSDL_LogToFile( "IMG_LoadTypeRW : src is NULL !!!" );
return(NULL);
}
/* See whether or not this data source can handle seeking */
long temp = SDL_RWseek(src, 0, RW_SEEK_CUR);
dprint(1,10, C_BLACK, "temp = %d", temp );
if ( temp < 0 ) {
if ( SDL_RWseek(src, 0, RW_SEEK_CUR) < 0 ) {
IMG_SetError("Can't seek in this data source");
///cSDL_LogToFile( "IMG_LoadTypeRW : can't seek in the file !!!" );
cSDL_LogToFile( "IMG_LoadTypeRW : can't seek in the file !!!" );
if(freesrc)
SDL_RWclose(src);
return(NULL);

View File

@ -243,20 +243,16 @@ static SDL_Surface *LoadBMP_RW (SDL_RWops *src, int freesrc)
/* Read in the BMP file header */
fp_offset = SDL_RWtell(src);
dprint(1,20, C_BLACK, "fp_offset = %d", fp_offset );
r61524_display(gint_vram, 0, DHEIGHT, R61524_CPU);
getkey();
SDL_ClearError();
if ( SDL_RWread(src, magic, 1, 2) != 2 ) {
//cSDL_LogToFile( "LoadBMP_RW : point 3 - magic test : fp_offset = %d", fp_offset );
//cSDL_LogToFile( "LoadBMP_RW : point 3.5 - magic = %s", magic );
cSDL_LogToFile( "LoadBMP_RW : point 3 - magic test : fp_offset = %d", fp_offset );
cSDL_LogToFile( "LoadBMP_RW : point 3.5 - magic = %s", magic );
SDL_Error(SDL_EFREAD);
was_error = SDL_TRUE;
goto done;
}
if ( strncmp(magic, "BM", 2) != 0 ) {
//cSDL_LogToFile( "LoadBMP_RW : point 4 - Not a BMP File" );
cSDL_LogToFile( "LoadBMP_RW : point 4 - Not a BMP File" );
IMG_SetError("File is not a Windows BMP file");
was_error = SDL_TRUE;
goto done;