git » fp-git.git » commit 6959098

o Solved last compression bug

author ecalot
2003-10-23 16:38:16 UTC
committer ecalot
2003-10-23 16:38:16 UTC
parent 3d3ff5f364741ec5bf7e30e9699a40c9c6921aa4

o Solved last compression bug

PR/src/lib/actions/import.c +7 -6
PR/src/lib/compression/rle_compress.c +6 -4
PR/src/lib/compression/rle_decompress.c +6 -4
PR/src/lib/compression/rlev_decompress.c +6 -4
PR/src/lib/object/image/image16.c +6 -4
PR/src/lib/object/image/image2.c +6 -4
PR/src/lib/object/image/image256.c +6 -4
PR/src/lib/object/image/image_common.c +6 -4

diff --git a/PR/src/lib/actions/import.c b/PR/src/lib/actions/import.c
index 9d9542a..d790985 100644
--- a/PR/src/lib/actions/import.c
+++ b/PR/src/lib/actions/import.c
@@ -116,14 +116,14 @@ char mAddCompiledFileToDatFile(FILE* fp,unsigned char** data, tResource *res) {
 		case 2: //compile bitmap
 			return mFormatCompileBmp(*data,fp,res);
 		case 3: //compile wave
-			mFormatCompileWav(*data,fp,res);
-			break;
+			return mFormatCompileWav(*data,fp,res);
 		case 4: //compile midi
-			mFormatCompileMid(*data,fp,res);
-			break;
+			return mFormatCompileMid(*data,fp,res);
 		case 6: //compile palette
 			//TODO: make mFormatCompilePal and stop using char** for data
-			mImportPalette(data,&((*res).size));
+			if (!mImportPalette(data,&((*res).size))) {
+				return 0;
+			}
 		case 1:
 		case 5:
 		default:
@@ -137,6 +137,7 @@ char mAddCompiledFileToDatFile(FILE* fp,unsigned char** data, tResource *res) {
 |                    M A I N   F U N C T I O N                  |
 \***************************************************************/
 //TODO: delete this function
+/*
 char mSaveFile(char* vFile,unsigned char *d, int s) {
 	FILE *fp;
 
@@ -148,7 +149,7 @@ char mSaveFile(char* vFile,unsigned char *d, int s) {
 		return 1;
 	}
 }
-
+*/
 int compile(char* vFiledat, char* vDirExt, tResource* r[], char opt) {
 	/*
 		Return values:
diff --git a/PR/src/lib/compression/rle_compress.c b/PR/src/lib/compression/rle_compress.c
index 87cebcd..b0b2f83 100644
--- a/PR/src/lib/compression/rle_compress.c
+++ b/PR/src/lib/compression/rle_compress.c
@@ -91,7 +91,9 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
   char* cursorData  = data;
   char* counter;
   char* cursorPix   = (*img).pix;
-  char* imgEnd      = (*img).pix+((*img).size>>1)-1;
+  char* imgEnd      = (*img).pix+(
+		(((*img).width+1)>>1)*(img->height)
+	);
 
   while (cursorPix<imgEnd) {
 		//Step 1: Create counter
@@ -99,9 +101,9 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 
 		//Step 2: Look and copy the string until a repeated byte is found
 		while ((cursorPix<imgEnd)&&(*cursorPix!=*(cursorPix+1))&&((*counter)!=127)) {
-			cursorPix++;
+			cursorPix++; //TODO idem
 			(*counter)++;
-			*(cursorData)=*(cursorPix-1);
+			*(cursorData)=       *(cursorPix-1);
 			cursorData++;
 		}
 
@@ -112,7 +114,7 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 				(*counter)--;
 			}
 			cursorPix++; //TODO poner esta linea abajo
-			*(cursorData)=*(cursorPix-1); //Print repeated char
+			*(cursorData)=     *(cursorPix-1); //Print repeated char
 			cursorData++;
 		}
 	}
diff --git a/PR/src/lib/compression/rle_decompress.c b/PR/src/lib/compression/rle_decompress.c
index 87cebcd..b0b2f83 100644
--- a/PR/src/lib/compression/rle_decompress.c
+++ b/PR/src/lib/compression/rle_decompress.c
@@ -91,7 +91,9 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
   char* cursorData  = data;
   char* counter;
   char* cursorPix   = (*img).pix;
-  char* imgEnd      = (*img).pix+((*img).size>>1)-1;
+  char* imgEnd      = (*img).pix+(
+		(((*img).width+1)>>1)*(img->height)
+	);
 
   while (cursorPix<imgEnd) {
 		//Step 1: Create counter
@@ -99,9 +101,9 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 
 		//Step 2: Look and copy the string until a repeated byte is found
 		while ((cursorPix<imgEnd)&&(*cursorPix!=*(cursorPix+1))&&((*counter)!=127)) {
-			cursorPix++;
+			cursorPix++; //TODO idem
 			(*counter)++;
-			*(cursorData)=*(cursorPix-1);
+			*(cursorData)=       *(cursorPix-1);
 			cursorData++;
 		}
 
@@ -112,7 +114,7 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 				(*counter)--;
 			}
 			cursorPix++; //TODO poner esta linea abajo
-			*(cursorData)=*(cursorPix-1); //Print repeated char
+			*(cursorData)=     *(cursorPix-1); //Print repeated char
 			cursorData++;
 		}
 	}
diff --git a/PR/src/lib/compression/rlev_decompress.c b/PR/src/lib/compression/rlev_decompress.c
index 87cebcd..b0b2f83 100644
--- a/PR/src/lib/compression/rlev_decompress.c
+++ b/PR/src/lib/compression/rlev_decompress.c
@@ -91,7 +91,9 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
   char* cursorData  = data;
   char* counter;
   char* cursorPix   = (*img).pix;
-  char* imgEnd      = (*img).pix+((*img).size>>1)-1;
+  char* imgEnd      = (*img).pix+(
+		(((*img).width+1)>>1)*(img->height)
+	);
 
   while (cursorPix<imgEnd) {
 		//Step 1: Create counter
@@ -99,9 +101,9 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 
 		//Step 2: Look and copy the string until a repeated byte is found
 		while ((cursorPix<imgEnd)&&(*cursorPix!=*(cursorPix+1))&&((*counter)!=127)) {
-			cursorPix++;
+			cursorPix++; //TODO idem
 			(*counter)++;
-			*(cursorData)=*(cursorPix-1);
+			*(cursorData)=       *(cursorPix-1);
 			cursorData++;
 		}
 
@@ -112,7 +114,7 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 				(*counter)--;
 			}
 			cursorPix++; //TODO poner esta linea abajo
-			*(cursorData)=*(cursorPix-1); //Print repeated char
+			*(cursorData)=     *(cursorPix-1); //Print repeated char
 			cursorData++;
 		}
 	}
diff --git a/PR/src/lib/object/image/image16.c b/PR/src/lib/object/image/image16.c
index 87cebcd..b0b2f83 100644
--- a/PR/src/lib/object/image/image16.c
+++ b/PR/src/lib/object/image/image16.c
@@ -91,7 +91,9 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
   char* cursorData  = data;
   char* counter;
   char* cursorPix   = (*img).pix;
-  char* imgEnd      = (*img).pix+((*img).size>>1)-1;
+  char* imgEnd      = (*img).pix+(
+		(((*img).width+1)>>1)*(img->height)
+	);
 
   while (cursorPix<imgEnd) {
 		//Step 1: Create counter
@@ -99,9 +101,9 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 
 		//Step 2: Look and copy the string until a repeated byte is found
 		while ((cursorPix<imgEnd)&&(*cursorPix!=*(cursorPix+1))&&((*counter)!=127)) {
-			cursorPix++;
+			cursorPix++; //TODO idem
 			(*counter)++;
-			*(cursorData)=*(cursorPix-1);
+			*(cursorData)=       *(cursorPix-1);
 			cursorData++;
 		}
 
@@ -112,7 +114,7 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 				(*counter)--;
 			}
 			cursorPix++; //TODO poner esta linea abajo
-			*(cursorData)=*(cursorPix-1); //Print repeated char
+			*(cursorData)=     *(cursorPix-1); //Print repeated char
 			cursorData++;
 		}
 	}
diff --git a/PR/src/lib/object/image/image2.c b/PR/src/lib/object/image/image2.c
index 87cebcd..b0b2f83 100644
--- a/PR/src/lib/object/image/image2.c
+++ b/PR/src/lib/object/image/image2.c
@@ -91,7 +91,9 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
   char* cursorData  = data;
   char* counter;
   char* cursorPix   = (*img).pix;
-  char* imgEnd      = (*img).pix+((*img).size>>1)-1;
+  char* imgEnd      = (*img).pix+(
+		(((*img).width+1)>>1)*(img->height)
+	);
 
   while (cursorPix<imgEnd) {
 		//Step 1: Create counter
@@ -99,9 +101,9 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 
 		//Step 2: Look and copy the string until a repeated byte is found
 		while ((cursorPix<imgEnd)&&(*cursorPix!=*(cursorPix+1))&&((*counter)!=127)) {
-			cursorPix++;
+			cursorPix++; //TODO idem
 			(*counter)++;
-			*(cursorData)=*(cursorPix-1);
+			*(cursorData)=       *(cursorPix-1);
 			cursorData++;
 		}
 
@@ -112,7 +114,7 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 				(*counter)--;
 			}
 			cursorPix++; //TODO poner esta linea abajo
-			*(cursorData)=*(cursorPix-1); //Print repeated char
+			*(cursorData)=     *(cursorPix-1); //Print repeated char
 			cursorData++;
 		}
 	}
diff --git a/PR/src/lib/object/image/image256.c b/PR/src/lib/object/image/image256.c
index 87cebcd..b0b2f83 100644
--- a/PR/src/lib/object/image/image256.c
+++ b/PR/src/lib/object/image/image256.c
@@ -91,7 +91,9 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
   char* cursorData  = data;
   char* counter;
   char* cursorPix   = (*img).pix;
-  char* imgEnd      = (*img).pix+((*img).size>>1)-1;
+  char* imgEnd      = (*img).pix+(
+		(((*img).width+1)>>1)*(img->height)
+	);
 
   while (cursorPix<imgEnd) {
 		//Step 1: Create counter
@@ -99,9 +101,9 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 
 		//Step 2: Look and copy the string until a repeated byte is found
 		while ((cursorPix<imgEnd)&&(*cursorPix!=*(cursorPix+1))&&((*counter)!=127)) {
-			cursorPix++;
+			cursorPix++; //TODO idem
 			(*counter)++;
-			*(cursorData)=*(cursorPix-1);
+			*(cursorData)=       *(cursorPix-1);
 			cursorData++;
 		}
 
@@ -112,7 +114,7 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 				(*counter)--;
 			}
 			cursorPix++; //TODO poner esta linea abajo
-			*(cursorData)=*(cursorPix-1); //Print repeated char
+			*(cursorData)=     *(cursorPix-1); //Print repeated char
 			cursorData++;
 		}
 	}
diff --git a/PR/src/lib/object/image/image_common.c b/PR/src/lib/object/image/image_common.c
index 87cebcd..b0b2f83 100644
--- a/PR/src/lib/object/image/image_common.c
+++ b/PR/src/lib/object/image/image_common.c
@@ -91,7 +91,9 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
   char* cursorData  = data;
   char* counter;
   char* cursorPix   = (*img).pix;
-  char* imgEnd      = (*img).pix+((*img).size>>1)-1;
+  char* imgEnd      = (*img).pix+(
+		(((*img).width+1)>>1)*(img->height)
+	);
 
   while (cursorPix<imgEnd) {
 		//Step 1: Create counter
@@ -99,9 +101,9 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 
 		//Step 2: Look and copy the string until a repeated byte is found
 		while ((cursorPix<imgEnd)&&(*cursorPix!=*(cursorPix+1))&&((*counter)!=127)) {
-			cursorPix++;
+			cursorPix++; //TODO idem
 			(*counter)++;
-			*(cursorData)=*(cursorPix-1);
+			*(cursorData)=       *(cursorPix-1);
 			cursorData++;
 		}
 
@@ -112,7 +114,7 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 				(*counter)--;
 			}
 			cursorPix++; //TODO poner esta linea abajo
-			*(cursorData)=*(cursorPix-1); //Print repeated char
+			*(cursorData)=     *(cursorPix-1); //Print repeated char
 			cursorData++;
 		}
 	}