?? gui.c.1
字號:
/* gui.c: Graphics demos
*
* Programmed By Chen: Yang (support@hhcn.com)
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#include <stdio.h> /* Standard input/output definitions */
#include <string.h> /* String function definitions */
#include <unistd.h> /* UNIX standard function definitions */
#include <fcntl.h> /* File control definitions */
#include <errno.h> /* Error number definitions */
#include <termios.h> /* POSIX terminal control definitions */
#include<sys/types.h>
#include<sys/stat.h>
#include <stdlib.h>
#include "gui.h"
void delay() /*延時(shí)函數(shù)*/
{int i,j;
for(i=0;i<1000;i++)
for(j=0;j<7000;j++) {}
}
main(int argc,char*argv[])
{
short i,j,w,h;
struct stat st;
int color0,filelength;
PatternIndex p1=BlackPattern;
/*定義緩沖區(qū),并初始化*/
char buf[20]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
char buf1[700000];
short *o,*c;
int *p;
long *q;
FILE *fp;
/*初始化液晶屏*/
initgraph();
clearscreen();
/*畫出方框*/
fillrect(10,10,100,100);
/*在指定的坐標(biāo)出顯出彩色文本*/
textout(0,130,"hello!\n\nA Student",0xf800,0x0000);
/*以只讀方式打開文件*/
if((fp=fopen("bqb4.bmp","r"))==NULL)
{
/*如文件缺失則報(bào)錯(cuò),返回*/
printf("Can't find the file");
return 1;
}
/*取得文件的狀態(tài)參數(shù),存放于結(jié)構(gòu)體內(nèi)*/
stat("bqb4.bmp",&st);
/*從結(jié)構(gòu)體中取出文件長度*/
filelength=st.st_size;
delay();
/*文本輸出*/
textout(0,30,"這只是一個(gè)小實(shí)驗(yàn)\n",0xf900,0x0000);
/*將文件內(nèi)容讀入緩沖區(qū),剛才取得的文件長度應(yīng)用于此*/
fread(buf1,1,filelength,fp);
/*關(guān)閉文件,釋放資源*/
fclose(fp);
/*從緩沖區(qū)進(jìn)行液晶屏輸出*/
ShowBuf(buf1,0,0);
/*打開文件*/
fp=fopen("bqb6.bmp","r");
/*取得文件參數(shù)*/
stat("bqb6.bmp",&st);
/*取得文件長度*/
filelength=st.st_size;
/*讀入緩沖區(qū)*/
fread(buf1,1,filelength,fp);
fclose(fp);
/*顯示緩沖區(qū)*/
ShowBuf(buf1,0,0);
/*以下同理,可以改用ShowBMP函數(shù),使用很方便,但顯示時(shí)沒有ShowBuf流暢!*/
fp=fopen("bqb8.bmp","r");
stat("bqb8.bmp",&st);
fread(buf1,1,st.st_size,fp);
fclose(fp);
delay();
ShowBuf(buf1,0,0);
fp=fopen("bqb10.bmp","r");
stat("bqb10.bmp",&st);
fread(buf1,1,st.st_size,fp);
fclose(fp);
delay();
ShowBuf(buf1,0,0);
delay();
fp=fopen("bqb12.bmp","r");
stat("bqb12.bmp",&st);
fread(buf1,1,st.st_size,fp);
fclose(fp);
delay();
ShowBuf(buf1,0,0);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -