trunk: Implemented file loading of JPEG, TGA, TIFF and a few others, by using SDL_Image builtin loader. Added visible 'hourglass' cursor during 24bit color reduction.
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1085 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
		
							parent
							
								
									9ef0e6b74c
								
							
						
					
					
						commit
						db130fc60d
					
				
							
								
								
									
										29
									
								
								Makefile.dep
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								Makefile.dep
									
									
									
									
									
								
							@ -4,7 +4,7 @@ $(OBJDIR)/brush.o: brush.c global.h struct.h const.h graph.h misc.h errors.h \
 | 
			
		||||
$(OBJDIR)/buttons.o: buttons.c const.h struct.h global.h misc.h graph.h engine.h \
 | 
			
		||||
  readline.h filesel.h loadsave.h init.h buttons.h operatio.h pages.h \
 | 
			
		||||
  palette.h errors.h readini.h saveini.h shade.h io.h help.h text.h \
 | 
			
		||||
  sdlscreen.h windows.h brush.h input.h
 | 
			
		||||
  sdlscreen.h windows.h brush.h input.h special.h
 | 
			
		||||
$(OBJDIR)/engine.o: engine.c const.h struct.h global.h graph.h misc.h special.h \
 | 
			
		||||
  buttons.h operatio.h shade.h errors.h sdlscreen.h windows.h brush.h \
 | 
			
		||||
  input.h engine.h
 | 
			
		||||
@ -26,7 +26,8 @@ $(OBJDIR)/input.o: input.c global.h struct.h const.h keyboard.h sdlscreen.h \
 | 
			
		||||
$(OBJDIR)/io.o: io.c struct.h const.h io.h realpath.h
 | 
			
		||||
$(OBJDIR)/keyboard.o: keyboard.c global.h struct.h const.h keyboard.h
 | 
			
		||||
$(OBJDIR)/loadsave.o: loadsave.c buttons.h struct.h const.h errors.h global.h io.h \
 | 
			
		||||
  loadsave.h misc.h op_c.h pages.h palette.h sdlscreen.h windows.h
 | 
			
		||||
  loadsave.h misc.h op_c.h pages.h palette.h sdlscreen.h windows.h \
 | 
			
		||||
  engine.h
 | 
			
		||||
$(OBJDIR)/main.o: main.c const.h struct.h global.h graph.h misc.h init.h buttons.h \
 | 
			
		||||
  engine.h pages.h loadsave.h sdlscreen.h errors.h readini.h saveini.h \
 | 
			
		||||
  io.h text.h setup.h windows.h brush.h palette.h realpath.h
 | 
			
		||||
@ -41,19 +42,22 @@ $(OBJDIR)/pages.o: pages.c global.h struct.h const.h pages.h errors.h misc.h \
 | 
			
		||||
$(OBJDIR)/palette.o: palette.c const.h struct.h global.h misc.h engine.h readline.h \
 | 
			
		||||
  buttons.h pages.h help.h sdlscreen.h errors.h op_c.h windows.h input.h \
 | 
			
		||||
  palette.h shade.h
 | 
			
		||||
$(OBJDIR)/pversion.o: pversion.c
 | 
			
		||||
$(OBJDIR)/pxdouble.o: pxdouble.c global.h struct.h const.h sdlscreen.h misc.h \
 | 
			
		||||
  pxdouble.h pxwide.h
 | 
			
		||||
$(OBJDIR)/pxquad.o: pxquad.c global.h struct.h const.h sdlscreen.h misc.h pxquad.h
 | 
			
		||||
  graph.h pxdouble.h pxwide.h
 | 
			
		||||
$(OBJDIR)/pxquad.o: pxquad.c global.h struct.h const.h sdlscreen.h misc.h graph.h \
 | 
			
		||||
  pxquad.h
 | 
			
		||||
$(OBJDIR)/pxsimple.o: pxsimple.c global.h struct.h const.h sdlscreen.h misc.h \
 | 
			
		||||
  pxsimple.h
 | 
			
		||||
