git » fp-git.git » commit 85ee233

bugfixes. Ignored checksum in image object

author ecalot
2006-02-18 04:55:09 UTC
committer ecalot
2006-02-18 04:55:09 UTC
parent f7dcc2393105557644b46fcd6ec859e3840dcdca

bugfixes. Ignored checksum in image object

PR/src/include/common.h +2 -0
PR/src/include/compress.h +5 -3
PR/src/lib/actions/export.c +5 -1
PR/src/lib/formats/bmp.c +2 -2
PR/src/lib/object/image/image16.c +1 -2
PR/src/lib/object/image/image2.c +1 -2
PR/src/lib/object/image/image256.c +1 -2
PR/src/lib/object/image/image_common.c +1 -2

diff --git a/PR/src/include/common.h b/PR/src/include/common.h
index 7c1c859..cb701e9 100644
--- a/PR/src/include/common.h
+++ b/PR/src/include/common.h
@@ -226,5 +226,7 @@ PARSING_OPTRAW\
 #define PR_RESULT_XML_AND_DAT_FORMAT_DO_NOT_MATCH -25
 #define PR_RESULT_HELP_SHOWN -1
 #define PR_RESULT_SUCCESS 0
+#define PR_RESULT_COMPRESS_RESULT_FATAL -26 
+#define PR_RESULT_COMPRESS_RESULT_WARNING -27
 
 #endif
diff --git a/PR/src/include/compress.h b/PR/src/include/compress.h
index 606ad79..c8cace0 100644
--- a/PR/src/include/compress.h
+++ b/PR/src/include/compress.h
@@ -34,6 +34,8 @@ compress.h: Princed Resources : Compression headers
 #ifndef _COMPRESS_H_
 #define _COMPRESS_H_
 
+#include "common.h"
+
 #define COMPRESS_RAW    0x00
 #define COMPRESS_RLE_LR 0x01
 #define COMPRESS_RLE_UD 0x02
@@ -42,9 +44,9 @@ compress.h: Princed Resources : Compression headers
 
 #define COMPRESS_WORKING_ALGORITHMS 5
 
-#define COMPRESS_RESULT_FATAL   -2
-#define COMPRESS_RESULT_WARNING -1
-#define COMPRESS_RESULT_SUCCESS 0
+#define COMPRESS_RESULT_FATAL   PR_RESULT_COMPRESS_RESULT_FATAL
+#define COMPRESS_RESULT_WARNING PR_RESULT_COMPRESS_RESULT_WARNING
+#define COMPRESS_RESULT_SUCCESS PR_RESULT_SUCCESS 
 
 /* Prototypes */
 
