Skip to content
Permalink
Browse files

Added VS2010 and VS2012 projects; updates for VS compile; fixes from …

…VS code analysis and code review
  • Loading branch information
ferzkopp committed Feb 3, 2013
1 parent 0fe7b05 commit c2f3f4856ccff97dc49f4f0663b7b6293ada563e
Showing with 1,615 additions and 153 deletions.
  1. +1 −1 IMG.c
  2. +7 −7 IMG_bmp.c
  3. +21 −10 IMG_gif.c
  4. +6 −6 IMG_jpg.c
  5. +19 −23 IMG_lbm.c
  6. +16 −16 IMG_pcx.c
  7. +12 −12 IMG_png.c
  8. +4 −4 IMG_pnm.c
  9. +16 −12 IMG_tga.c
  10. +5 −5 IMG_tif.c
  11. +8 −8 IMG_webp.c
  12. +19 −18 IMG_xcf.c
  13. +29 −25 IMG_xpm.c
  14. +6 −6 IMG_xv.c
  15. +36 −0 VisualC/SDL_image_VS2010.sln
  16. +398 −0 VisualC/SDL_image_VS2010.vcxproj
  17. +36 −0 VisualC/SDL_image_VS2012.sln
  18. +402 −0 VisualC/SDL_image_VS2012.vcxproj
  19. +285 −0 VisualC/showimage/showimage_VS2010.vcxproj
  20. +289 −0 VisualC/showimage/showimage_VS2012.vcxproj
