[layers] Updated from trunk.
git-svn-id: svn://pulkomandy.tk/GrafX2/branches/layers@1087 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
commit
3781dae7d3
@ -7,7 +7,7 @@ $(OBJDIR)/buttons.o: buttons.c const.h struct.h global.h misc.h graph.h engine.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
|
||||
input.h engine.h pages.h
|
||||
$(OBJDIR)/filesel.o: filesel.c const.h struct.h global.h misc.h errors.h io.h \
|
||||
windows.h sdlscreen.h loadsave.h mountlist.h engine.h readline.h \
|
||||
input.h help.h filesel.h
|
||||
@ -16,7 +16,7 @@ $(OBJDIR)/graph.o: graph.c global.h struct.h const.h engine.h buttons.h pages.h
|
||||
pxdouble.h pxtriple.h pxwide2.h pxtall2.h pxquad.h windows.h input.h
|
||||
$(OBJDIR)/help.o: help.c const.h struct.h global.h misc.h engine.h helpfile.h \
|
||||
help.h sdlscreen.h text.h keyboard.h windows.h input.h hotkeys.h \
|
||||
errors.h
|
||||
errors.h pages.h
|
||||
$(OBJDIR)/hotkeys.o: hotkeys.c struct.h const.h global.h hotkeys.h
|
||||
$(OBJDIR)/init.o: init.c const.h struct.h global.h graph.h buttons.h palette.h \
|
||||
help.h operatio.h misc.h errors.h keyboard.h io.h hotkeys.h setup.h \
|
||||
@ -71,7 +71,7 @@ $(OBJDIR)/setup.o: setup.c struct.h const.h io.h setup.h
|
||||
$(OBJDIR)/shade.o: shade.c global.h struct.h const.h graph.h engine.h misc.h \
|
||||
readline.h help.h sdlscreen.h windows.h input.h shade.h
|
||||
$(OBJDIR)/special.o: special.c const.h struct.h global.h graph.h engine.h windows.h \
|
||||
special.h
|
||||
special.h pages.h misc.h buttons.h
|
||||
$(OBJDIR)/text.o: text.c SFont.h struct.h const.h global.h sdlscreen.h io.h \
|
||||
errors.h
|
||||
$(OBJDIR)/transform.o: transform.c global.h struct.h const.h transform.h engine.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, ICO)
|
||||
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, 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, 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;ico"},
|
||||
{FORMAT_ALL_FILES, "(*.*)", NULL, NULL, NULL, 0, 0, 0, "", "*"},
|
||||
{FORMAT_GIF, " gif", Test_GIF, Load_GIF, Save_GIF, 1, 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, 0, "kcf", "kcf"},
|
||||
{FORMAT_PAL, " pal", Test_PAL, Load_PAL, Save_PAL, 0, 0, 0, "pal", "pal"},
|
||||
{FORMAT_C64, " c64", Test_C64, Load_C64, Save_C64, 1, 1, 0, "c64", "c64;koa"},
|
||||
{FORMAT_MISC,"misc.", NULL, NULL, NULL, 1, 0, 0, "", "tga;pnm;xpm;xcf;jpg;jpeg;tif;tiff;ico"},
|
||||
};
|
||||
|
||||
// Cette variable est alimentée après chargement réussi d'une image.
|
||||
@ -620,6 +627,7 @@ void Load_image(byte image)
|
||||
if (Main_format>FORMAT_ALL_FILES)
|
||||
{
|
||||
format = Get_fileformat(Main_format);
|
||||
if (format->Test)
|
||||
format->Test();
|
||||
}
|
||||
|
||||
@ -631,7 +639,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:
|
||||
@ -642,8 +650,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;
|
||||
@ -651,6 +677,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)
|
||||
{
|
||||
@ -666,6 +693,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
|
||||
@ -676,13 +707,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);
|
||||
@ -728,18 +759,13 @@ 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;
|
||||
@ -767,7 +793,9 @@ void Save_image(byte image)
|
||||
}
|
||||
|
||||
|
||||
Get_fileformat(Main_fileformat)->Save();
|
||||
format = Get_fileformat(Main_fileformat);
|
||||
if (format->Save)
|
||||
format->Save();
|
||||
|
||||
if (File_error)
|
||||
Error(0);
|
||||
@ -6930,6 +6958,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,
|
||||
|
||||
@ -68,9 +68,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