用計算機程序制作三維立體畫
}
else {
printf(File %s open error! ,fn-result);
getch();
exit(5);
}
for(line=0;lineNUM-LINE;line++){
printf(line=%d ,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-byteBYTE-PER-LINE;i-byte++) {
fread(tmp-byte1,1,1,fLayer);
fread(tmp-byte2,1,1,fOrigin);
for(i-pixel=0;i-pixelPIXEL-PER-BYTE;i-pixel++) {
x=i-byte*PIXEL-PER-BYTE+i-pixel;
if(xWIDTH) {
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;xWIDTH;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;layerNUM-COLOR;layer++)
for(x=0;xWIDTH;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-xWIDTH)) {
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;xWIDTH;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-byteBYTE-PER-LINE;i-byte++) {
tmp-bytel=0;
for(i-pixel=0;i-pixelPIXEL-PER-BYTE;i-pixel++) {
x=i-byte*PIXEL-PER-BYTE+i-pixel;
if(xWIDTH)
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詳解.北京: 電子 工業(yè) 出版社,1994.
c語言相關文章:c語言教程
評論