git » fp-git.git » commit 34176f9

improved image types

author ecalot
2006-03-07 09:27:26 UTC
committer ecalot
2006-03-07 09:27:26 UTC
parent c1bd64ca6f7a11550ded0c73d23f80d33a52aa4e

improved image types

PR/src/include/image.h +12 -4
PR/src/lib/object/image/image16.c +4 -4
PR/src/lib/object/image/image2.c +4 -4
PR/src/lib/object/image/image_common.c +4 -4
PR/src/lib/object/object.c +11 -4
PR/src/xml/resources.xml +2 -2

diff --git a/PR/src/include/image.h b/PR/src/include/image.h
index 20745b6..9954cde 100644
--- a/PR/src/include/image.h
+++ b/PR/src/include/image.h
@@ -65,10 +65,18 @@ typedef struct {
 
 /*int mCompressGraphic(tBinary* input, tBinary* output, int ignoreFirstBytes) */
 
-void* objImageCreate(tBinary c, tObject palette, int *error);
-int objImageWrite(void* img,const char* file,int optionflag,const char* backupExtension);
-void* objImageRead(const char* file,tObject palette, int *result);
-int objImageSet(void* o,tResource* res);
+int objImage16Set(void* o,tResource* res);
+int objImage16Write(void* img,const char* file,int optionflag,const char* backupExtension);
+int objImage256Set(void* o,tResource* res);
+int objImage256Write(void* img,const char* file,int optionflag,const char* backupExtension);
+int objImage2Set(void* o,tResource* res);
+int objImage2Write(void* img,const char* file,int optionflag,const char* backupExtension);
+void* objImage16Create(tBinary c, tObject palette, int *error);
+void* objImage16Read(const char* file,tObject palette, int *result);
+void* objImage256Create(tBinary c, tObject palette, int *error);
+void* objImage256Read(const char* file,tObject palette, int *result);
+void* objImage2Create(tBinary c, int *error);
+void* objImage2Read(const char* file,tObject palette, int *result);
 
 #define getCarry(a) ((((a)>>4)&7)+1)
 #define getAlgor(a) a&0x4F
diff --git a/PR/src/lib/object/image/image16.c b/PR/src/lib/object/image/image16.c
index 9e887d1..c4e38e3 100644
--- a/PR/src/lib/object/image/image16.c
+++ b/PR/src/lib/object/image/image16.c
@@ -346,7 +346,7 @@ int mCompressGraphic(tBinary* input, tBinary* output, int ignoreFirstBytes, int
 
 extern FILE* outputStream;
 
-void* objImageCreate(tBinary cont, tObject palette, int *error) { /* use get like main.c */
+void* objImage16Create(tBinary cont, tObject palette, int *error) { /* use get like main.c */
 
 	/*
 	 * This function will expand the data into an image structure,
@@ -377,7 +377,7 @@ void* objImageCreate(tBinary cont, tObject palette, int *error) { /* use get lik
 	return (void*)image;
 }
 
-int objImageWrite(void* img,const char* file,int optionflag,const char* backupExtension) {
+int objImage16Write(void* img,const char* file,int optionflag,const char* backupExtension) {
 	tImage* i=img;
 	int bits;
 	int colors;
@@ -404,7 +404,7 @@ void objImageFree(void* img) {
 	free(img);
 }
 
-void* objImageRead(const char* file,tObject palette, int *result) {
+void* objImage16Read(const char* file,tObject palette, int *result) {
 	int bits;
 	tImage* image=(tImage*)malloc(sizeof(tImage));
 	tColor* colorArray;
@@ -437,7 +437,7 @@ void* objImageRead(const char* file,tObject palette, int *result) {
 	/* TODO: generate image->type in objImageSet */
 
 /*int mFormatImportBmp(tResource *res) { --> objImageSet */
-int objImageSet(void* o,tResource* res) {
+int objImage16Set(void* o,tResource* res) {
 	tImage* img=o;
 	tBinary decompressed,compressed;
 	int algorithm;
diff --git a/PR/src/lib/object/image/image2.c b/PR/src/lib/object/image/image2.c
index 9e887d1..c4e38e3 100644
--- a/PR/src/lib/object/image/image2.c
+++ b/PR/src/lib/object/image/image2.c
@@ -346,7 +346,7 @@ int mCompressGraphic(tBinary* input, tBinary* output, int ignoreFirstBytes, int
 
 extern FILE* outputStream;
 
-void* objImageCreate(tBinary cont, tObject palette, int *error) { /* use get like main.c */
+void* objImage16Create(tBinary cont, tObject palette, int *error) { /* use get like main.c */
 
 	/*
 	 * This function will expand the data into an image structure,
@@ -377,7 +377,7 @@ void* objImageCreate(tBinary cont, tObject palette, int *error) { /* use get lik
 	return (void*)image;
 }
 
-int objImageWrite(void* img,const char* file,int optionflag,const char* backupExtension) {
+int objImage16Write(void* img,const char* file,int optionflag,const char* backupExtension) {
 	tImage* i=img;
 	int bits;
 	int colors;
@@ -404,7 +404,7 @@ void objImageFree(void* img) {
 	free(img);
 }
 
-void* objImageRead(const char* file,tObject palette, int *result) {
+void* objImage16Read(const char* file,tObject palette, int *result) {
 	int bits;
 	tImage* image=(tImage*)malloc(sizeof(tImage));
 	tColor* colorArray;
@@ -437,7 +437,7 @@ void* objImageRead(const char* file,tObject palette, int *result) {
 	/* TODO: generate image->type in objImageSet */
 
 /*int mFormatImportBmp(tResource *res) { --> objImageSet */
-int objImageSet(void* o,tResource* res) {
+int objImage16Set(void* o,tResource* res) {
 	tImage* img=o;
 	tBinary decompressed,compressed;
 	int algorithm;
diff --git a/PR/src/lib/object/image/image_common.c b/PR/src/lib/object/image/image_common.c
index 9e887d1..c4e38e3 100644
--- a/PR/src/lib/object/image/image_common.c
+++ b/PR/src/lib/object/image/image_common.c
@@ -346,7 +346,7 @@ int mCompressGraphic(tBinary* input, tBinary* output, int ignoreFirstBytes, int
 
 extern FILE* outputStream;
 
-void* objImageCreate(tBinary cont, tObject palette, int *error) { /* use get like main.c */
+void* objImage16Create(tBinary cont, tObject palette, int *error) { /* use get like main.c */
 
 	/*
 	 * This function will expand the data into an image structure,
@@ -377,7 +377,7 @@ void* objImageCreate(tBinary cont, tObject palette, int *error) { /* use get lik
 	return (void*)image;
 }
 
-int objImageWrite(void* img,const char* file,int optionflag,const char* backupExtension) {
+int objImage16Write(void* img,const char* file,int optionflag,const char* backupExtension) {
 	tImage* i=img;
 	int bits;
 	int colors;
@@ -404,7 +404,7 @@ void objImageFree(void* img) {
 	free(img);
 }
 
-void* objImageRead(const char* file,tObject palette, int *result) {
+void* objImage16Read(const char* file,tObject palette, int *result) {
 	int bits;
 	tImage* image=(tImage*)malloc(sizeof(tImage));
 	tColor* colorArray;
@@ -437,7 +437,7 @@ void* objImageRead(const char* file,tObject palette, int *result) {
 	/* TODO: generate image->type in objImageSet */
 
 /*int mFormatImportBmp(tResource *res) { --> objImageSet */
-int objImageSet(void* o,tResource* res) {
+int objImage16Set(void* o,tResource* res) {
 	tImage* img=o;
 	tBinary decompressed,compressed;
 	int algorithm;
diff --git a/PR/src/lib/object/object.c b/PR/src/lib/object/object.c
index 2d5044c..99096c9 100644
--- a/PR/src/lib/object/object.c
+++ b/PR/src/lib/object/object.c
@@ -72,10 +72,17 @@ tObject getObject(tResource* r, int* error) {
 	case eResTypeWave: /* save wav file */
 		o.obj=objWaveCreate(r->content,error);
 		break;
+	case eResTypeImage2: /* save image */
+		o.obj=objImage2Create(r->content,error);
+		break;
 	case eResTypeImage16: /* save image */
-		o.obj=objImageCreate(r->content,r->palette,error);
+		o.obj=objImage16Create(r->content,r->palette,error);
+		break;
+	case eResTypeImage256: /* save image */
+		o.obj=objImage256Create(r->content,r->palette,error);
 		break;
 	default:
+		*error=PR_RESULT_SUCCESS; /* NOTE: change to 1 to detect unhooked types */
 		break;
 	}
 	
@@ -106,7 +113,7 @@ int writeObject(tObject o, const char* file, int optionflag, const char* backupE
 		error=objWaveWrite(o.obj,file,optionflag,backupExtension);
 		break;
 	case eResTypeImage16: /* save image */
-		error=objImageWrite(o.obj,file,optionflag,backupExtension);
+		error=objImage16Write(o.obj,file,optionflag,backupExtension);
 		break;
 	default:
 		break;
@@ -160,7 +167,7 @@ void setObject(tObject o,int *result,tResource* res) {
 			/*o.obj=objLevelRead(file,res.content,result);*/
 			break;
 		case eResTypeImage16:
-			*result=objImageSet(o.obj,res);
+			*result=objImage16Set(o.obj,res);
 			break;
 		case eResTypeWave:
 			*result=objWaveSet(o.obj,res);
@@ -191,7 +198,7 @@ tObject readObject(const char* file,tResource* res,int *result) {
 			/*o.obj=objLevelRead(file,res.content,result);*/
 			break;
 		case eResTypeImage16:
-			o.obj=objImageRead(file,res->palette,result);
+			o.obj=objImage16Read(file,res->palette,result);
 			break;
 		case eResTypeWave:
 			o.obj=objWaveRead(file,result);
diff --git a/PR/src/xml/resources.xml b/PR/src/xml/resources.xml
index 251789e..2a67055 100644
--- a/PR/src/xml/resources.xml
+++ b/PR/src/xml/resources.xml
@@ -46,7 +46,7 @@ resources.xml: Princed Resources : Resource tree
 
 <resources version="1.0">
  <folder index="pop1" name="binary" file="title.dat" path="title">
-  <folder path="texts" type="image" palette="monochrome">
+  <folder path="texts" type="image" colors="2">
    <item value="42" path="in the absence.bmp">Text in the absence (42)</item>
    <item value="43" path="marry jaffar.bmp">Text marry jaffar (43)</item>
    <item value="44" path="the tyrant.bmp">Text the tyrant (44)</item>
@@ -748,7 +748,7 @@ resources.xml: Princed Resources : Resource tree
     <item value="165" path="big palace.bmp" type="image">Unknown Resource number 165</item>
    </folder>
 
-   <folder name="bubble animation" path="bubble animation" type="image" palette="monochrome">
+   <folder name="bubble animation" path="bubble animation" type="image" colors="2">
     <item value="166" path="frame01.bmp">Image frame01 (166)</item>
     <item value="167" path="frame02.bmp">Image frame02 (167)</item>
     <item value="168" path="frame03.bmp">Image frame03 (168)</item>