$(OBJDIR)/pxtall.o: pxtall.c global.h struct.h const.h sdlscreen.h misc.h pxtall.h \
 | 
			
		||||
  pxsimple.h
 | 
			
		||||
$(OBJDIR)/pxtall2.o: pxtall2.c global.h struct.h const.h sdlscreen.h misc.h \
 | 
			
		||||
  graph.h pxsimple.h
 | 
			
		||||
$(OBJDIR)/pxtall.o: pxtall.c global.h struct.h const.h sdlscreen.h misc.h graph.h \
 | 
			
		||||
  pxtall.h pxsimple.h
 | 
			
		||||
$(OBJDIR)/pxtall2.o: pxtall2.c global.h struct.h const.h sdlscreen.h misc.h graph.h \
 | 
			
		||||
  pxtall2.h
 | 
			
		||||
$(OBJDIR)/pxtriple.o: pxtriple.c global.h struct.h const.h sdlscreen.h misc.h \
 | 
			
		||||
  pxtriple.h
 | 
			
		||||
$(OBJDIR)/pxwide.o: pxwide.c global.h struct.h const.h sdlscreen.h misc.h pxwide.h
 | 
			
		||||
$(OBJDIR)/pxwide2.o: pxwide2.c global.h struct.h const.h sdlscreen.h misc.h \
 | 
			
		||||
  graph.h pxtriple.h
 | 
			
		||||
$(OBJDIR)/pxwide.o: pxwide.c global.h struct.h const.h sdlscreen.h misc.h graph.h \
 | 
			
		||||
  pxwide.h
 | 
			
		||||
$(OBJDIR)/pxwide2.o: pxwide2.c global.h struct.h const.h sdlscreen.h misc.h graph.h \
 | 
			
		||||
  pxwide2.h
 | 
			
		||||
$(OBJDIR)/readini.o: readini.c const.h global.h struct.h misc.h readini.h
 | 
			
		||||
$(OBJDIR)/readline.o: readline.c const.h struct.h global.h misc.h errors.h \
 | 
			
		||||
@ -73,5 +77,6 @@ $(OBJDIR)/text.o: text.c SFont.h struct.h const.h global.h sdlscreen.h io.h \
 | 
			
		||||
$(OBJDIR)/transform.o: transform.c global.h struct.h const.h transform.h engine.h \
 | 
			
		||||
  sdlscreen.h windows.h input.h help.h misc.h readline.h buttons.h \
 | 
			
		||||
  pages.h
 | 
			
		||||
$(OBJDIR)/version.o: version.c
 | 
			
		||||
$(OBJDIR)/windows.o: windows.c windows.h struct.h const.h global.h graph.h engine.h \
 | 
			
		||||
  misc.h sdlscreen.h errors.h
 | 
			
		||||
  misc.h sdlscreen.h errors.h input.h
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								SDL_image.dll
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								SDL_image.dll
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										1
									
								
								const.h
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								const.h
									
									
									
									
									
								
							@ -112,6 +112,7 @@ enum FILE_FORMATS
 | 
			
		||||
  FORMAT_C64,
 | 
			
		||||
  FORMAT_KCF,
 | 
			
		||||
  FORMAT_PAL,
 | 
			
		||||
  FORMAT_MISC, ///< Must be last of enum: others formats recognized by SDL_image
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/// Default format for 'save as'
 | 
			
		||||
 | 
			
		||||
@ -100,15 +100,35 @@ Libpng
 | 
			
		||||
  make install (long)
 | 
			
		||||
  Files created in /usr/local/include and /usr/local/lib ....
 | 
			
		||||
  
 | 
			
		||||
