git » fp-git.git » commit f9b0376

packed (data, size) into a tBinary in some compression functions

author ecalot
2006-06-24 06:25:19 UTC
committer ecalot
2006-06-24 06:25:19 UTC
parent a3b5b8ec9da5b5d493736137ae52a4a0a8afabdf

packed (data, size) into a tBinary in some compression functions

PR/src/include/image.h +2 -1
PR/src/lib/object/image/image16.c +16 -16
PR/src/lib/object/image/image2.c +1 -1
PR/src/lib/object/image/image256.c +1 -1
PR/src/lib/object/image/image_common.c +16 -16
PR/src/ports/winfiles/pr.dev +1 -1

diff --git a/PR/src/include/image.h b/PR/src/include/image.h
index a6040fa..6ea92f2 100644
--- a/PR/src/include/image.h
+++ b/PR/src/include/image.h
@@ -82,7 +82,8 @@ void* objectImage2Read(const char* file,tObject palette, int *result);
 #define getCarry(a) ((((a)>>4)&7)+1)
 #define getAlgor(a) a&0x4F
 
-int mExpandGraphic(const unsigned char* data,tImage *image, int dataSizeInBytes);
+int mExpandGraphic(tBinary data,tImage *image);
+/*int mExpandGraphic(const unsigned char* data, int dataSizeInBytes,tImage *image);*/
 int mCompressGraphic(tBinary* input, tBinary* output, int ignoreFirstBytes, int w, int h);
 
 int objectImageGetColorCount(void* img);
