author | ecalot
<ecalot> 2006-02-15 04:28:36 UTC |
committer | ecalot
<ecalot> 2006-02-15 04:28:36 UTC |
parent | 2598ac4b83c00723a7b3179512c71a03eaccb8c8 |
PR/src/include/bitmap.h | +1 | -1 |
PR/src/include/bmp.h | +1 | -1 |
PR/src/include/common.h | +3 | -2 |
PR/src/include/compress.h | +1 | -30 |
PR/src/include/image.h | +8 | -27 |
PR/src/include/palette.h | +1 | -1 |
PR/src/include/png.h | +1 | -1 |
PR/src/lib/compression/rlev_decompress.c | +3 | -3 |
PR/src/lib/formats/bmp.c | +2 | -1 |
PR/src/lib/layers/autodetect.c | +1 | -1 |
PR/src/lib/layers/dat.c | +1 | -1 |
PR/src/lib/layers/memory.c | +1 | -1 |
PR/src/lib/object/image/image16.c | +1 | -0 |
PR/src/lib/object/image/image2.c | +1 | -0 |
PR/src/lib/object/image/image256.c | +1 | -0 |
PR/src/lib/object/image/image_common.c | +1 | -0 |
PR/src/lib/object/palette/pop1_16c.c | +6 | -4 |
PR/src/lib/object/palette/pop2_256c.c | +6 | -4 |
PR/src/lib/object/palette/pop2_4bit.c | +6 | -4 |
diff --git a/PR/src/include/bitmap.h b/PR/src/include/bitmap.h index d36fb5f..3a26232 100644 --- a/PR/src/include/bitmap.h +++ b/PR/src/include/bitmap.h @@ -36,7 +36,7 @@ bmp.h: Princed Resources : BMP file support headers #define _BMP_H_ #include "reslist.h" /* tResource */ -#include "compress.h" /* tImage */ +#include "image.h" /* tImage */ #define FORMATS_BMP_PALETTE_BW "\x00\x00\x00\0\xFF\xFF\xFF" diff --git a/PR/src/include/bmp.h b/PR/src/include/bmp.h index d36fb5f..3a26232 100644 --- a/PR/src/include/bmp.h +++ b/PR/src/include/bmp.h @@ -36,7 +36,7 @@ bmp.h: Princed Resources : BMP file support headers #define _BMP_H_ #include "reslist.h" /* tResource */ -#include "compress.h" /* tImage */ +#include "image.h" /* tImage */ #define FORMATS_BMP_PALETTE_BW "\x00\x00\x00\0\xFF\xFF\xFF" diff --git a/PR/src/include/common.h b/PR/src/include/common.h index 0c15939..0da982f 100644 --- a/PR/src/include/common.h +++ b/PR/src/include/common.h @@ -47,7 +47,7 @@ common.h: Princed Resources : Defines and prototypes common to all PR code /* User configuration defines */ #ifndef WIN32 - #define UNIX +#define UNIX #endif #ifdef WIN32 @@ -138,7 +138,8 @@ typedef enum { | Command Line specific options | \***************************************************************/ -#define PR_IGNORE_RAW_OPTION +/*#define PR_IGNORE_RAW_OPTION*/ +#define DEBUG_RESPRINT #ifndef PR_IGNORE_RAW_OPTION #define PARSING_OPTRAW ,{"raw", no_argument, 0,'w'}, diff --git a/PR/src/include/compress.h b/PR/src/include/compress.h index 4907bff..606ad79 100644 --- a/PR/src/include/compress.h +++ b/PR/src/include/compress.h @@ -19,7 +19,7 @@ */ /* -compress.h: Princed Resources : Image compression headers +compress.h: Princed Resources : Compression headers \xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf Copyright 2003 Princed Development Team Created: 24 Aug 2003 @@ -34,20 +34,6 @@ compress.h: Princed Resources : Image compression headers #ifndef _COMPRESS_H_ #define _COMPRESS_H_ -typedef struct { /* TODO: move to image.h */ - unsigned char r; - unsigned char g; - unsigned char b; -}tColor; - -typedef struct { - tColor p8[256]; - tColor p4[16]; - tColor p1[2]; -}tPalette; - -#define SIZE_OF_PALETTE 3*16 /* TODO: erase this line */ - #define COMPRESS_RAW 0x00 #define COMPRESS_RLE_LR 0x01 #define COMPRESS_RLE_UD 0x02 @@ -60,28 +46,13 @@ typedef struct { #define COMPRESS_RESULT_WARNING -1 #define COMPRESS_RESULT_SUCCESS 0 -typedef struct { /* TODO: move to image.h */ - int width; - int widthInBytes; - int height; - unsigned char* pix; - tPalette pal; - unsigned char type; /* XY where X is F for 8 bits, B for 4 bits and 0 for 1 bit; Y=algorithm */ -}tImage; - /* Prototypes */ -int mCompressGraphic(unsigned char** a,tImage* i, int* size); -int mExpandGraphic (const unsigned char* array,tImage *image, int size); - #define cLevel(a) if (compressionLevel>=a) #define cHigh if (compressionHigher) #define setHigh compressionHigher=1 #define unsetHigh compressionHigher=0 -#define getCarry(a) ((((a)>>4)&7)+1) -#define getAlgor(a) a&0x4F /* 0x0F */ - /* private declarations */ /***************************************************************\ diff --git a/PR/src/include/image.h b/PR/src/include/image.h index fe09811..8a7214e 100644 --- a/PR/src/include/image.h +++ b/PR/src/include/image.h @@ -19,9 +19,9 @@ */ /* -compress.h: Princed Resources : Image compression headers -\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf - Copyright 2003 Princed Development Team +image.h: Princed Resources : Image handling headers +\xaf\xaf\xaf\xaf\xaf\xaf\xaf + Copyright 2003, 2004, 2005, 2006 Princed Development Team Created: 24 Aug 2003 Author: Enrique Calot <ecalot.cod@princed.com.ar> @@ -31,10 +31,10 @@ compress.h: Princed Resources : Image compression headers DO NOT remove this copyright notice */ -#ifndef _COMPRESS_H_ -#define _COMPRESS_H_ +#ifndef _IMAGE_H_ +#define _IMAGE_H_ -typedef struct { /* TODO: move to image.h */ +typedef struct { unsigned char r; unsigned char g; unsigned char b; @@ -46,21 +46,7 @@ typedef struct { tColor p1[2]; }tPalette; -#define SIZE_OF_PALETTE 3*16 /* TODO: erase this line */ - -#define COMPRESS_RAW 0x00 -#define COMPRESS_RLE_LR 0x01 -#define COMPRESS_RLE_UD 0x02 -#define COMPRESS_LZG_LR 0x03 -#define COMPRESS_LZG_UD 0x04 - -#define COMPRESS_WORKING_ALGORITHMS 5 - -#define COMPRESS_RESULT_FATAL -2 -#define COMPRESS_RESULT_WARNING -1 -#define COMPRESS_RESULT_SUCCESS 0 - -typedef struct { /* TODO: move to image.h */ +typedef struct { int width; int widthInBytes; int height; @@ -74,12 +60,7 @@ typedef struct { /* TODO: move to image.h */ int mCompressGraphic(unsigned char** a,tImage* i, int* size); int mExpandGraphic (const unsigned char* array,tImage *image, int size); -#define cLevel(a) if (compressionLevel>=a) -#define cHigh if (compressionHigher) -#define setHigh compressionHigher=1 -#define unsetHigh compressionHigher=0 - -#define getCarry(a) ((a)>>6) +#define getCarry(a) ((((a)>>4)&7)+1) #define getAlgor(a) a&0x4F #endif diff --git a/PR/src/include/palette.h b/PR/src/include/palette.h index df286f3..e869dd5 100644 --- a/PR/src/include/palette.h +++ b/PR/src/include/palette.h @@ -34,7 +34,7 @@ pal.h: Princed Resources : JASC PAL files support headers #ifndef _PALETTE_H_ #define _PALETTE_H_ -#include "compress.h" /* tPalette, tImage */ +#include "image.h" /* tPalette, tImage */ #define SAMPLE_PAL16 {\ {0x00,0x00,0x00},\ diff --git a/PR/src/include/png.h b/PR/src/include/png.h index d36fb5f..3a26232 100644 --- a/PR/src/include/png.h +++ b/PR/src/include/png.h @@ -36,7 +36,7 @@ bmp.h: Princed Resources : BMP file support headers #define _BMP_H_ #include "reslist.h" /* tResource */ -#include "compress.h" /* tImage */ +#include "image.h" /* tImage */ #define FORMATS_BMP_PALETTE_BW "\x00\x00\x00\0\xFF\xFF\xFF" diff --git a/PR/src/lib/compression/rlev_decompress.c b/PR/src/lib/compression/rlev_decompress.c index 989efd1..25c901a 100644 --- a/PR/src/lib/compression/rlev_decompress.c +++ b/PR/src/lib/compression/rlev_decompress.c @@ -22,7 +22,7 @@ rlec_uncompress.c: Princed Resources : Image Compression Library : \xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf Run length encoding with checksum decompressor - Copyright 2003, 2004 Princed Development Team + Copyright 2003, 2004, 2005, 2006 Princed Development Team Created: 24 Aug 2003 Author: Enrique Calot <ecalot.cod@princed.com.ar> @@ -53,7 +53,7 @@ int expandRleC(const unsigned char* input, int inputSize, /* main loop */ while (iCursor<inputSize) { rep=(input[iCursor++]); -printf("o=%d i=%d\n",oCursor,iCursor); +/*printf("o=%d i=%d\n",oCursor,iCursor);*/ if ((done)||(oCursor%verif)) { done=0; if (rep&0x80) { /* repeat */ @@ -90,7 +90,7 @@ printf("o=%d i=%d\n",oCursor,iCursor); } -printf("done=%d i=%d but=%d\n",done,iCursor,inputSize); +/*printf("done=%d i=%d but=%d\n",done,iCursor,inputSize);*/ *outputSize=oCursor; return (rep==1)?COMPRESS_RESULT_SUCCESS:COMPRESS_RESULT_WARNING; } diff --git a/PR/src/lib/formats/bmp.c b/PR/src/lib/formats/bmp.c index 5c8951e..6fce1ab 100644 --- a/PR/src/lib/formats/bmp.c +++ b/PR/src/lib/formats/bmp.c @@ -33,11 +33,12 @@ bmp.c: Princed Resources : BMP file support */ #include "bmp.h" -#include "palette.h" #include "common.h" +#include "compress.h" #include "dat.h" #include "disk.h" #include "memory.h" +#include "palette.h" #include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/PR/src/lib/layers/autodetect.c b/PR/src/lib/layers/autodetect.c index 29ed9c9..e6910af 100644 --- a/PR/src/lib/layers/autodetect.c +++ b/PR/src/lib/layers/autodetect.c @@ -65,7 +65,7 @@ int verifyPaletteHeader(const unsigned char *array, int size) { return ( ((size==101)&&(!array[2])&&(!array[3])&&(array[4]==0x10)) || - ((size==(256*3))&&isA64kPalette(array,size)) + ((size==(256*3+1)||size==(320*3+1))&&isA64kPalette(array+1,size-1)) ); } diff --git a/PR/src/lib/layers/dat.c b/PR/src/lib/layers/dat.c index cc21500..361ef88 100644 --- a/PR/src/lib/layers/dat.c +++ b/PR/src/lib/layers/dat.c @@ -111,7 +111,7 @@ void dat_datIndexToHuman(char* to, const char* from) { to[1]=from[2]; to[2]=from[1]; to[3]=from[0]; - to[5]=0; + to[4]=0; /* shift */ if (to[0]||to[1]||to[2]||to[3]) diff --git a/PR/src/lib/layers/memory.c b/PR/src/lib/layers/memory.c index b8c85bb..30ee27c 100644 --- a/PR/src/lib/layers/memory.c +++ b/PR/src/lib/layers/memory.c @@ -58,7 +58,7 @@ char* strToLower(const char* txt) { static char ret[5]; char* r=ret; while (*txt) { - *r=(('A'<=(*txt)) && ((*txt)<='Z'))?(*txt)|0x20:*txt; + *r=(((unsigned char)'A'<=(unsigned char)(*txt)) && ((unsigned char)(*txt)<=(unsigned char)'Z'))?(*txt)|0x20:*txt; r++; txt++; } diff --git a/PR/src/lib/object/image/image16.c b/PR/src/lib/object/image/image16.c index d90a859..7cec2ba 100644 --- a/PR/src/lib/object/image/image16.c +++ b/PR/src/lib/object/image/image16.c @@ -35,6 +35,7 @@ compress.c: Princed Resources : Image Compression Library #include <stdio.h> #include <string.h> #include "compress.h" +#include "image.h" #include "memory.h" #include "disk.h" /* array2short */ diff --git a/PR/src/lib/object/image/image2.c b/PR/src/lib/object/image/image2.c index d90a859..7cec2ba 100644 --- a/PR/src/lib/object/image/image2.c +++ b/PR/src/lib/object/image/image2.c @@ -35,6 +35,7 @@ compress.c: Princed Resources : Image Compression Library #include <stdio.h> #include <string.h> #include "compress.h" +#include "image.h" #include "memory.h" #include "disk.h" /* array2short */ diff --git a/PR/src/lib/object/image/image256.c b/PR/src/lib/object/image/image256.c index d90a859..7cec2ba 100644 --- a/PR/src/lib/object/image/image256.c +++ b/PR/src/lib/object/image/image256.c @@ -35,6 +35,7 @@ compress.c: Princed Resources : Image Compression Library #include <stdio.h> #include <string.h> #include "compress.h" +#include "image.h" #include "memory.h" #include "disk.h" /* array2short */ diff --git a/PR/src/lib/object/image/image_common.c b/PR/src/lib/object/image/image_common.c index d90a859..7cec2ba 100644 --- a/PR/src/lib/object/image/image_common.c +++ b/PR/src/lib/object/image/image_common.c @@ -35,6 +35,7 @@ compress.c: Princed Resources : Image Compression Library #include <stdio.h> #include <string.h> #include "compress.h" +#include "image.h" #include "memory.h" #include "disk.h" /* array2short */ diff --git a/PR/src/lib/object/palette/pop1_16c.c b/PR/src/lib/object/palette/pop1_16c.c index f4a87b3..e066943 100644 --- a/PR/src/lib/object/palette/pop1_16c.c +++ b/PR/src/lib/object/palette/pop1_16c.c @@ -116,6 +116,7 @@ int readPalette(tPalette* p, unsigned char* data, int dataSize) { int i,bits=0; *p=createPalette(); printf("reading a palette from data (%d)\n",dataSize); + /* TODO: validate checksum */ switch (dataSize) { case 101: @@ -126,11 +127,12 @@ int readPalette(tPalette* p, unsigned char* data, int dataSize) { } bits=4; break; - case 3*256: + case 3*256+1: + case 3*320+1: for (i=0;i<256;i++) { - c[i].r=data[(i*3)+0]<<2; - c[i].g=data[(i*3)+1]<<2; - c[i].b=data[(i*3)+2]<<2; + c[i].r=data[(i*3)+1]<<2; + c[i].g=data[(i*3)+2]<<2; + c[i].b=data[(i*3)+3]<<2; } bits=8; break; diff --git a/PR/src/lib/object/palette/pop2_256c.c b/PR/src/lib/object/palette/pop2_256c.c index f4a87b3..e066943 100644 --- a/PR/src/lib/object/palette/pop2_256c.c +++ b/PR/src/lib/object/palette/pop2_256c.c @@ -116,6 +116,7 @@ int readPalette(tPalette* p, unsigned char* data, int dataSize) { int i,bits=0; *p=createPalette(); printf("reading a palette from data (%d)\n",dataSize); + /* TODO: validate checksum */ switch (dataSize) { case 101: @@ -126,11 +127,12 @@ int readPalette(tPalette* p, unsigned char* data, int dataSize) { } bits=4; break; - case 3*256: + case 3*256+1: + case 3*320+1: for (i=0;i<256;i++) { - c[i].r=data[(i*3)+0]<<2; - c[i].g=data[(i*3)+1]<<2; - c[i].b=data[(i*3)+2]<<2; + c[i].r=data[(i*3)+1]<<2; + c[i].g=data[(i*3)+2]<<2; + c[i].b=data[(i*3)+3]<<2; } bits=8; break; diff --git a/PR/src/lib/object/palette/pop2_4bit.c b/PR/src/lib/object/palette/pop2_4bit.c index f4a87b3..e066943 100644 --- a/PR/src/lib/object/palette/pop2_4bit.c +++ b/PR/src/lib/object/palette/pop2_4bit.c @@ -116,6 +116,7 @@ int readPalette(tPalette* p, unsigned char* data, int dataSize) { int i,bits=0; *p=createPalette(); printf("reading a palette from data (%d)\n",dataSize); + /* TODO: validate checksum */ switch (dataSize) { case 101: @@ -126,11 +127,12 @@ int readPalette(tPalette* p, unsigned char* data, int dataSize) { } bits=4; break; - case 3*256: + case 3*256+1: + case 3*320+1: for (i=0;i<256;i++) { - c[i].r=data[(i*3)+0]<<2; - c[i].g=data[(i*3)+1]<<2; - c[i].b=data[(i*3)+2]<<2; + c[i].r=data[(i*3)+1]<<2; + c[i].g=data[(i*3)+2]<<2; + c[i].b=data[(i*3)+3]<<2; } bits=8; break;