From 7bde7d90ce25d28e9774e1d611a389a0ba427474 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Mon, 13 Jul 2009 08:09:40 +0000 Subject: [PATCH] Quick-made support for Neochrome files. Loading works, saving leaves parts of the header uninitialized. Neochrome may or may not like it. git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@911 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- const.h | 11 ++-- gfx2.cfg | Bin 10133 -> 10133 bytes loadsave.c | 177 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 183 insertions(+), 5 deletions(-) diff --git a/const.h b/const.h index 6c604d5c..c0fcc269 100644 --- a/const.h +++ b/const.h @@ -90,14 +90,14 @@ // -- File formats #ifndef __no_pnglib__ +#define NB_KNOWN_FORMATS 14 ///< Total number of known file formats. +#define NB_FORMATS_LOAD 14 ///< Number of file formats that grafx2 can load. +#define NB_FORMATS_SAVE 14 ///< Number of file formats that grafx2 can save. +#else +// Without pnglib #define NB_KNOWN_FORMATS 13 ///< Total number of known file formats. #define NB_FORMATS_LOAD 13 ///< Number of file formats that grafx2 can load. #define NB_FORMATS_SAVE 13 ///< Number of file formats that grafx2 can save. -#else -// Without pnglib -#define NB_KNOWN_FORMATS 12 ///< Total number of known file formats. -#define NB_FORMATS_LOAD 12 ///< Number of file formats that grafx2 can load. -#define NB_FORMATS_SAVE 12 ///< Number of file formats that grafx2 can save. #endif /// List of file formats recognized by grafx2 @@ -114,6 +114,7 @@ enum FILE_FORMATS FORMAT_PI1, FORMAT_PC1, FORMAT_CEL, + FORMAT_NEO, FORMAT_KCF, FORMAT_PAL, FORMAT_PNG diff --git a/gfx2.cfg b/gfx2.cfg index 00f063575534f2fe1325217f0fc194bb9d34460b..a02e005c348bed9e79b9b9e14dc8e34e45e0c912 100644 GIT binary patch delta 156 zcmY+2I}(C000lP$1q~WR{EI0-Z(_}DtSqp%kqo^@a3-Y(@E)GTSh6#3X7_bQDN-vWh4sG ZhaUD>eQkTpRBHZz>lfHZ`Ei$%5kK&E6H@>H delta 118 zcmbR0Kh=Lj4YM{Q11AFmBNGD`kYr}y29hicJV26_ffq=!G4KIN1_llWb_V{=c zH#hL}h-_})X5rY}qs-0-QUnAbH9%_e29-yXFQ^Dio}?>4);x_pos++) + { + PI1_8b_to_16p(ptr,pixels+(x_pos<<4)); + ptr+=8; + } + for (x_pos=0;x_pos<320;x_pos++) + Pixel_load_function(x_pos,y_pos,pixels[x_pos]); + } + } + } + else + File_error=1; + free(buffer); + } + else + File_error=1; + fclose(file); + } + else + File_error=1; +} + +void Save_NEO(void) +{ + char filename[MAX_PATH_CHARACTERS]; // Nom complet du fichier + FILE *file; + short x_pos,y_pos; + byte * buffer; + byte * ptr; + byte pixels[320]; + + Get_full_filename(filename,0); + + File_error=0; + // Ouverture du fichier + if ((file=fopen(filename,"wb"))) + { + // allocation d'un buffer mémoire + buffer=(byte *)malloc(32128); + // Codage de la résolution + buffer[0]=0x00; + buffer[1]=0x00; + buffer[2]=0x00; + buffer[3]=0x00; + // Codage de la palette + PI1_code_palette((byte *)Main_palette,buffer+4); + // Codage de l'image + ptr=buffer+128; + for (y_pos=0;y_pos<200;y_pos++) + { + // Codage de la ligne + memset(pixels,0,320); + if (y_pos>4);x_pos++) + { + PI1_16p_to_8b(pixels+(x_pos<<4),ptr); + ptr+=8; + } + } + + if (Write_bytes(file,buffer,32128)) + { + fclose(file); + } + else // Error d'écriture (disque plein ou protégé) + { + fclose(file); + remove(filename); + File_error=1; + } + // Libération du buffer mémoire + free(buffer); + } + else + { + fclose(file); + remove(filename); + File_error=1; + } +} + ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// //////////////////////////////////// PNG ////////////////////////////////////