用计算机程序制作三维立体画
if( BITMAPFILEHEADER.bfType1=='B' && BITMAPFILEHEADER.bfType2=='M'
&& BITMAPINFOHEADER.biWidth==WIDTH && BITMAPINFOHDADER.biHeight==NUM-LINE
&& BITMAPINFOHEADER.biBitCount==BITS-PER-PIXEL
&& BITMAPINFOHEADER.biCompression==COMPRESSION)
fread(RGBQUAD,SIZE-OF-RGBQUAD,NUM-COLOR,fOrigin);
else {
fclose(fOrigin);
printf("File %s is not fit for this program!/n",fn-org);
getch();
exit(3);
}
}
else {
printf("File %s does not exist!/n",fn-org);
getch();
exit(4);
}
if( (fResult=fopen(fn-result,"wb"))!=NULL){
fwrite(&BITMAPFILEHEADER,SIZE-OF-BITMAPFILEHEADER,1,fResult);
fwrite(& BITMAPINFOHIADER,SIZE-OF-BITMAPINFOHEADER,1,fResult);
fwrite(RGBQUAD,SIZE-OF-RGBQUAD,NUM-COLOR,fResult);
}
else {
printf("File %s open error!/n",fn-result);
getch();
exit(5);
}
for(line=0;line<NUM-LINE;line++){
printf("line=%d/n",line);
cur-offset=(unsigned long int)PIXEL-DATA-OFFSET+(unsigned long int)BYTE-
PER-LINE*line;
fseek (fLayer,cur-offset,SEEK-SET);
fseek (fOrigin,cur-offset,SEEK-SET);
for(i-byte=0;i-byte<BYTE-PER-LINE;i-byte++) {
fread(&tmp-byte1,1,1,fLayer);
fread(&tmp-byte2,1,1,fOrigin);
for(i-pixel=0;i-pixel<PIXEL-PER-BYTE;i-pixel++) {
x=i-byte*PIXEL-PER-BYTE+i-pixel;
if(x<WIDTH) {
h[x]=(unsigned char) (tmp-byte1<<(BITS-PER-PIXEL*i-pixel)
) /((unsigned char)0x80>>(BITS-PER-PIXEL-1));
org-color[x]=(unsigned char) (tmp-byte2<<(BITS-PER-PIXEL*i-pixel))
/((unsigned char)0x80>>(BITS-PER-PIXEL-1));
}
}}
for(x=0;x<WIDTH;x++) {
dot[x].color=0;
dot[x].nxt-x=NO-DOT;
dot[x].pri-x=NO-DOT;
if((x+EYE-SPACE)<WIDTH) dot[x].nxt-x=x+EYE-SPACE;
if((signed)x-EYE-SPACE)>=0)dot[x].pri-x=x-EYE-SPACE;
}
for(layer=1;layer<NUM-COLOR;layer++)
for(x=0;x<WIDTH;x++) {
left-x=x-EYE-SPACE/2+(layer/2);
right-x=x+EYE-SPACE/2-((layer+1)/2);
if((h[x]==layer)&&(left-x>=0)&&(rignt-x<WIDTH)) {
if (dot[left-x].nxt-x!=NO-DOT) dot[dot[left-x].nxt-x].pri-x=NO
-DOT;
dot[left-x].nxt-x=right-x;
if (dot[right-x].pri-x!=NO-DOT) dot[dot[right-x].nxt-x].nxt-x=
NO-DOT;
dot[right-x].pri-x=left-x;
}
}
for(x=0;x<WIDTH;x++) {
if(dot[x].pri-x==NO-DOT) {
dot[x].color=org-color[x];
tmp-x=x;
while( dot[tmp-x].nxt-x!=NO-DOT) {
tmp-x=dot[tmp-x].nxt-x;
dot[tmp-x].color=org-color[x];
}
}
}
fseek(fResult,cur-offset,SEEK-SET);
for(i-byte=0;i-byte<BYTE-PER-LINE;i-byte++) {
tmp-bytel=0;
for(i-pixel=0;i-pixel<PIXEL-PER-BYTE;i-pixel++) {
x=i-byte*PIXEL-PER-BYTE+i-pixel;
if(x<WIDTH)
tmp-byte1=(unsigned char) (tmp-byte1<<(BITS-PER-PIXEL*i
-pixel)) +dot[x].color;
}
fwirte(&tmp-byte1,1,1,fResult);
}
}
fclose(fLayer);fclose(fOrigin);fclose(fResult);
}
参考文献
孙志辉、王萃寒、王茜.实用Windows 3.1详解.北京:电子工业出版社,1994.
Tags:
作者:佚名评论内容只代表网友观点,与本站立场无关!
评论摘要(共 0 条,得分 0 分,平均 0 分)
查看完整评论