author | ecalot
<ecalot> 2006-02-09 21:28:24 UTC |
committer | ecalot
<ecalot> 2006-02-09 21:28:24 UTC |
parent | b82046dd27bb2f68d2edbfcd78297d5ba32b1fee |
PR/doc/changelog.txt | +4 | -2 |
PR/src/lib/actions/export.c | +4 | -3 |
PR/src/lib/formats/bmp.c | +11 | -14 |
PR/src/lib/formats/pal.c | +4 | -4 |
diff --git a/PR/doc/changelog.txt b/PR/doc/changelog.txt index 7a6bbcf..e4d1a95 100644 --- a/PR/doc/changelog.txt +++ b/PR/doc/changelog.txt @@ -157,7 +157,7 @@ Versions: - Rewritten resource handling using dynamic structures - Support of partial list folder selection wildcards (e.g. vdungeon.dat@vdungeon/chopper/*.bmp) '*' and '?' using '&' as escape - * PR v1.2 (scheduled 2006-01-22) + * PR v1.2 (scheduled 2006-02-22) + Added order to support non-unique resource IDs + Inverted POP2 index names - Added --format option for unknown filename generation format @@ -185,7 +185,9 @@ Versions: x Check for memory leak x Finish python interface x Fix buffer overflows (in entered filename sizes) - x Transform flags from the hex form to the a-y form (a is 1, b is 2, c is 4...) + x Add support of 256 colours palettes + x Transform flags from the hex form to the [a-y]* form (a is 1, b is 2, c is 4...) + x Fork compress to code images as a new object in a separated file * PR v2.0 beta x Add full POP2 support * PR v2.0 diff --git a/PR/src/lib/actions/export.c b/PR/src/lib/actions/export.c index ddf20ef..ed6831c 100644 --- a/PR/src/lib/actions/export.c +++ b/PR/src/lib/actions/export.c @@ -46,6 +46,7 @@ export.c: Princed Resources : DAT Extractor #include "memory.h" #include "reslist.h" /* resIdcmp, resourceList primitives for the palette */ #include "unknown.h" +#include "palette.h" #include "bmp.h" #include "mid.h" @@ -86,7 +87,7 @@ int extract(const char* vFiledat,const char* vDirExt, tResourceList* r, int opti /* initialize palette buffer */ paletteBuffer=resourceListCreate(1); /* initialize the default palette */ - memcpy(image.pal,DEFAULT_PALETTE,SIZE_OF_PALETTE); + image.pal=createPalette(); /* main loop */ for (indexNumber=0;ok&&(indexNumber<numberOfItems);indexNumber++) { @@ -116,7 +117,7 @@ int extract(const char* vFiledat,const char* vDirExt, tResourceList* r, int opti case eResTypePalette: /* save and remember palette file */ /* Remember the palette for the next images * (because it's more probable to get all the images after its palette) */ - mLoadPalette(res.data,image,mReadGetVersion()); + applyPaletteFromData(res.data,res.size,&image); bufferedPalette=res.id; resourceListAdd(&paletteBuffer,&res); /* Export the palette */ @@ -138,7 +139,7 @@ int extract(const char* vFiledat,const char* vDirExt, tResourceList* r, int opti if (mReadFileInDatFileId(&readPalette)) { /* All right, it's not so bad, I can handle it! I'll buffer the new palette */ bufferedPalette=readPalette.id; - mLoadPalette(readPalette.data,image,mReadGetVersion()); + applyPaletteFromData(readPalette.data,readPalette.size,&image); resourceListAdd(&paletteBuffer,&readPalette); } /* else, that's bad, I'll have to use the previous palette, even if it is the default */ } /* else, good, the palette is buffered */ diff --git a/PR/src/lib/formats/bmp.c b/PR/src/lib/formats/bmp.c index 77823f8..65cd9d0 100644 --- a/PR/src/lib/formats/bmp.c +++ b/PR/src/lib/formats/bmp.c @@ -33,6 +33,7 @@ bmp.c: Princed Resources : BMP file support */ #include "bmp.h" +#include "palette.h" #include "common.h" #include "dat.h" #include "disk.h" @@ -96,6 +97,7 @@ int mWriteBitMap(tImage img,const char* vFile,int optionflag,const char* backupE unsigned long int width; const unsigned long int zero=0; char lineSerialization; + tColor* palette; FILE* bitmap; /* open file */ @@ -129,20 +131,15 @@ int mWriteBitMap(tImage img,const char* vFile,int optionflag,const char* backupE fwritelong (&zero ,bitmap); /* Important colours */ /* Write ColorTable */ - if (colours==2) { - /* Black & White */ - fwrite(FORMATS_BMP_PALETTE_BW,8,1,bitmap); /* 24-bit palette: #000000, #FFFFFF */ - } else { - /* Colours */ - for (a=0;a<colours;a++) { - color=img.pal[3*a+2]<<2; - fwritechar(&color,bitmap); /* Blue */ - color=img.pal[3*a+1]<<2; - fwritechar(&color,bitmap); /* Green */ - color=img.pal[3*a+0]<<2; - fwritechar(&color,bitmap); /* Red */ - fwritechar(&zero ,bitmap); /* alpha */ - } + getPalette(&img.pal,bits,&palette); + for (a=0;a<colours;a++) { + color=palette[a].b; + fwritechar(&color,bitmap); /* Blue */ + color=palette[a].g; + fwritechar(&color,bitmap); /* Green */ + color=palette[a].r; + fwritechar(&color,bitmap); /* Red */ + fwritechar(&zero ,bitmap); /* alpha */ } /* Write data */ diff --git a/PR/src/lib/formats/pal.c b/PR/src/lib/formats/pal.c index aa89820..445fd0e 100644 --- a/PR/src/lib/formats/pal.c +++ b/PR/src/lib/formats/pal.c @@ -47,7 +47,7 @@ static const char* enter="\r\n"; /* Public functions */ int mFormatExportPal(const unsigned char* data, char *vFileext,unsigned long int size,int optionflag,const char* backupExtension ) { - unsigned char* pal=malloc(240); + unsigned char* pal=malloc(256*4+50); unsigned char* aux=malloc(MAX_FILENAME_SIZE); int i; @@ -56,7 +56,7 @@ int mFormatExportPal(const unsigned char* data, char *vFileext,unsigned long int writeData(data,1,(char*)aux,size,optionflag,backupExtension); /* Convert palette from POP format to JASC format */ - strcpy((char*)pal,PAL_HEADER); + sprintf((char*)pal,"JASC-PAL\r\n%04d\r\n%d\r\n",100,16); for (i=0;i<16;i++) { strcpy((char*)aux,(char*)pal); sprintf((char*)pal,"%s%d %d %d%s", @@ -84,7 +84,7 @@ int mFormatImportPal(tResource *res,const char* vFile) { unsigned char* pals; unsigned char* pals1; unsigned char pals2[]=PAL_SAMPLE; - unsigned char palh []=PAL_HEADER; + unsigned char palh [30]; unsigned char* pal; unsigned char* pal2; char* data2; @@ -99,7 +99,7 @@ int mFormatImportPal(tResource *res,const char* vFile) { /* check size */ if ((res->size)<130) return 0; /* false */ - /* verify JASC pal header */ + /* TODO: fix, pal 256 support. verify JASC pal header */ while (palh[i]==(res->data)[i++]); if (i!=sizeof(palh)) return 0; /* false: palette differs with headers */