diff --git a/PR/src/lib/actions/export.c b/PR/src/lib/actions/export.c
index f693ffb..b738b04 100644
--- a/PR/src/lib/actions/export.c
+++ b/PR/src/lib/actions/export.c
@@ -106,6 +106,7 @@ int extract(const char* vFiledat,const char* vDirExt, tResourceList* r, int opti
 				tObject o;
 				if (hasFlag(raw_flag)) res.type=0; /* If "extract as raw" is set, type is 0 */
 
+printf("ok=%d ok2=%d type=%d\n",ok,ok2,res.type);
 				/* get save file name (if unknown document is in the XML) */
 				getFileName(file,vDirExt,&res,vFiledat,vDatFileName,optionflag,backupExtension,format);
 
@@ -139,7 +140,10 @@ printf("id=(%d,%s,%d)\n",res.paletteId.value,res.paletteId.index,res.paletteId.o
 				}
 		/* TODO: warning counting here */	
 /*				if (!fatal(ok)) */
-				ok=writeObject(o,file,optionflag,backupExtension);
+				if (ok==PR_RESULT_SUCCESS)
+					ok=writeObject(o,file,optionflag,backupExtension);
+				else
+					printf("not ok. result=%d for %s\n",ok,file);
 
 				/* Verbose information */
 				/*if (hasFlag(verbose_flag)) {
diff --git a/PR/src/lib/formats/bmp.c b/PR/src/lib/formats/bmp.c
index e0adfb8..e1062ba 100644
--- a/PR/src/lib/formats/bmp.c
+++ b/PR/src/lib/formats/bmp.c
@@ -61,7 +61,7 @@ int mWriteBmp(const char* file,const unsigned char* data, int w, int h, int bits
 	FILE* bitmap;
 
 	/* open file */
-	if (!writeOpen(file,&bitmap,optionflag)) return 0; /* false */
+	if (!writeOpen(file,&bitmap,optionflag)) return PR_RESULT_ERR_FILE_NOT_WRITE_ACCESS;
 
 	/* initialize variables */
 /*	width=img.width;
@@ -108,7 +108,7 @@ int mWriteBmp(const char* file,const unsigned char* data, int w, int h, int bits
 	}
 
 	writeCloseOk(bitmap,optionflag,backupExtension);
-	return 1; /* true */
+	return PR_RESULT_SUCCESS; 
 }
 
 int mReadBitMap(tImage* image,unsigned char* data, int size) {
diff --git a/PR/src/lib/object/image/image16.c b/PR/src/lib/object/image/image16.c
index 8ce4578..3052c53 100644
--- a/PR/src/lib/object/image/image16.c
+++ b/PR/src/lib/object/image/image16.c
@@ -157,7 +157,6 @@ int mExpandGraphic(const unsigned char* data,tImage *image, int dataSizeInBytes)
 	int imageSizeInBytes=0;
 	int result;
 
-	data++;
 	image->height=array2short(data);
 	data+=2;
 	image->width =array2short(data);
@@ -165,7 +164,7 @@ int mExpandGraphic(const unsigned char* data,tImage *image, int dataSizeInBytes)
 
 	if (*(data++)>1) return COMPRESS_RESULT_FATAL; /* Verify format */
 	image->type=(unsigned char)(*(data++));
-	dataSizeInBytes-=7;
+	dataSizeInBytes-=6;
 	switch (((image->type>>4)&7)+1) {
 	case 8:
 		image->widthInBytes=(image->width);
diff --git a/PR/src/lib/object/image/image2.c b/PR/src/lib/object/image/image2.c
index 8ce4578..3052c53 100644
--- a/PR/src/lib/object/image/image2.c
+++ b/PR/src/lib/object/image/image2.c
@@ -157,7 +157,6 @@ int mExpandGraphic(const unsigned char* data,tImage *image, int dataSizeInBytes)
 	int imageSizeInBytes=0;
 	int result;
 
-	data++;
 	image->height=array2short(data);
 	data+=2;
 	image->width =array2short(data);
@@ -165,7 +164,7 @@ int mExpandGraphic(const unsigned char* data,tImage *image, int dataSizeInBytes)
 
 	if (*(data++)>1) return COMPRESS_RESULT_FATAL; /* Verify format */
 	image->type=(unsigned char)(*(data++));
-	dataSizeInBytes-=7;
+	dataSizeInBytes-=6;
 	switch (((image->type>>4)&7)+1) {
 	case 8:
 		image->widthInBytes=(image->width);
diff --git a/PR/src/lib/object/image/image256.c b/PR/src/lib/object/image/image256.c
index 8ce4578..3052c53 100644
--- a/PR/src/lib/object/image/image256.c
+++ b/PR/src/lib/object/image/image256.c
@@ -157,7 +157,6 @@ int mExpandGraphic(const unsigned char* data,tImage *image, int dataSizeInBytes)
 	int imageSizeInBytes=0;
 	int result;
 
-	data++;
 	image->height=array2short(data);
 	data+=2;
 	image->width =array2short(data);
@@ -165,7 +164,7 @@ int mExpandGraphic(const unsigned char* data,tImage *image, int dataSizeInBytes)
 
 	if (*(data++)>1) return COMPRESS_RESULT_FATAL; /* Verify format */
 	image->type=(unsigned char)(*(data++));
-	dataSizeInBytes-=7;
+	dataSizeInBytes-=6;
 	switch (((image->type>>4)&7)+1) {
 	case 8:
 		image->widthInBytes=(image->width);
diff --git a/PR/src/lib/object/image/image_common.c b/PR/src/lib/object/image/image_common.c
index 8ce4578..3052c53 100644
--- a/PR/src/lib/object/image/image_common.c
+++ b/PR/src/lib/object/image/image_common.c
@@ -157,7 +157,6 @@ int mExpandGraphic(const unsigned char* data,tImage *image, int dataSizeInBytes)
 	int imageSizeInBytes=0;
 	int result;
 
-	data++;
 	image->height=array2short(data);
 	data+=2;
 	image->width =array2short(data);
@@ -165,7 +164,7 @@ int mExpandGraphic(const unsigned char* data,tImage *image, int dataSizeInBytes)
 
 	if (*(data++)>1) return COMPRESS_RESULT_FATAL; /* Verify format */
 	image->type=(unsigned char)(*(data++));
-	dataSizeInBytes-=7;
+	dataSizeInBytes-=6;
 	switch (((image->type>>4)&7)+1) {
 	case 8:
 		image->widthInBytes=(image->width);