author | ecalot
<ecalot> 2006-07-17 18:55:54 UTC |
committer | ecalot
<ecalot> 2006-07-17 18:55:54 UTC |
parent | 8386ba7c7b006b5b0dfcc41ab83b96227beb6875 |
PR/src/include/image.h | +1 | -1 |
PR/src/lib/object/image/image16.c | +1 | -1 |
PR/src/lib/object/image/image2.c | +3 | -7 |
PR/src/lib/object/image/image_common.c | +1 | -0 |
PR/src/lib/object/object.c | +7 | -4 |
diff --git a/PR/src/include/image.h b/PR/src/include/image.h index 6ea92f2..1c73b51 100644 --- a/PR/src/include/image.h +++ b/PR/src/include/image.h @@ -77,7 +77,7 @@ void* objectImage16Read(const char* file,tObject palette, int *result); void* objectImage256Create(tBinary c, int *error); void* objectImage256Read(const char* file,tObject palette, int *result); void* objectImage2Create(tBinary c, int *error); -void* objectImage2Read(const char* file,tObject palette, int *result); +void* objectImage2Read(const char* file, 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 cf73d55..b4ab31f 100644 --- a/PR/src/lib/object/image/image16.c +++ b/PR/src/lib/object/image/image16.c @@ -158,7 +158,7 @@ void* objectImage16Read(const char* file,tObject palette, int *result) { /* check the palette information */ image->pal=palette; - bits=objectPaletteGetBitRate(image->pal); + bits=objectPaletteGetBitRate(image->pal); /* TODO: transform this check into a colors==16 */ if (bits && bits!=image->bits) { /* bits=0 means all palettes allowed or ignore palette check */ *result=PR_RESULT_F_BMP_BITRATE_DIFFERS; free(image->pix); diff --git a/PR/src/lib/object/image/image2.c b/PR/src/lib/object/image/image2.c index aa6473a..f97db40 100644 --- a/PR/src/lib/object/image/image2.c +++ b/PR/src/lib/object/image/image2.c @@ -116,7 +116,6 @@ void* objectImage2Create(tBinary cont, int *error) { /* Expand graphic and check results */ *error=mExpandGraphic(cont,image); -printf("w=%d h=%d\n",image->width,image->height); if (*error==PR_RESULT_F_COMPRESS_RESULT_FATAL) { free(image); @@ -138,8 +137,7 @@ int objectImage2Write(void* img,const char* file,int optionflag,const char* back return mWriteBmp(file,i->pix,i->width,i->height,1,2,colorArray,i->widthInBytes,optionflag,backupExtension); } -void* objectImage2Read(const char* file,tObject palette, int *result) { - int bits; +void* objectImage2Read(const char* file, int *result) { tImage* image=(tImage*)malloc(sizeof(tImage)); tColor* colorArray; int colors; @@ -154,10 +152,8 @@ void* objectImage2Read(const char* file,tObject palette, int *result) { free(colorArray); /* check the palette information */ - - bits=objectPaletteGetBitRate(image->pal); - if (image->bits!=1) { - *result=PR_RESULT_F_BMP_BITRATE_DIFFERS; + if (colors!=2) { + *result=PR_RESULT_F_PAL_UNSUPPORTED_SIZE; /* TODO: convert in warning and perform a palette conversion */ free(image->pix); free(image); return NULL; diff --git a/PR/src/lib/object/image/image_common.c b/PR/src/lib/object/image/image_common.c index ac0dbac..5ff7a19 100644 --- a/PR/src/lib/object/image/image_common.c +++ b/PR/src/lib/object/image/image_common.c @@ -179,6 +179,7 @@ int mExpandGraphic(tBinary input, tImage *image) { if ((image->pix=getMemory(input.size))==NULL) return PR_RESULT_F_COMPRESS_RESULT_FATAL; memcpy(image->pix,input.data,input.size); imageSizeInBytes=image->widthInBytes*image->height; + if (imageSizeInBytes>input.size) return PR_RESULT_F_COMPRESS_RESULT_FATAL; /* TODO: check if raw images still work */ result=PR_RESULT_SUCCESS; break; case COMPRESS_RLE_LR: /* RLE Left to Right Compression Algorithm */ diff --git a/PR/src/lib/object/object.c b/PR/src/lib/object/object.c index 83690d1..9db5bc1 100644 --- a/PR/src/lib/object/object.c +++ b/PR/src/lib/object/object.c @@ -188,10 +188,7 @@ tColor* objectPaletteGetColorArray(tObject pal) { } } -/***************************************************************\ -| Dat compiling primitive | -\***************************************************************/ - +/* put an object into a dat */ void objectSet(tObject o,int *result,tResource* res) { switch (o.type) { case eResTypeLevelPop1: /* TODO: pop2 */ @@ -200,6 +197,9 @@ void objectSet(tObject o,int *result,tResource* res) { case eResTypeImage16: *result=objectImage16Set(o.obj,res); break; + case eResTypeImage2: + *result=objectImage2Set(o.obj,res); + break; case eResTypeSoundWave: *result=objectSoundWaveSet(o.obj,res); break; @@ -231,6 +231,9 @@ tObject objectRead(const char* file,tResource* res,int *result) { case eResTypeImage16: o.obj=objectImage16Read(file,*res->palette /*TODO: check because sometimes it is not initialized */,result); break; + case eResTypeImage2: + o.obj=objectImage2Read(file,result); + break; case eResTypeSoundWave: o.obj=objectSoundWaveRead(file,result); break;