diff --git a/install/WinInstaller.nsi b/install/WinInstaller.nsi index 43bea4bc..c04ab720 100644 --- a/install/WinInstaller.nsi +++ b/install/WinInstaller.nsi @@ -11,7 +11,7 @@ ;Name and file Name "Grafx2" - OutFile "grafx2-2.00b98.0-svn482-win32.exe" + OutFile "grafx2-2.00b99.0-svn722-win32.exe" ;Default installation folder InstallDir "$PROGRAMFILES\Grafx2" @@ -60,11 +60,9 @@ Section "Grafx2" SecProgram SetOutPath "$INSTDIR" ;ADD YOUR OWN FILES HERE... File ..\grafx2.exe - File ..\gfxcfg.exe - File ..\src-svn482.tgz - File ..\gfx2.dat + File ..\src-svn722.tgz + File ..\skins\base.gif File ..\gfx2.gif - File ..\gfx2cfg.gif File ..\SDL_image.dll File ..\SDL.dll File ..\libfreetype-6.dll @@ -138,11 +136,8 @@ Section "un.SecProgram" ;ADD YOUR OWN FILES HERE... Delete "$INSTDIR\grafx2.exe" - Delete "$INSTDIR\gfxcfg.exe" - Delete "$INSTDIR\src-svn482.tgz" - Delete "$INSTDIR\gfx2.dat" + Delete "$INSTDIR\src-svn722.tgz" Delete "$INSTDIR\gfx2.gif" - Delete "$INSTDIR\gfx2cfg.gif" Delete "$INSTDIR\SDL_image.dll" Delete "$INSTDIR\SDL.dll" Delete "$INSTDIR\libfreetype-6.dll" @@ -159,6 +154,8 @@ Section "un.SecProgram" Delete "$INSTDIR\fonts\8pxfont.png" Delete "$INSTDIR\fonts\Tuffy.ttf" RMDir "$INSTDIR\fonts" + Delete "$INSTDIR\skins\base.gif" + RMDir "$INSTDIR\skins Delete "$INSTDIR\Uninstall.exe" MessageBox MB_YESNO|MB_DEFBUTTON2|MB_ICONQUESTION "Do you wish to keep your configuration settings ?" IDYES keepconfig IDNO deleteconfig diff --git a/loadsave.c b/loadsave.c index 5e7f5889..c20420db 100644 --- a/loadsave.c +++ b/loadsave.c @@ -2270,6 +2270,46 @@ void Test_BMP(void) } } +// Find the 8 important bits in a dword +byte Bitmap_mask(dword pixel, dword mask) +{ + byte result; + int i; + int bits_found; + + switch(mask) + { + // Shortcuts to quickly handle the common 24/32bit cases + case 0x000000FF: + return (pixel & 0x000000FF); + case 0x0000FF00: + return (pixel & 0x0000FF00)>>8; + case 0x00FF0000: + return (pixel & 0x00FF0000)>>16; + case 0xFF000000: + return (pixel & 0xFF000000)>>24; + } + // Uncommon : do it bit by bit. + bits_found=0; + result=0; + // Process the mask from low to high bit + for (i=0;i<32;i++) + { + // Found a bit in the mask + if (mask & (1<=8) + return result; + } + } + // Less than 8 bits in the mask: scale the result to 8 bits + return result << (8-bits_found); +} // -- Charger un fichier au format BMP -------------------------------------- void Load_BMP(void) @@ -2334,9 +2374,6 @@ void Load_BMP(void) { if (Read_bytes(file,local_palette,nb_colors<<2)) { - // On commence par passer la palette en 256 comme ça, si la nouvelle - // palette a moins de 256 coul, la précédente ne souffrira pas d'un - // assombrissement préjudiciable. if (Config.Clear_palette) memset(Main_palette,0,sizeof(T_Palette)); // On peut maintenant transférer la nouvelle palette @@ -2396,7 +2433,7 @@ void Load_BMP(void) /*Init_lecture();*/ Read_one_byte(file, &a); Read_one_byte(file, &b); - while ( (!File_error) && ((a)||(b!=1)) ) + while (!File_error) { if (a) // Encoded mode for (index=1; index<=a; index++) @@ -2420,15 +2457,19 @@ void Load_BMP(void) while (b) { Read_one_byte(file, &a); - Read_one_byte(file, &c); + //Read_one_byte(file, &c); Pixel_load_function(x_pos++,y_pos,a); - if (--c) - { - Pixel_load_function(x_pos++,y_pos,c); - b--; - } + //if (--c) + //{ + // Pixel_load_function(x_pos++,y_pos,c); + // b--; + //} + b--; } + if (ftell(file) & 1) fseek(file, 1, SEEK_CUR); } + if (a==0 && b==1) + break; Read_one_byte(file, &a); Read_one_byte(file, &b); } @@ -2503,28 +2544,100 @@ void Load_BMP(void) } else { - // Image 24 bits!!! + // Image 16/24/32 bits + dword red_mask; + dword green_mask; + dword blue_mask; + if (header.Nb_bits == 16) + { + red_mask = 0x00007C00; + green_mask = 0x000003E0; + blue_mask = 0x0000001F; + } + else + { + red_mask = 0x00FF0000; + green_mask = 0x0000FF00; + blue_mask = 0x000000FF; + } File_error=0; Main_image_width=header.Width; Main_image_height=header.Height; Init_preview(header.Width,header.Height,file_size,FORMAT_BMP | FORMAT_24B); - if (File_error==0) { - line_size=Main_image_width*3; - x_pos=(line_size % 4); // x_pos sert de variable temporaire - if (x_pos>0) - line_size+=(4-x_pos); - - buffer=(byte *)malloc(line_size); - for (y_pos=Main_image_height-1; ((y_pos>=0) && (!File_error)); y_pos--) + switch (header.Compression) { - if (Read_bytes(file,buffer,line_size)) - for (x_pos=0,index=0; x_pos0) + line_size+=(4-x_pos); + + buffer=(byte *)malloc(line_size); + for (y_pos=Main_image_height-1; ((y_pos>=0) && (!File_error)); y_pos--) + { + if (Read_bytes(file,buffer,line_size)) + for (x_pos=0,index=0; x_pos=0) && (!File_error)); y_pos--) + { + if (Read_bytes(file,buffer,line_size)) + for (x_pos=0; x_pos=0) && (!File_error)); y_pos--) + { + if (Read_bytes(file,buffer,line_size)) + for (x_pos=0; x_pos