libjpeg (optional - improves SDL_image with JPEG reading)
 | 
			
		||||
  http://www.mirrorservice.org/sites/download.sourceforge.net/pub/sourceforge/l/project/li/libjpeg/libjpeg/
 | 
			
		||||
  jpegsr6.zip
 | 
			
		||||
  Uncompress in temporary directory
 | 
			
		||||
  ./configure --enable-shared
 | 
			
		||||
  make
 | 
			
		||||
  (make install doesn't work. Copy jpeglib.h, jmorecfg.h, jconfig.h in include, and libjpeg.a in lib)
 | 
			
		||||
  
 | 
			
		||||
libtiff (optional - improves SDL_image with TIFF reading)
 | 
			
		||||
  ftp://ftp.sgi.com/graphics/tiff/
 | 
			
		||||
  tiff-v3.4-tar.gz
 | 
			
		||||
  Uncompress in temporary directory
 | 
			
		||||
  ./configure i686-pc-mingw32
 | 
			
		||||
  make
 | 
			
		||||
  Don't use 'make install', copy tiff.h libtiff.a manually instead.
 | 
			
		||||
  
 | 
			
		||||
SDL_image:
 | 
			
		||||
  Requires: Libpng
 | 
			
		||||
  Requires optionally: libtiff
 | 
			
		||||
  Requires optionally: libjpeg
 | 
			
		||||
  http://www.mirrorservice.org/sites/download.sourceforge.net/pub/sourceforge/l/li/libsdl/
 | 
			
		||||
  SDL_image-1.2.6.zip
 | 
			
		||||
  SDL_image-1.2.8.zip
 | 
			
		||||
  Uncompress in temporary directory
 | 
			
		||||
  ./configure
 | 
			
		||||
  Check that png worked
 | 
			
		||||
  Check in the messages that png worked
 | 
			
		||||
  Optionally check if jpeg worked too
 | 
			
		||||
  Optionally check if tiff worked too
 | 
			
		||||
  make
 | 
			
		||||
  make install
 | 
			
		||||
  make install prefix=/usr/mingw
 | 
			
		||||
  
 | 
			
		||||
FreeType:
 | 
			
		||||
  http://www.mirrorservice.org/sites/download.sourceforge.net/pub/sourceforge/m/mi/mingw-cross/
 | 
			
		||||
 | 
			
		||||
@ -1,11 +1,19 @@
 | 
			
		||||
The following file:
 | 
			
		||||
The following file
 | 
			
		||||
 | 
			
		||||
	SDL_image.dll
 | 
			
		||||
 | 
			
		||||
is the runtime environment for the library SDL_image 1.2.70 by Sam Lantiga and Mattias Engdegård.
 | 
			
		||||
is the runtime environment for the library SDL_image 1.2.8 by Sam Lantiga and Mattias Engdegård.
 | 
			
		||||
 | 
			
		||||
This library is distributed under the terms of the GNU LGPL license:
 | 
			
		||||
http://www.gnu.org/copyleft/lesser.html
 | 
			
		||||
 | 
			
		||||
The source is available from the libraries page at the SDL website:
 | 
			
		||||
http://www.libsdl.org/
 | 
			
		||||
 | 
			
		||||
=========================
 | 
			
		||||
 | 
			
		||||
Compiled by yrizoud on 21/10/2009 with static builds of :
 | 
			
		||||
	libjpeg (JPEG library http://www.ijg.org/ release 6b of 27-Mar-1998 : jpegsr6.zip)
 | 
			
		||||
	libtiff (TIFF library ftp://ftp.sgi.com/graphics/tiff/ : tiff-v3.4-tar.gz)
 | 
			
		||||
And dynamic version of :
 | 
			
		||||
	libpng (http://www.libpng.org/pub/png/libpng.html) --> libpng13.dll requirement
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										7
									
								
								init.c
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								init.c
									
									
									
									
									
								
							@ -267,12 +267,7 @@ byte Parse_skin(SDL_Surface * gui, T_Gui_skin *gfx)
 | 
			
		||||
    return 1;
 | 
			
		||||
  }
 | 
			
		||||
  // Read the default palette
 | 
			
		||||
  for (i=0; i<256; i++)
 | 
			
		||||
  {
 | 
			
		||||
    gfx->Default_palette[i].R=SDLPal->colors[i].r;
 | 
			
		||||
    gfx->Default_palette[i].G=SDLPal->colors[i].g;
 | 
			
		||||
    gfx->Default_palette[i].B=SDLPal->colors[i].b;
 | 
			
		||||
  }
 | 
			
		||||
  Get_SDL_Palette(SDLPal, gfx->Default_palette);
 | 
			
		||||
 | 
			
		||||
  // Carré "noir"
 | 
			
		||||
  MC_Black = Get_SDL_pixel_8(gui,cursor_x,cursor_y);
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										131
									
								
								loadsave.c
									
									
									
									
									
								
							
							
						
						
									
										131
									
								
								loadsave.c
									
									
									
									
									
								
							@ -30,6 +30,7 @@
 | 
			
		||||
#ifndef __no_pnglib__
 | 
			
		||||
#include <png.h>
 | 
			
		||||
#endif
 | 
			
		||||
#include <SDL_image.h>
 | 
			
		||||
 | 
			
		||||
#include "buttons.h"
 | 
			
		||||
#include "const.h"
 | 
			
		||||
@ -123,10 +124,15 @@ void Load_PNG(void);
 | 
			
		||||
void Save_PNG(void);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// -- SDL_Image -------------------------------------------------------------
 | 
			
		||||
// (TGA, BMP, PNM, XPM, XCF, PCX, GIF, JPG, TIF, LBM, PNG)
 | 
			
		||||
void Load_SDL_Image(void);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void Init_preview(short width,short height,long size,int format,enum PIXEL_RATIO ratio);
 | 
			
		||||
 | 
			
		||||
T_Format File_formats[NB_KNOWN_FORMATS] = {
 | 
			
		||||
  {FORMAT_ALL_IMAGES, "(all)", NULL, NULL, NULL, 0, 0, "", "gif;png;bmp;pcx;pkm;lbm;iff;img;sci;scq;scf;scn;sco;pi1;pc1;cel;neo;kcf;pal;c64;koa"},
 | 
			
		||||
  {FORMAT_ALL_IMAGES, "(all)", NULL, NULL, NULL, 0, 0, "", "gif;png;bmp;pcx;pkm;lbm;iff;img;sci;scq;scf;scn;sco;pi1;pc1;cel;neo;kcf;pal;c64;koa;tga;pnm;xpm;xcf;jpg;jpeg;tif;tiff"},
 | 
			
		||||
  {FORMAT_ALL_FILES, "(*.*)", NULL, NULL, NULL, 0, 0, "", "*"},
 | 
			
		||||
  {FORMAT_GIF, " gif", Test_GIF, Load_GIF, Save_GIF, 1, 1, "gif", "gif"},
 | 
			
		||||
#ifndef __no_pnglib__
 | 
			
		||||
@ -145,6 +151,7 @@ T_Format File_formats[NB_KNOWN_FORMATS] = {
 | 
			
		||||
  {FORMAT_KCF, " kcf", Test_KCF, Load_KCF, Save_KCF, 0, 0, "kcf", "kcf"},
 | 
			
		||||
  {FORMAT_PAL, " pal", Test_PAL, Load_PAL, Save_PAL, 0, 0, "pal", "pal"},
 | 
			
		||||
  {FORMAT_C64, " c64", Test_C64, Load_C64, Save_C64, 1, 1, "c64", "c64;koa"},
 | 
			
		||||
  {FORMAT_MISC,"misc.", NULL, NULL, NULL, 1, 0,  "", "tga;pnm;xpm;xcf;jpg;jpeg;tif;tiff"},
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// Cette variable est alimentée après chargement réussi d'une image.
 | 
			
		||||
@ -617,6 +624,7 @@ void Load_image(byte image)
 | 
			
		||||
  if (Main_format>FORMAT_ALL_FILES)
 | 
			
		||||
  {
 | 
			
		||||
    format = Get_fileformat(Main_format);
 | 
			
		||||
    if (format->Test)
 | 
			
		||||
      format->Test();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -628,7 +636,7 @@ void Load_image(byte image)
 | 
			
		||||
    {
 | 
			
		||||
      format = Get_fileformat(index);
 | 
			
		||||
      // Loadable format
 | 
			
		||||
      if (format->Load == NULL)
 | 
			
		||||
      if (format->Test == NULL)
 | 
			
		||||
        continue;
 | 
			
		||||
        
 | 
			
		||||
      // On appelle le testeur du format:
 | 
			
		||||
@ -639,8 +647,26 @@ void Load_image(byte image)
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  if (File_error)
 | 
			
		||||
  {
 | 
			
		||||
    // Last try: with SDL_image
 | 
			
		||||
    Image_24b=0;
 | 
			
		||||
    Ratio_of_loaded_image=PIXEL_SIMPLE;
 | 
			
		||||
 | 
			
		||||
    Load_SDL_Image();
 | 
			
		||||
 | 
			
		||||
    if (File_error)
 | 
			
		||||
    { 
 | 
			
		||||
      // Sinon, l'appelant sera au courant de l'échec grace à File_error;
 | 
			
		||||
      // et si on s'apprêtait à faire un chargement définitif de l'image (pas
 | 
			
		||||
      // une preview), alors on flash l'utilisateur.
 | 
			
		||||
      if (Pixel_load_function!=Pixel_load_in_preview)
 | 
			
		||||
        Error(0);
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  // Si on a su déterminer avec succès le format du fichier:
 | 
			
		||||
  if (!File_error)
 | 
			
		||||
  {
 | 
			
		||||
    // On peut charger le fichier:
 | 
			
		||||
    Image_24b=0;
 | 
			
		||||
@ -648,6 +674,7 @@ void Load_image(byte image)
 | 
			
		||||
    // Dans certains cas il est possible que le chargement plante
 | 
			
		||||
    // après avoir modifié la palette. TODO
 | 
			
		||||
    format->Load();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (File_error>0)
 | 
			
		||||
  {
 | 
			
		||||
@ -663,6 +690,10 @@ void Load_image(byte image)
 | 
			
		||||
      if (Pixel_load_function==Pixel_load_in_current_screen)
 | 
			
		||||
      {
 | 
			
		||||
        // Cas d'un chargement dans l'image
 | 
			
		||||
        Hide_cursor();
 | 
			
		||||
        Cursor_shape=CURSOR_SHAPE_HOURGLASS;
 | 
			
		||||
        Display_cursor();
 | 
			
		||||
        Flush_update();
 | 
			
		||||
        if (Convert_24b_bitmap_to_256(Main_screen,Buffer_image_24b,Main_image_width,Main_image_height,Main_palette))
 | 
			
		||||
          File_error=2;
 | 
			
		||||
        else
 | 
			
		||||
@ -673,13 +704,13 @@ void Load_image(byte image)
 | 
			
		||||
      else
 | 
			
		||||
      {
 | 
			
		||||
        // Cas d'un chargement dans la brosse
 | 
			
		||||
        Hide_cursor();
 | 
			
		||||
        Cursor_shape=CURSOR_SHAPE_HOURGLASS;
 | 
			
		||||
        Display_cursor();
 | 
			
		||||
        Flush_update();
 | 
			
		||||
        if (Convert_24b_bitmap_to_256(Brush,Buffer_image_24b,Brush_width,Brush_height,Main_palette))
 | 
			
		||||
          File_error=2;
 | 
			
		||||
      }
 | 
			
		||||
        //if (!File_error)
 | 
			
		||||
        //  Palette_256_to_64(Main_palette);
 | 
			
		||||
        // Normalement plus besoin car 256 color natif, et c'etait probablement
 | 
			
		||||
        // un bug - yr
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    free(Buffer_image_24b);
 | 
			
		||||
@ -725,25 +756,22 @@ void Load_image(byte image)
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
  else
 | 
			
		||||
    // Sinon, l'appelant sera au courant de l'échec grace à File_error;
 | 
			
		||||
    // et si on s'apprêtait à faire un chargement définitif de l'image (pas
 | 
			
		||||
    // une preview), alors on flash l'utilisateur.
 | 
			
		||||
    if (Pixel_load_function!=Pixel_load_in_preview)
 | 
			
		||||
      Error(0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// -- Sauver n'importe quel type connu de fichier d'image (ou palette) ------
 | 
			
		||||
void Save_image(byte image)
 | 
			
		||||
{
 | 
			
		||||
  T_Format *format;
 | 
			
		||||
  
 | 
			
		||||
  // On place par défaut File_error à vrai au cas où on ne sache pas
 | 
			
		||||
  // sauver le format du fichier: (Est-ce vraiment utile??? Je ne crois pas!)
 | 
			
		||||
  File_error=1;
 | 
			
		||||
 | 
			
		||||
  Read_pixel_function=(image)?Read_pixel_from_current_screen:Read_pixel_from_brush;
 | 
			
		||||
 | 
			
		||||
  Get_fileformat(Main_fileformat)->Save();
 | 
			
		||||
  format = Get_fileformat(Main_fileformat);
 | 
			
		||||
  if (format->Save)
 | 
			
		||||
    format->Save();
 | 
			
		||||
 | 
			
		||||
  if (File_error)
 | 
			
		||||
    Error(0);
 | 
			
		||||
@ -6847,6 +6875,79 @@ void Save_PNG(void)
 | 
			
		||||
}
 | 
			
		||||
#endif  // __no_pnglib__
 | 
			
		||||
 | 
			
		||||
void Load_SDL_Image(void)
 | 
			
		||||
{
 | 
			
		||||
  char filename[MAX_PATH_CHARACTERS]; // Nom complet du fichier
 | 
			
		||||
  word x_pos,y_pos;
 | 
			
		||||
  // long file_size;
 | 
			
		||||
  dword pixel;
 | 
			
		||||
  long file_size;
 | 
			
		||||
  SDL_Surface * surface;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  Get_full_filename(filename,0);
 | 
			
		||||
  File_error=0;
 | 
			
		||||
  
 | 
			
		||||
  surface = IMG_Load(filename);
 | 
			
		||||
  
 | 
			
		||||
  if (!surface)
 | 
			
		||||
  {
 | 
			
		||||
    File_error=1;
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  file_size=File_length(filename);
 | 
			
		||||
  
 | 
			
		||||
  if (surface->format->BytesPerPixel == 1)
 | 
			
		||||
  {
 | 
			
		||||
    // 8bpp image
 | 
			
		||||
    
 | 
			
		||||
    Init_preview(surface->w, surface->h, file_size ,FORMAT_MISC, PIXEL_SIMPLE);
 | 
			
		||||
    // Read palette
 | 
			
		||||
    if (surface->format->palette)
 | 
			
		||||
    {
 | 
			
		||||
      Get_SDL_Palette(surface->format->palette, Main_palette);
 | 
			
		||||
      Set_palette(Main_palette);
 | 
			
		||||
      Remap_fileselector();
 | 
			
		||||
    }
 | 
			
		||||
    Main_image_width=surface->w;
 | 
			
		||||
    Main_image_height=surface->h;
 | 
			
		||||
    
 | 
			
		||||
    for (y_pos=0; y_pos<Main_image_height; y_pos++)
 | 
			
		||||
    {
 | 
			
		||||
      for (x_pos=0; x_pos<Main_image_width; x_pos++)
 | 
			
		||||
      {
 | 
			
		||||
        Pixel_load_function(x_pos,y_pos,Get_SDL_pixel_8(surface, x_pos, y_pos));
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    // Hi/Trucolor
 | 
			
		||||
    Init_preview_24b(surface->w, surface->h, file_size ,FORMAT_ALL_IMAGES);
 | 
			
		||||
    Main_image_width=surface->w;
 | 
			
		||||
    Main_image_height=surface->h;
 | 
			
		||||
    
 | 
			
		||||
    for (y_pos=0; y_pos<Main_image_height; y_pos++)
 | 
			
		||||
    {
 | 
			
		||||
      for (x_pos=0; x_pos<Main_image_width; x_pos++)
 | 
			
		||||
      {
 | 
			
		||||
        pixel = Get_SDL_pixel_hicolor(surface, x_pos, y_pos);
 | 
			
		||||
        Pixel_load_24b(
 | 
			
		||||
          x_pos,
 | 
			
		||||
          y_pos, 
 | 
			
		||||
          ((pixel & surface->format->Rmask) >> surface->format->Rshift) << surface->format->Rloss,
 | 
			
		||||
          ((pixel & surface->format->Gmask) >> surface->format->Gshift) << surface->format->Gloss,
 | 
			
		||||
          ((pixel & surface->format->Bmask) >> surface->format->Bshift) << surface->format->Bloss);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  SDL_FreeSurface(surface);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// Saves an image.
 | 
			
		||||
// This routine will only be called when all hope is lost, memory thrashed, etc
 | 
			
		||||
// It's the last chance to save anything, but the code has to be extremely careful,
 | 
			
		||||
 | 
			
		||||
@ -67,9 +67,9 @@ T_Format * Get_fileformat(byte format);
 | 
			
		||||
// -- File formats
 | 
			
		||||
 | 
			
		||||
#ifndef __no_pnglib__
 | 
			
		||||
#define NB_KNOWN_FORMATS         17    ///< Total number of known file formats.
 | 
			
		||||
#define NB_KNOWN_FORMATS         18    ///< Total number of known file formats.
 | 
			
		||||
#else
 | 
			
		||||
// Without pnglib
 | 
			
		||||
#define NB_KNOWN_FORMATS         16    ///< Total number of known file formats.
 | 
			
		||||
#define NB_KNOWN_FORMATS         17    ///< Total number of known file formats.
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								op_c.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								op_c.c
									
									
									
									
									
								
							@ -826,6 +826,7 @@ void CS_Generate(T_Cluster_set * cs, T_Occurrence_table * to)
 | 
			
		||||
	// On les remet dans le set
 | 
			
		||||
    CS_Set(cs,&Nouveau1);
 | 
			
		||||
    CS_Set(cs,&Nouveau2);
 | 
			
		||||
    
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1275,7 +1276,6 @@ int Convert_24b_bitmap_to_256(T_Bitmap256 dest,T_Bitmap24B source,int width,int
 | 
			
		||||
    if (table!=0)
 | 
			
		||||
      break;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (table!=0)
 | 
			
		||||
  {
 | 
			
		||||
    //Convert_24b_bitmap_to_256_Floyd_Steinberg(dest,source,width,height,palette,table);
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										41
									
								
								sdlscreen.c
									
									
									
									
									
								
							
							
						
						
									
										41
									
								
								sdlscreen.c
									
									
									
									
									
								
							@ -139,10 +139,11 @@ void Update_rect(short x, short y, unsigned short width, unsigned short height)
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Converts a SDL_Surface (indexed colors or RGB) into an array of bytes
 | 
			
		||||
// (indexed colors).
 | 
			
		||||
// If dest is NULL, it's allocated by malloc(). Otherwise, be sure to
 | 
			
		||||
// pass a buffer of the right dimensions.
 | 
			
		||||
///
 | 
			
		||||
/// Converts a SDL_Surface (indexed colors or RGB) into an array of bytes
 | 
			
		||||
/// (indexed colors).
 | 
			
		||||
/// If dest is NULL, it's allocated by malloc(). Otherwise, be sure to
 | 
			
		||||
/// pass a buffer of the right dimensions.
 | 
			
		||||
byte * Surface_to_bytefield(SDL_Surface *source, byte * dest)
 | 
			
		||||
{
 | 
			
		||||
  byte *src;
 | 
			
		||||
@ -185,13 +186,41 @@ SDL_Color Color_to_SDL_color(byte index)
 | 
			
		||||
  return color;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Reads a pixel in a SDL surface.
 | 
			
		||||
// Warning, this is only suitable for 8-bit surfaces.
 | 
			
		||||
/// Reads a pixel in a 8-bit SDL surface.
 | 
			
		||||
byte Get_SDL_pixel_8(SDL_Surface *bmp, int x, int y)
 | 
			
		||||
{
 | 
			
		||||
  return ((byte *)(bmp->pixels))[(y*bmp->pitch+x)];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Reads a pixel in a multi-byte SDL surface.
 | 
			
		||||
dword Get_SDL_pixel_hicolor(SDL_Surface *bmp, int x, int y)
 | 
			
		||||
{
 | 
			
		||||
  switch(bmp->format->BytesPerPixel)
 | 
			
		||||
  {
 | 
			
		||||
    case 4:
 | 
			
		||||
    default:
 | 
			
		||||
      return *((dword *)((byte *)bmp->pixels+(y*bmp->pitch+x*4)));
 | 
			
		||||
    case 3:
 | 
			
		||||
      return *(((dword *)((byte *)bmp->pixels+(y*bmp->pitch+x*3)))) & 0xFFFFFF;
 | 
			
		||||
    case 2:
 | 
			
		||||
      return *((word *)((byte *)bmp->pixels+(y*bmp->pitch+x*2)));
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Convert a SDL Palette to a grafx2 palette
 | 
			
		||||
void Get_SDL_Palette(const SDL_Palette * sdl_palette, T_Palette palette)
 | 
			
		||||
{
 | 
			
		||||
  int i;
 | 
			
		||||
  
 | 
			
		||||
  for (i=0; i<256; i++)
 | 
			
		||||
  {
 | 
			
		||||
    palette[i].R=sdl_palette->colors[i].r;
 | 
			
		||||
    palette[i].G=sdl_palette->colors[i].g;
 | 
			
		||||
    palette[i].B=sdl_palette->colors[i].b;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Clear_border(byte color)
 | 
			
		||||
{
 | 
			
		||||
  int width;
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										11
									
								
								sdlscreen.h
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								sdlscreen.h
									
									
									
									
									
								
							@ -42,9 +42,20 @@ byte* Screen_pixels;
 | 
			
		||||
 | 
			
		||||
void Update_rect(short x, short y, unsigned short width, unsigned short height);
 | 
			
		||||
void Flush_update(void);
 | 
			
		||||
///
 | 
			
		||||
/// Converts a SDL_Surface (indexed colors or RGB) into an array of bytes
 | 
			
		||||
/// (indexed colors).
 | 
			
		||||
/// If dest is NULL, it's allocated by malloc(). Otherwise, be sure to
 | 
			
		||||
/// pass a buffer of the right dimensions.
 | 
			
		||||
byte * Surface_to_bytefield(SDL_Surface *source, byte * dest);
 | 
			
		||||
/// Gets the RGB 24-bit color currently associated with a palette index.
 | 
			
		||||
SDL_Color Color_to_SDL_color(byte);
 | 
			
		||||
/// Reads a pixel in a 8-bit SDL surface.
 | 
			
		||||
byte Get_SDL_pixel_8(SDL_Surface *bmp, int x, int y);
 | 
			
		||||
/// Reads a pixel in a multi-byte SDL surface.
 | 
			
		||||
dword Get_SDL_pixel_hicolor(SDL_Surface *bmp, int x, int y);
 | 
			
		||||
/// Convert a SDL Palette to a grafx2 palette
 | 
			
		||||
void Get_SDL_Palette(const SDL_Palette * sdl_palette, T_Palette palette);
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// Clears the parts of screen that are outside of the editing area.
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user