Board logo

标题: 一个pcx256色程序(古董) [打印本页]

作者: bush     时间: 2005-10-29 13:07    标题: 一个pcx256色程序(古董)
typedef struct {

char PcxFlag ;
char Version ;
char Encoding ;
char Bitsperpixel ;
int Xmin ;
int Ymin ;
int Xmax ;
int Ymax ;
int Hres ;
int Vres ;
char palette ;
char reserved ;
char planes ;
int width ;
int palettetype ;
char filler ;
}PCXHEAD;

void pcx256display(int x,int y,int status, char * name)
{
FILE *phonefp;
unsigned long phonewidth,phoneheigh;
unsigned char phonedata,phoneline;
long phonelen,phonetemp,linebit;
unsigned char ColorTable ;
int i,j , m , b;
unsigned char data;
int count, total , height ;

PCXHEAD pcxheader;

if((phonefp=fopen(name,"rb"))==NULL){
//printf("cannot open file %s \n",name);
exit(0);
}

fseek( phonefp ,-768L,SEEK_END);
fread( ColorTable , 1 , 768 , phonefp ) ;



fseek( phonefp ,0L,SEEK_SET);
fread( (char *)&pcxheader , sizeof(PCXHEAD), 1, phonefp) ;

height = pcxheader.Ymax - pcxheader.Ymin +1 ;

fseek( phonefp , 128L , SEEK_SET ) ;
//printf("+++++++++++++++++++++++++++++++++%d,%d\n",height,pcxheader.width);
//getch();

if(status)
{
setfillstyle(1,BLACK); //hm_disable
bar(x+pcxheader.width-1,y+6,x+pcxheader.width+4,y+height+4); //hm_disable
bar(x+4,y+height,x+pcxheader.width+4,y+height+4); //hm_disable
}

for( i = 0 ; i<height ; i++)
{
total = 0 ;
while( total < pcxheader.width )
{
count = 1 ;
data = fgetc(phonefp);

if ( 0xc0 == ( 0xc0 & data) )
{
count = 0x3f & data ;
data = fgetc( phonefp );
}

for( j = 0 ; j < count ; j++)
if(j+total!=pcxheader.width-1) putpixel(x+j+total , y+i , data);

total += count ;
}
}

fclose(phonefp);
}

作者: JonePeng     时间: 2005-10-29 20:48
真的很古董,只能怀旧一下。可是现在还有谁用PCX图像啊?!

作者: alchemist     时间: 2005-11-23 17:48
当然有人用了!任天堂 FC 红白机模拟器 Nesticle 和世嘉5代 16bi t游戏机模拟器 Genecyst 都用 PCX 保存游戏截图!

Last edited by alchemist on 2005-11-23 at 17:51 ]

作者: 6622186     时间: 2007-5-17 22:05
怎么用啊?