diff --git a/PR/src/lib/object/image/image16.c b/PR/src/lib/object/image/image16.c
index 4098f21..0ed1722 100644
--- a/PR/src/lib/object/image/image16.c
+++ b/PR/src/lib/object/image/image16.c
@@ -150,23 +150,23 @@ void cmp_antiTransposeImage(tBinary* b, int widthInBytes, int height) {
  */
 
 /* Expands an array into an image */
-int mExpandGraphic(const unsigned char* data,tImage *image, int dataSizeInBytes) {
+int mExpandGraphic(tBinary input, tImage *image) {
 	/*
-	 * Reads data and extracts tImage
+	 * Reads input.data and extracts tImage
 	 * returns the next image address or -1 in case of error
 	 */
 
 	int imageSizeInBytes=0;
 	int result;
 
-	image->height=array2short(data);
-	data+=2;
-	image->width =array2short(data);
-	data+=2;
+	image->height=array2short(input.data);
+	input.data+=2;
+	image->width =array2short(input.data);
+	input.data+=2;
 
-	if (*(data++)>1) return PR_RESULT_COMPRESS_RESULT_FATAL; /* Verify format */
-	image->type=(unsigned char)(*(data++));
-	dataSizeInBytes-=6;
+	if (*(input.data++)>1) return PR_RESULT_COMPRESS_RESULT_FATAL; /* Verify format */
+	image->type=(unsigned char)(*(input.data++));
+	input.size-=6;
 	switch (((image->type>>4)&7)+1) {
 	case 8:
 		image->widthInBytes=(image->width);
@@ -188,27 +188,27 @@ int mExpandGraphic(const unsigned char* data,tImage *image, int dataSizeInBytes)
 
 	switch (getAlgor(image->type)) {
 		case COMPRESS_RAW: /* No Compression Algorithm */
-			if ((image->pix=getMemory(dataSizeInBytes))==NULL) return PR_RESULT_COMPRESS_RESULT_FATAL;
-			memcpy(image->pix,data,dataSizeInBytes);
+			if ((image->pix=getMemory(input.size))==NULL) return PR_RESULT_COMPRESS_RESULT_FATAL;
+			memcpy(image->pix,input.data,input.size);
 			imageSizeInBytes=image->widthInBytes*image->height;
 			result=PR_RESULT_SUCCESS;
 			break;
 		case COMPRESS_RLE_LR: /* RLE Left to Right Compression Algorithm */
-			result=expandRle(data,dataSizeInBytes,&(image->pix),&imageSizeInBytes);
+			result=expandRle(input.data,input.size,&(image->pix),&imageSizeInBytes);
 			checkSize;
 			break;
 		case COMPRESS_RLE_UD: /* RLE Up to Down Compression Algorithm */
-			result=expandRle(data,dataSizeInBytes,&(image->pix),&imageSizeInBytes);
+			result=expandRle(input.data,input.size,&(image->pix),&imageSizeInBytes);
 			checkResult;
 			checkSize;
 			cmp_transposeImage(image,imageSizeInBytes);
 			break;
 		case COMPRESS_LZG_LR: /* LZ Groody Left to Right Compression Algorithm */
-			result=expandLzg(data,dataSizeInBytes,&(image->pix),&imageSizeInBytes);
+			result=expandLzg(input.data,input.size,&(image->pix),&imageSizeInBytes);
 			checkSize;
 			break;
 		case COMPRESS_LZG_UD: /* LZ Groody Up to Down Compression Algorithm */
-			result=expandLzg(data,dataSizeInBytes,&(image->pix),&imageSizeInBytes);
+			result=expandLzg(input.data,input.size,&(image->pix),&imageSizeInBytes);
 			checkResult;
 			checkSize;
 			cmp_transposeImage(image,imageSizeInBytes);
@@ -366,7 +366,7 @@ void* objectImage16Create(tBinary cont, int *error) { /* use get like main.c */
 	image=(tImage*)malloc(sizeof(tImage));
 
 	/* Expand graphic and check results */
-	*error=mExpandGraphic(cont.data,image,cont.size); /* TODO: pass tBinary */
+	*error=mExpandGraphic(cont,image); /* TODO: pass tBinary */
 /*	if ((result==COMPRESS_RESULT_WARNING)&&hasFlag(verbose_flag))
 		fprintf(outputStream,PR_TEXT_EXPORT_BMP_WARN);*/
 	if (*error==PR_RESULT_COMPRESS_RESULT_FATAL) {
diff --git a/PR/src/lib/object/image/image2.c b/PR/src/lib/object/image/image2.c
index 19576e3..98d9392 100644
--- a/PR/src/lib/object/image/image2.c
+++ b/PR/src/lib/object/image/image2.c
@@ -115,7 +115,7 @@ void* objectImage2Create(tBinary cont, int *error) { /* use get like main.c */
 	image=(tImage*)malloc(sizeof(tImage));
 
 	/* Expand graphic and check results */
-	*error=mExpandGraphic(cont.data,image,cont.size); /* TODO: pass tBinary */
+	*error=mExpandGraphic(cont,image); /* TODO: pass tBinary */
 /*	if ((result==COMPRESS_RESULT_WARNING)&&hasFlag(verbose_flag))
 		fprintf(outputStream,PR_TEXT_EXPORT_BMP_WARN);*/
 	if (*error==PR_RESULT_COMPRESS_RESULT_FATAL) {
diff --git a/PR/src/lib/object/image/image256.c b/PR/src/lib/object/image/image256.c
index b14552d..c08beee 100644
--- a/PR/src/lib/object/image/image256.c
+++ b/PR/src/lib/object/image/image256.c
@@ -142,7 +142,7 @@ int mExpandGraphic256(const unsigned char* data,tImage *image, int dataSizeInByt
 	}
 
 	/* special format has a special function */
-	return pop2decompress(data,dataSizeInBytes,image->width,&(image->pix),&imageSizeInBytes);
+	return pop2decompress(data,dataSizeInBytes,image->width,&(image->pix),&imageSizeInBytes); /* TODO: use tBinary */
 }
 
 /* Compress an image into binary data */
diff --git a/PR/src/lib/object/image/image_common.c b/PR/src/lib/object/image/image_common.c
index 4098f21..0ed1722 100644
--- a/PR/src/lib/object/image/image_common.c
+++ b/PR/src/lib/object/image/image_common.c
@@ -150,23 +150,23 @@ void cmp_antiTransposeImage(tBinary* b, int widthInBytes, int height) {
  */
 
 /* Expands an array into an image */
-int mExpandGraphic(const unsigned char* data,tImage *image, int dataSizeInBytes) {
+int mExpandGraphic(tBinary input, tImage *image) {
 	/*
-	 * Reads data and extracts tImage
+	 * Reads input.data and extracts tImage
 	 * returns the next image address or -1 in case of error
 	 */
 
 	int imageSizeInBytes=0;
 	int result;
 
-	image->height=array2short(data);
-	data+=2;
-	image->width =array2short(data);
-	data+=2;
+	image->height=array2short(input.data);
+	input.data+=2;
+	image->width =array2short(input.data);
+	input.data+=2;
 
-	if (*(data++)>1) return PR_RESULT_COMPRESS_RESULT_FATAL; /* Verify format */
-	image->type=(unsigned char)(*(data++));
-	dataSizeInBytes-=6;
+	if (*(input.data++)>1) return PR_RESULT_COMPRESS_RESULT_FATAL; /* Verify format */
+	image->type=(unsigned char)(*(input.data++));
+	input.size-=6;
 	switch (((image->type>>4)&7)+1) {
 	case 8:
 		image->widthInBytes=(image->width);
@@ -188,27 +188,27 @@ int mExpandGraphic(const unsigned char* data,tImage *image, int dataSizeInBytes)
 
 	switch (getAlgor(image->type)) {
 		case COMPRESS_RAW: /* No Compression Algorithm */
-			if ((image->pix=getMemory(dataSizeInBytes))==NULL) return PR_RESULT_COMPRESS_RESULT_FATAL;
-			memcpy(image->pix,data,dataSizeInBytes);
+			if ((image->pix=getMemory(input.size))==NULL) return PR_RESULT_COMPRESS_RESULT_FATAL;
+			memcpy(image->pix,input.data,input.size);
 			imageSizeInBytes=image->widthInBytes*image->height;
 			result=PR_RESULT_SUCCESS;
 			break;
 		case COMPRESS_RLE_LR: /* RLE Left to Right Compression Algorithm */
-			result=expandRle(data,dataSizeInBytes,&(image->pix),&imageSizeInBytes);
+			result=expandRle(input.data,input.size,&(image->pix),&imageSizeInBytes);
 			checkSize;
 			break;
 		case COMPRESS_RLE_UD: /* RLE Up to Down Compression Algorithm */
-			result=expandRle(data,dataSizeInBytes,&(image->pix),&imageSizeInBytes);
+			result=expandRle(input.data,input.size,&(image->pix),&imageSizeInBytes);
 			checkResult;
 			checkSize;
 			cmp_transposeImage(image,imageSizeInBytes);
 			break;
 		case COMPRESS_LZG_LR: /* LZ Groody Left to Right Compression Algorithm */
-			result=expandLzg(data,dataSizeInBytes,&(image->pix),&imageSizeInBytes);
+			result=expandLzg(input.data,input.size,&(image->pix),&imageSizeInBytes);
 			checkSize;
 			break;
 		case COMPRESS_LZG_UD: /* LZ Groody Up to Down Compression Algorithm */
-			result=expandLzg(data,dataSizeInBytes,&(image->pix),&imageSizeInBytes);
+			result=expandLzg(input.data,input.size,&(image->pix),&imageSizeInBytes);
 			checkResult;
 			checkSize;
 			cmp_transposeImage(image,imageSizeInBytes);
@@ -366,7 +366,7 @@ void* objectImage16Create(tBinary cont, int *error) { /* use get like main.c */
 	image=(tImage*)malloc(sizeof(tImage));
 
 	/* Expand graphic and check results */
-	*error=mExpandGraphic(cont.data,image,cont.size); /* TODO: pass tBinary */
+	*error=mExpandGraphic(cont,image); /* TODO: pass tBinary */
 /*	if ((result==COMPRESS_RESULT_WARNING)&&hasFlag(verbose_flag))
 		fprintf(outputStream,PR_TEXT_EXPORT_BMP_WARN);*/
 	if (*error==PR_RESULT_COMPRESS_RESULT_FATAL) {
diff --git a/PR/src/ports/winfiles/pr.dev b/PR/src/ports/winfiles/pr.dev
index dfa182c..224c288 100644
--- a/PR/src/ports/winfiles/pr.dev
+++ b/PR/src/ports/winfiles/pr.dev
@@ -933,7 +933,7 @@ BuildCmd=
 Major=1
 Minor=3
 Release=0
-Build=57
+Build=60
 LanguageID=2057
 CharsetID=1252
 CompanyName=Princed development team