用计算机程序制作三维立体画
该程序寄生在Windows 3.1中的Pbrush软件上。借助于它来构筑立体形体(即立体形体水平剖面高低坐标数据文件图8),设计原始图案(图9)。程序运行后,逐行输入并处理以上两个文件中的图形,然后输出立体画结果文件(图10)。最后,用Pbrush来观赏立体画result.bmp。当然,要设计出令人赏心悦目的立体画,必须在立体形体和图案素材的选择和搭配上做到天衣无缝,独具匠心。
@@09A04007.GIF;图8@@
@@09A04008.GIF;图9@@
@@09A04009.GIF;图10程序清单@@
/*--from 1995.4.19--to 1995.5.18----*/include<stdio.h>
#define COMPRESSION 0
#define SIZE-OF-BITMAPFILEHEADER 14
#define SIZE-OF-BITMAPINFOHEADER 40
#define SIZE-OF-RGBQUAD 4
#define PIXEL-DATE-OFFSET 14+40+4*16
/*SIZE-OF-BITMAPFILEHEADER+SIZE-OF-BITMAPINFOHEADER+BITS-PER-PIXEL
*NUM-COLOR*/
#define NUM-COLOR 16
#define NUM-LINE 400
#define WIDTH 640
#define BITS-PER-PIXEL 4
#define PIXEL-PER-BYTE 2 /*8/BITS-PER-PIXEL*/
#define BYTE-PER-LINE 320 /*((WIDTH*BITS-PER-PIXEL-1)/32+1)*4 */
#define NO-DOT WIDTH+1
#define EYE-SPACE 128
struct{
unsignde char color ;
unsigned int pri-x ;
unsigned int nxt-x ;
}dot[WIDTH];
main()
{
struct tagBITMAPFILEHEADER{
unsigned char bfType1,bfType2; /* always equal to'BM'*/
unsigned long int bfSize; /*size of file */
unsigned int bfReserved1,bfReserved2; /* set to zero */
unsiged long int bfoffits; /*byte offset from BITMAPFILEHEADER to bitmap p
ixel
data in the file */
}BITMAPFILEHEADER;
struct tagBITMAPINFOHEADER{
unsigned long int biSize,/* size of BITMAPINFOHEADER */
biWidth;/* width in pixels biHeight;/* height in pixels */
unsigned int biPlanes, /* always 1 */
biBitCount; /* color bits per pixel must be 1,4,8 or 24 */
unsigned long int biCompression, /*BI-RGB,BI-RLE 8 or 4*/
biSizeImage, /*total bytes in image */
biXPelsPerMeter,/* 0,or opt,h res. */
biYPelsPerMeter,/* 0,or opt,h res. */
biClrUsed, /* normally 0,can set a lower no. colors than biBitCount */
biClrImportant; /* normally 0 */
}BITMAPINFOHEADER;
struct tagRGBQUAD{
unsigned char rgbBlue, /* blue intensity,0-255 */
rgbGreen, /* green intensity,0-255 */
rgbRed, /* red intensity,0-255 */
rgbReserved; /* reserved,set to Zero */
}RGBQUAD[NUM-COLOR];
char *fn-layer="layer.bmp";
char *fn-org="origin.bmp";
char *fn-result="result.bmp";
FILE *flayer,*fOrigin, *fResult;
unsigned char tmp-byte1,tmp-byte2;
unsigned int line,i-byte,i-pixel,x;
unsigned int layer;
int left-x,right-x;tmp-x;
unsigned long int cur-offset;
unsigned char h[WIDTH],org-color[WIDTH];
puts("---WINTRICK---");
puts("---by Li Jisong ---");
if( (fLayer=fopen(fn-layer,"rb") )!=NULL) {
fread(&BITMAPFILEHEADER,SIZE-OF-BITMAPFILEHADER,1,fLayer);
fread(&BITMAPINFOHEADER,SIZE-OF-BITMAPINFOHEADER,1,fLayer);
if( BITMAPFILEHEADER.bfType1=='B' && BITMAPFILEHEADER.bfType2=='M'
&& BITMAPINFOHEADER.biWidth==WIDTH && BITMAPINFOHEADER.biHeight==NUM-
LINE
&& BITMAPINFOHEADER.biBitCount==BITS-PER-PIXEL
&& BITMAPINFOHEADER.biCompression==COMPRESSION)
fread(RGBQUAD,SIZE-OF-RGBQUAD,NUM-COLOR,fLayer);
else{
fclose(fLayer);
printf("File %s is not fit for this program!/n",fn-layer);
getch();
exit(1);
}
}
else{
printf("File %s does not exist!/n",fn-layer);
getch();
exit(2);
}
if( (fOrigin=fopen(fn-org,"rb"))!=NULL) {
fread(& BITMAPFILEHEADER,SIZE-OF-BITMAPFILEHEADER,1,fOrigin);
fread(& BITMAPINFOHEADER,SIZE-OF-BITMAPINFOHEA
Tags:
作者:佚名评论内容只代表网友观点,与本站立场无关!
评论摘要(共 0 条,得分 0 分,平均 0 分)
查看完整评论