/*Authur Xuntan
This sample program shows how to decode a ssreader image file
Based on xuntan's reverse engineer work.
Gif writing function is not included
*/
#include <stdio.h>
#include <math.h>
#include "gif.h"
typedef struct {
int width;
int height;
unsigned char * data;
}
myimg,*pmyimg;
int huffman1();
int huffman2();
int GetNextBit();
void MyImageDestory(pmyimg p);
pmyimg ReadMyImageHead(char * fname);
void DecodeMyImage(pmyimg img);
void ScaleMyImage(pmyimg,int neww);
void WriteGifFile(pmyimg image);
void CropMyImage(pmyimg image);
void Error(char *);
/* Global Variable*/
FILE * fimg;
unsigned int bdata;
int len=16;
int buf1[1024];
int buf2[1024];
int offset;
int main(int argc,char *argv[]){
FILE * out;
int color[16];
int i,j;
pmyimg image;
char * p,q;
char * query;
char fname[64];
char buf [64];
char buf2[16];
if(argc<2) {
printf("usage: gifconv filename\n");
exit(0);
}
image=ReadMyImageHead(argv[1]);
DecodeMyImage(image);
WriteGifFile(image);
MyImageDestory(image);
}
void Error(char * msg){
printf("%s\n",msg);
exit(0);
}
void WriteGifFile(pmyimg image){
GIFStream *stream;
GIFData *cur;
GIF89info info;
int i,j;
stream=(GIFStream *)malloc(sizeof(GIFStream));
if(!stream)
Error("error in malloc gif data\n");
stream->width =image->width;
stream->height=image->height;
stream->cmapSize=16;
stream->colorMapSize =16;
stream->colorResolution =4;
stream->background =0;
stream->ASPectRatio= 0;
stream->data =NULL;
stream->cmapData[0][0]=255;
stream->cmapData[0][1]=255;
stream->cmapData[0][2]=255;
for(i=1;i<16;i++){
stream->cmapData[i][0]=256-i*16;
stream->cmapData[i][1]=256-i*16;
stream->cmapData[i][2]=256-i*16;
}
info.disposal = 0;
info.inputFlag = 0;
info.delayTime = 0;
info.transparent = -1;
cur=(GIFData *)malloc(sizeof(GIFData));
cur->type =gif_image;
cur->info =info;
cur->x =0;
&nbs