2 IMG.c
@@ -123,7 +123,7 @@ void IMG_Quit()
SDL_Surface *IMG_Load(const char *file)
{
SDL_RWops *src = SDL_RWFromFile(file, "rb");
char *ext = strrchr(file, '.');
const char *ext = strrchr(file, '.');
if(ext) {
ext++;
}
@@ -35,7 +35,7 @@
/* See if an image is contained in a data source */
int IMG_isBMP(SDL_RWops *src)
{
int start;
Sint64 start;
int is_BMP;
char magic[2];

@@ -44,7 +44,7 @@ int IMG_isBMP(SDL_RWops *src)
start = SDL_RWtell(src);
is_BMP = 0;
if ( SDL_RWread(src, magic, sizeof(magic), 1) ) {
if ( strncmp(magic, "BM", 2) == 0 ) {
if ( SDL_strncmp(magic, "BM", 2) == 0 ) {
is_BMP = 1;
}
}
@@ -54,7 +54,7 @@ int IMG_isBMP(SDL_RWops *src)

static int IMG_isICOCUR(SDL_RWops *src, int type)
{
int start;
Sint64 start;
int is_ICOCUR;

/* The Win32 ICO file header (14 bytes) */
@@ -187,7 +187,7 @@ static int readRlePixels(SDL_Surface * surface, SDL_RWops * src, int isRle8)
static SDL_Surface *LoadBMP_RW (SDL_RWops *src, int freesrc)
{
SDL_bool was_error;
long fp_offset;
Sint64 fp_offset;
int bmpPitch;
int i, pad;
SDL_Surface *surface;
@@ -237,7 +237,7 @@ static SDL_Surface *LoadBMP_RW (SDL_RWops *src, int freesrc)
was_error = SDL_TRUE;
goto done;
}
if ( strncmp(magic, "BM", 2) != 0 ) {
if ( SDL_strncmp(magic, "BM", 2) != 0 ) {
IMG_SetError("File is not a Windows BMP file");
was_error = SDL_TRUE;
goto done;
@@ -404,7 +404,7 @@ static SDL_Surface *LoadBMP_RW (SDL_RWops *src, int freesrc)
goto done;
}
if ((biCompression == BI_RLE4) || (biCompression == BI_RLE8)) {
was_error = readRlePixels(surface, src, biCompression == BI_RLE8);
was_error = (SDL_bool)readRlePixels(surface, src, biCompression == BI_RLE8);
if (was_error) IMG_SetError("Error reading from BMP");
goto done;
}
@@ -520,7 +520,7 @@ static SDL_Surface *
LoadICOCUR_RW(SDL_RWops * src, int type, int freesrc)
{
SDL_bool was_error;
long fp_offset;
Sint64 fp_offset;
int bmpPitch;
int i, pad;
SDL_Surface *surface;
@@ -33,7 +33,7 @@
/* See if an image is contained in a data source */
int IMG_isGIF(SDL_RWops *src)
{
int start;
Sint64 start;
int is_GIF;
char magic[6];

@@ -42,9 +42,9 @@ int IMG_isGIF(SDL_RWops *src)
start = SDL_RWtell(src);
is_GIF = 0;
if ( SDL_RWread(src, magic, sizeof(magic), 1) ) {
if ( (strncmp(magic, "GIF", 3) == 0) &&
((memcmp(magic + 3, "87a", 3) == 0) ||
(memcmp(magic + 3, "89a", 3) == 0)) ) {
if ( (SDL_strncmp(magic, "GIF", 3) == 0) &&
((SDL_memcmp(magic + 3, "87a", 3) == 0) ||
(SDL_memcmp(magic + 3, "89a", 3) == 0)) ) {
is_GIF = 1;
}
}
@@ -152,7 +152,7 @@ static Image *ReadImage(SDL_RWops * src, int len, int height, int,
Image *
IMG_LoadGIF_RW(SDL_RWops *src)
{
int start;
Sint64 start;
unsigned char buf[16];
unsigned char c;
unsigned char localColorMap[3][MAXCOLORMAPSIZE];
@@ -173,14 +173,14 @@ IMG_LoadGIF_RW(SDL_RWops *src)
RWSetMsg("error reading magic number");
goto done;
}
if (strncmp((char *) buf, "GIF", 3) != 0) {
if (SDL_strncmp((char *) buf, "GIF", 3) != 0) {
RWSetMsg("not a GIF file");
goto done;
}
memcpy(version, (char *) buf + 3, 3);
SDL_memcpy(version, (char *) buf + 3, 3);
version[3] = '\0';

if ((strcmp(version, "87a") != 0) && (strcmp(version, "89a") != 0)) {
if ((SDL_strcmp(version, "87a") != 0) && (SDL_strcmp(version, "89a") != 0)) {
RWSetMsg("bad version number, not '87a' or '89a'");
goto done;
}
@@ -337,7 +337,7 @@ DoExtension(SDL_RWops *src, int label)
return FALSE;
default:
str = (char *)buf;
sprintf(str, "UNKNOWN (0x%02x)", label);
SDL_snprintf(str, 256, "UNKNOWN (0x%02x)", label);
break;
}

@@ -439,8 +439,9 @@ LWZReadByte(SDL_RWops *src, int flag, int input_code_size)
table[0][i] = 0;
table[1][i] = i;
}
table[1][0] = 0;
for (; i < (1 << MAX_LWZ_BITS); ++i)
table[0][i] = table[1][0] = 0;
table[0][i] = 0;

sp = stack;

@@ -493,12 +494,22 @@ LWZReadByte(SDL_RWops *src, int flag, int input_code_size)
code = oldcode;
}
while (code >= clear_code) {
/* Guard against buffer overruns */
if (code < 0 || code >= (1 << MAX_LWZ_BITS)) {
RWSetMsg("invalid LWZ data");
return -3;
}
*sp++ = table[1][code];
if (code == table[0][code])
RWSetMsg("circular table entry BIG ERROR");
code = table[0][code];
}

/* Guard against buffer overruns */
if (code < 0 || code >= (1 << MAX_LWZ_BITS)) {
RWSetMsg("invalid LWZ data");
return -4;
}
*sp++ = firstcode = table[1][code];

if ((code = max_code) < (1 << MAX_LWZ_BITS)) {
@@ -177,7 +177,7 @@ void IMG_QuitJPG()
/* See if an image is contained in a data source */
int IMG_isJPG(SDL_RWops *src)
{
int start;
Sint64 start;
int is_JPG;
int in_scan;
Uint8 magic[4];
@@ -214,13 +214,13 @@ int IMG_isJPG(SDL_RWops *src)
is_JPG = 0;
} else {
/* Yes, it's big-endian */
Uint32 start;
Sint64 innerStart;
Uint32 size;
Uint32 end;
start = SDL_RWtell(src);
Sint64 end;
innerStart = SDL_RWtell(src);
size = (magic[2] << 8) + magic[3];
end = SDL_RWseek(src, size-2, RW_SEEK_CUR);
if ( end != start + size - 2 ) is_JPG = 0;
if ( end != innerStart + size - 2 ) is_JPG = 0;
if ( magic[1] == 0xDA ) {
/* Now comes the actual JPEG meat */
#ifdef FAST_IS_JPEG
@@ -374,7 +374,7 @@ static void output_no_message(j_common_ptr cinfo)
/* Load a JPEG type image from an SDL datasource */
SDL_Surface *IMG_LoadJPG_RW(SDL_RWops *src)
{
int start;
Sint64 start;
struct jpeg_decompress_struct cinfo;
JSAMPROW rowptr[1];
SDL_Surface *volatile surface = NULL;
@@ -61,7 +61,7 @@ typedef struct

int IMG_isLBM( SDL_RWops *src )
{
int start;
Sint64 start;
int is_LBM;
Uint8 magic[4+4+4];

@@ -71,9 +71,9 @@ int IMG_isLBM( SDL_RWops *src )
is_LBM = 0;
if ( SDL_RWread( src, magic, sizeof(magic), 1 ) )
{
if ( !memcmp( magic, "FORM", 4 ) &&
( !memcmp( magic + 8, "PBM ", 4 ) ||
!memcmp( magic + 8, "ILBM", 4 ) ) )
if ( !SDL_memcmp( magic, "FORM", 4 ) &&
( !SDL_memcmp( magic + 8, "PBM ", 4 ) ||
!SDL_memcmp( magic + 8, "ILBM", 4 ) ) )
{
is_LBM = 1;
}
@@ -84,7 +84,7 @@ int IMG_isLBM( SDL_RWops *src )

SDL_Surface *IMG_LoadLBM_RW( SDL_RWops *src )
{
int start;
Sint64 start;
SDL_Surface *Image;
Uint8 id[4], pbm, colormap[MAXCOLORS*3], *MiniBuf, *ptr, count, color, msk;
Uint32 size, bytesloaded, nbcolors;
@@ -135,20 +135,20 @@ SDL_Surface *IMG_LoadLBM_RW( SDL_RWops *src )
pbm = 0;

/* File format : PBM=Packed Bitmap, ILBM=Interleaved Bitmap */
if ( !memcmp( id, "PBM ", 4 ) ) pbm = 1;
else if ( memcmp( id, "ILBM", 4 ) )
if ( !SDL_memcmp( id, "PBM ", 4 ) ) pbm = 1;
else if ( SDL_memcmp( id, "ILBM", 4 ) )
{
error="not a IFF picture";
goto done;
}

nbcolors = 0;

memset( &bmhd, 0, sizeof( BMHD ) );
SDL_memset( &bmhd, 0, sizeof( BMHD ) );
flagHAM = 0;
flagEHB = 0;

while ( memcmp( id, "BODY", 4 ) != 0 )
while ( SDL_memcmp( id, "BODY", 4 ) != 0 )
{
if ( !SDL_RWread( src, id, 4, 1 ) )
{
@@ -166,7 +166,7 @@ SDL_Surface *IMG_LoadLBM_RW( SDL_RWops *src )

size = SDL_SwapBE32( size );

if ( !memcmp( id, "BMHD", 4 ) ) /* Bitmap header */
if ( !SDL_memcmp( id, "BMHD", 4 ) ) /* Bitmap header */
{
if ( !SDL_RWread( src, &bmhd, sizeof( BMHD ), 1 ) )
{
@@ -185,7 +185,7 @@ SDL_Surface *IMG_LoadLBM_RW( SDL_RWops *src )
bmhd.Hpage = SDL_SwapBE16( bmhd.Hpage );
}

if ( !memcmp( id, "CMAP", 4 ) ) /* palette ( Color Map ) */
if ( !SDL_memcmp( id, "CMAP", 4 ) ) /* palette ( Color Map ) */
{
if ( !SDL_RWread( src, &colormap, size, 1 ) )
{
@@ -214,7 +214,7 @@ SDL_Surface *IMG_LoadLBM_RW( SDL_RWops *src )
flagEHB = 1;
}

if ( memcmp( id, "BODY", 4 ) )
if ( SDL_memcmp( id, "BODY", 4 ) )
{
if ( size & 1 ) ++size; /* padding ! */
size -= bytesloaded;
@@ -242,7 +242,7 @@ SDL_Surface *IMG_LoadLBM_RW( SDL_RWops *src )
/* Allocate memory for a temporary buffer ( used for
decompression/deinterleaving ) */

MiniBuf = (void *)malloc( bytesperline * (nbplanes + stencil) );
MiniBuf = (Uint8 *)SDL_malloc( bytesperline * (nbplanes + stencil) );
if ( MiniBuf == NULL )
{
error="no enough memory for temporary buffer";
@@ -335,7 +335,7 @@ SDL_Surface *IMG_LoadLBM_RW( SDL_RWops *src )
error="error reading BODY chunk";
goto done;
}
memset( ptr, color, count );
SDL_memset( ptr, color, count );
}
else
{
@@ -365,7 +365,7 @@ SDL_Surface *IMG_LoadLBM_RW( SDL_RWops *src )

/* One line has been read, store it ! */

ptr = Image->pixels;
ptr = (Uint8 *)Image->pixels;
if ( nbplanes==24 || flagHAM==1 )
ptr += h * width * 3;
else
@@ -449,19 +449,15 @@ SDL_Surface *IMG_LoadLBM_RW( SDL_RWops *src )
{
finalcolor = pixelcolor;
}
if ( SDL_BYTEORDER == SDL_LIL_ENDIAN )
{
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
*ptr++ = (Uint8)(finalcolor>>16);
*ptr++ = (Uint8)(finalcolor>>8);
*ptr++ = (Uint8)(finalcolor);
}
else
{
*ptr++ = (Uint8)(finalcolor);
#else
*ptr++ = (Uint8)(finalcolor);
*ptr++ = (Uint8)(finalcolor>>8);
*ptr++ = (Uint8)(finalcolor>>16);
}

#endif
maskBit = maskBit>>1;
}
}

0 comments on commit c2f3f48

Please sign in to comment.