📄 jiemian.c
字号:
#include <stdio.h>
#include <graphics.h>
#include <time.h>
#include <conio.h>
#include "dir.h"
#include "dos.h"
char *malloc();
FILE *hzk_p ;
FILE *hzk12_p ;
void dishzCSB(char color);
void dishz12ld(char color);
void drawcoordinate(void);
void var(float x,int x1,int y1);
void setchan(char i);
void staticwindow(void);
void trendswindow(float ld,float nd,char chan);
void showdate(int x0,int y0);
char s3[10];
char bytes[32];
char bytes1[24];
char *s="超声波在线粒度检测仪";
char *s1="粒度趋势浓度趋势当前值浓度第一流道第二流道第三流道";
clock_t start,end;
int counter=0;
int sum1=0,sum2=0;
long int total_t=0;
int templd[100]={0};
int tempnd[100]={0};
int ldarray[61]={0};
int ndarray[61]={0};
char bmp_to_dat(char *bmp,char *dat)
{unsigned char c[8],scan_times,scan_pixs;
unsigned char workpos;int i,j,k,n,nowpos,iw,ih;
static int color[16]={0,4,2,6,1,5,3,7,8,12,10,14,9,13,11,15};
unsigned char workline[640],scanline[640];
FILE *fp,*targetfp;
union
{unsigned char value;
struct
{unsigned cl:4;
unsigned ch:4;
}color;
}mycolor;
if((fp=fopen(bmp,"rb"))==NULL)return(0);
targetfp=fopen(dat,"wb");
fseek(fp,18,SEEK_SET);
iw=0;ih=0;
fread(&iw,4,1,fp);
fread(&ih,4,1,fp);
if(iw==0&&ih==0&&iw>640&&ih>480)
{fclose(fp);fclose(targetfp);return(0);}
iw--;ih--;
scan_times=iw/8+1;
scan_pixs=scan_times*4;
fputc(iw%256,targetfp);
fputc(iw/256,targetfp);
fputc(ih%256,targetfp);
fputc(ih/256,targetfp);
fseek(fp,-scan_pixs,SEEK_END);
for(j=0;j<=ih;j++)
{nowpos=0;
fread(scanline,scan_pixs,1,fp);
fseek(fp,-scan_pixs*2,SEEK_CUR);
for(n=3;n>=0;n--)
{for(i=0;i<scan_times;i++)
{workpos=0;
for(k=0;k<4;k++)
{ mycolor.value=scanline[i*4+k];
c[k*2]=color[mycolor.color.ch];
c[k*2+1]=color[mycolor.color.cl];
}
for(k=0;k<8;k++)workpos+=(c[k]>>n&1)<<(7-k);
workline[nowpos]=workpos;nowpos++;
}}
fwrite(workline,scan_pixs,1,targetfp);
}
fclose(fp);fclose(targetfp);
return(1);
}
void staticwindow(void)
{
setbkcolor(BLUE);
setviewport(0,20,639,479,1); /* 开图视口 */
setfillstyle(1,CYAN);
setcolor(YELLOW);
rectangle(5,20,635,459);
floodfill(6,50, YELLOW);
setfillstyle(1,13);
rectangle(0,20,5,459);
floodfill(1,50, YELLOW);
setfillstyle(1,13);
rectangle(635,20,639,459);
floodfill(637,80,YELLOW);
setfillstyle(1,LIGHTGRAY);
rectangle(5,20,635,58);
floodfill(10,40,YELLOW);
setfillstyle(1,BROWN); /*第一格条*/
rectangle(5,58,635,60);
floodfill(6,59,YELLOW);
setcolor(LIGHTBLUE);
setfillstyle(1,LIGHTBLUE);
rectangle(577,360,634,380);
floodfill(600,370,LIGHTBLUE);
/*setfillstyle(1,BLUE);*/
/*rectangle(579,362,632,378);*/
/*floodfill(600,370,BLUE);*/
setfillstyle(1,LIGHTBLUE);
rectangle(577,330,634,350);
floodfill(600,340,LIGHTBLUE);
setcolor(YELLOW);
setfillstyle(1,YELLOW);
rectangle(556,66,566,76);
floodfill(565,70,YELLOW);
setcolor(RED);
setfillstyle(1,RED);
rectangle(556,83,566,93);
floodfill(565,85,RED);
setcolor(YELLOW);
setfillstyle(1,BROWN); /*第四格条*/
rectangle(5,428,635,430);
floodfill(6,429,YELLOW);
setfillstyle(1,BROWN);
rectangle(540,60,542,428);
floodfill(541,360,YELLOW);
setfillstyle(1,WHITE);
circle(15,445,5);
floodfill(15,445,YELLOW);
setfillstyle(1,WHITE);
circle(104,445,5);
floodfill(104,445,YELLOW);
setfillstyle(1,WHITE);
circle(193,445,5);
floodfill(193,445,YELLOW);
dishzCSB(YELLOW);
dishz12ld(YELLOW);
drawcoordinate();
/*setcolor(RED);*/
/*var(ld,617,336);*/
/*setcolor(BLUE);*/
/*var(nd,617,366);*/
/*setchan(chan);*/
}
void open_hzk(void)
{
hzk_p=fopen("c:/turboc2/work/hzk16","rb");
if (!hzk_p)
{
printf("The file HZK16 not exist! Enter to system\n");
getch();
exit(1);
}
}
void get_hz(char incode1,char incode2)
{
unsigned char qh,wh;
long int offset;
qh=incode1-0xa0; /*得到区号*/
wh=incode2-0xa0; /*得到位号*/
offset=(94*(qh-1)+(wh-1))*32L; /*得到偏移位置*/
fseek(hzk_p,offset,SEEK_SET); /*移文件指针到要读取的汉字字模处*/
fread(bytes,32,1,hzk_p); /*读取汉字的32个汉字字模*/
}
void dishz(int x0,int y0,char incode1,char incode2,char color)
{
unsigned char mask[]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
/*屏蔽字模每行各位的数组*/
int i,j;
void get_hz(char incode1,char incode2);
get_hz(s[i],s[i+1]);
for(i=0;i<16;i++)
for(j=0;j<8;j++)
{
if(bytes[2*i]&mask[j]) putpixel(x0+j,i+y0,BLUE);
if(bytes[2*i+1]&mask[j]) putpixel(x0+8+j,i+y0,BLUE);
}
}
void dishzCSB(char color)
{
int num,i;
int x0=248,y0=31;
char incode1,incode2;
void open_hzk(void);
void dishz(int x0,int y0,char incode1,char incode2, char color);
open_hzk();
/*char *s="超声波在线粒度检测仪";*/
num=strlen(s);
for(i=0;i<num;i+=2)
{
dishz(x0,y0,s[i],s[i+1],YELLOW);
x0+=16;
if(x0>=640)
{y0+=16;x0=0;}
}
fclose(hzk_p);
}
void dishz12ld(char color)
{
int num,i,j;
int x0,y0;
void open_hzk12(void);
void dishz12(int x0,int y0,char incode3,char incode4, char color);
open_hzk12();
setcolor(BLUE);
sprintf(s3,"-200");
outtextxy(544,336,s3);
num=strlen(s1);
for(j=0;j<7;j++)
{
switch(j)
{
case 0: {x0=571;y0=65;
for(i=0;i<7;i+=2)
{
dishz12(x0,y0,s1[i],s1[i+1],YELLOW);
x0+=16;
if(x0>=640)
{y0+=16;x0=0;}
}
} break;
case 1: {x0=571;y0=82;
for(i=8;i<15;i+=2)
{
dishz12(x0,y0,s1[i],s1[i+1],YELLOW);
x0+=16;
if(x0>=640)
{y0+=16;x0=0;}
}
} break;
case 2: {x0=545;y0=314;
for(i=16;i<21;i+=2)
{
dishz12(x0,y0,s1[i],s1[i+1],YELLOW);
x0+=16;
if(x0>=640)
{y0+=16;x0=0;}
}
} break;
case 3: {x0=544;y0=364;
for(i=22;i<25;i+=2)
{
dishz12(x0,y0,s1[i],s1[i+1],YELLOW);
x0+=16;
if(x0>=640)
{y0+=16;x0=0;}
}
} break;
case 4: {x0=25;y0=440;
for(i=26;i<33;i+=2)
{
dishz12(x0,y0,s1[i],s1[i+1],YELLOW);
x0+=16;
if(x0>=640)
{y0+=16;x0=0;}
}
} break;
case 5: {x0=114;y0=440;
for(i=34;i<41;i+=2)
{
dishz12(x0,y0,s1[i],s1[i+1],YELLOW);
x0+=16;
if(x0>=640)
{y0+=16;x0=0;}
}
} break;
case 6: {x0=203;y0=440;
for(i=42;i<num;i+=2)
{
dishz12(x0,y0,s1[i],s1[i+1],YELLOW);
x0+=16;
if(x0>=640)
{y0+=16;x0=0;}
}
} break;
default : break;
}
}
fclose(hzk12_p);
}
void open_hzk12(void)
{
hzk12_p=fopen("c:/turboc2/work/hzk12","rb");
if (!hzk12_p)
{
printf("The file HZK12not exist! Enter to system\n");
getch();
exit(1);
}
}
void get_hz12(char incode3,char incode4)
{
unsigned char qh,wh;
long int offset;
qh=incode3-0xa0; /*得到区号*/
wh=incode4-0xa0; /*得到位号*/
offset=(94*(qh-1)+(wh-1))*24L; /*得到偏移位置*/
fseek(hzk12_p,offset,SEEK_SET); /*移文件指针到要读取的汉字字模处*/
fread(bytes1,24,1,hzk12_p); /*读取汉字的24个汉字字模*/
}
void dishz12(int x0,int y0,char incode3,char incode4,char color)
{
unsigned char mask[]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
/*屏蔽字模每行各位的数组*/
int i,j;
void get_hz12(char incode3,char incode4);
get_hz12(s1[i],s1[i+1]);
for(i=0;i<12;i++)
for(j=0;j<8;j++)
{
if(bytes1[2*i]&mask[j]) putpixel(x0+j,i+y0,BLUE);
if(bytes1[2*i+1]&mask[j]) putpixel(x0+8+j,i+y0,BLUE);
}
}
void drawcoordinate(void)
{
char i,j,k;
char s0[2],s1[2],s2[2],s3[2],s4[2],s5[2],s6[2],s7[2],s8[2],s9[2],s10[2];
sprintf(s0,"0");
sprintf(s1,"1");
sprintf(s2,"2");
sprintf(s3,"3");
sprintf(s4,"4");
sprintf(s5,"5");
sprintf(s6,"6");
sprintf(s7,"7");
sprintf(s8,"8");
sprintf(s9,"9");
sprintf(s10,"%");
setcolor(BLUE);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -