📄 paint.bak
字号:
#ifndef __PAINT_H
#define __PAINT_H
#define ESC 0x1b
#include <bios.h>
#include <conio.h>
#include <process.h>
#include <io.h>
#include <dos.h>
#include <stdarg.h>
#include <graphics.h>
#include <stdio.h>
void g_pset(int x,int y,int col)
{
putpixel(x,y,col);
}
void g_line(int x1,int y1,int x2,int y2,int col)
{
setcolor(col);
setlinestyle(0,1,0);
line(x1,y1,x2,y2);
}
void g_rectangle(int x1,int y1,int x2,int y2,int col,int fill)
{
if(fill!=1)
{
setcolor(col);
setlinestyle(0,1,0);
rectangle(x1,y1,x2,y2);
}
else
{
setfillstyle(1,col);
bar(x1,y1,x2,y2);
}
}
void g_text(int x,int y,int col,char *text)
{
setcolor(col);
settextstyle(0,0,1);
outtextxy(x,y,text);
}
//void read_clib16(FILE* stream, unsigned int hz_code,int x1,int y1);
void read_clib24 (unsigned int hz_code,int x1, int y1, FILE* stream)
{
register int i,j;
unsigned int gjqwm;
struct{
unsigned int bit0:1;
unsigned int bit1:1;
unsigned int bit2:1;
unsigned int bit3:1;
unsigned int bit4:1;
unsigned int bit5:1;
unsigned int bit6:1;
unsigned int bit7:1;
}sp[72];
union{
struct {
unsigned int bit0:1;
unsigned int bit1:1;
unsigned int bit2:1;
unsigned int bit3:1;
unsigned int bit4:1;
unsigned int bit5:1;
unsigned int bit6:1;
unsigned int bit7:1;
}s;
unsigned char byte;}cc;
long kk;
gjqwm=hz_code-1500;
kk=(gjqwm/100-1)*94+(gjqwm%100);
kk=(kk-1)*72;
fseek(stream,kk,SEEK_SET);
fread(sp,1,72,stream);
for(i=0;i<72;i=i+3)
{
for(j=2;j>=0;j--)
{
cc.s.bit7=sp[j+i].bit0;
cc.s.bit6=sp[j+i].bit1;
cc.s.bit5=sp[j+i].bit2;
cc.s.bit4=sp[j+i].bit3;
cc.s.bit3=sp[j+i].bit4;
cc.s.bit2=sp[j+i].bit5;
cc.s.bit1=sp[j+i].bit6;
cc.s.bit0=sp[j+i].bit7;
setlinestyle(USERBIT_LINE,cc.byte,1);
line(x1,y1+23-(2-j)*8,x1,y1+23-(2-j)*8-7);
}
x1=x1+1;
}
}
int disp_hz24(unsigned char *msg,int x1,int y1,int delt)
{
FILE *stream;
unsigned char g1,g2;
unsigned int hz_code;
register int i,j;
settextjustify(CENTER_TEXT,CENTER_TEXT);
if((stream=fopen("c:\\TC\\CODE\\GA\\hzk24s","rb"))==NULL)
{
setlinestyle(SOLID_LINE,0,1);
return 1;
}
for(;*msg;msg+=2)
{
g1=*msg-0xa0;
g2=*(msg+1)-0xa0;
hz_code=g1*100+g2;
read_clib24(hz_code,x1,y1,stream);
x1+=delt;
}
fclose(stream);
setlinestyle(SOLID_LINE,0,1);
return 0;
}
void read_clib16(unsigned int hz_code,int x1,int y1,FILE *stream)
{
register int i,j;
unsigned int gjqwm;
unsigned char sp[32];
unsigned long kk,k;
gjqwm=hz_code;
kk=(gjqwm/100-1)*94+(gjqwm%100);
kk=(kk-1)*32;
fseek(stream,kk,SEEK_SET);
fread(sp,1,32,stream);
for(i=0;i<32;i=i+2)
{
k=sp[i]*256+sp[i+1];
setlinestyle(USERBIT_LINE,k,1);
line(x1+15,y1,x1,y1);
y1++;
}
}
int disp_hz16(unsigned char *msg,int x1,int y1,int delt)
{
FILE *stream;
unsigned char g1,g2;
unsigned int hz_code;
register int i,j;
char msg_no_hz[1];
settextjustify(CENTER_TEXT,CENTER_TEXT);
if((stream=fopen("\\GA\\hzk16","rb"))==NULL)
{
setlinestyle(SOLID_LINE,0,1);
return 1;
}
next1: for(;*msg;msg+=2)
{
if(*msg<0xa0)
{
settextstyle(0,0,0);
msg_no_hz[0]=*msg;
msg_no_hz[1]=0;
outtextxy(x1,y1+8,msg_no_hz);
x1+=8;
msg++;
}
if(*msg<0xa0)
{
settextstyle(0,0,0);
msg_no_hz[0]=*msg;
msg_no_hz[1]=0;
outtextxy(x1,y1+8,msg_no_hz);
x1+=8;
msg++;
goto next1;
}
g1=*msg-0xa0;
g2=*(msg+1)-0xa0;
hz_code=g1*100+g2;
read_clib16(hz_code,x1,y1,stream);
x1+=delt;
}
fclose(stream);
setlinestyle(SOLID_LINE,0,1);
return 0;
}
int gprintf( int xloc,int yloc,int fc,int bc,char *fmt,...)
{
va_list argptr;
char str[150];
int cnt;
struct viewporttype view;
int xp,yp;
getviewsettings(&view);
va_start(argptr,fmt);
cnt=vsprintf(str,fmt,argptr);
va_end(argptr);
setfillstyle(1,bc);
bar(xloc,yloc,xloc+8*strlen(str),yloc+8);
settextjustify(LEFT_TEXT,TOP_TEXT);
setcolor(fc);
outtextxy(xloc,yloc,str);
return(cnt);
}
int gscanf(int x,int y,int fore,int back,int length,char *fmt,...)
{
va_list argptr;
char key[40];
int xp,yp,temp;
int i=0,xx=x,j;
char string[10];
char c[1];
union inkey{
char ch[2];
int i;
}cc;
setwritemode(1);
va_start(argptr,fmt);
line(x,y,x,y+8);
setcolor(fore);
setfillstyle(1,back);
settextjustify(0,2);
settextstyle(0,0,1);
do{
circl:
line(x,y,x,y+8);
if(bioskey(1))
{
cc.i=bioskey(0);
}
else
{ delay(100);
goto circl;
}
line(x,y,x,y+8);
if(cc.ch[0])
{
temp=key[i]=c[0]=cc.ch[0];
c[1]='\0';
switch(temp)
{
case 0x0d: goto next;
case 0x1b:
setcolor(back);
setwritemode(0);
line(x,y,x,y+8);
key[0]='\0';
vsscanf(key,fmt,argptr);
va_end(argptr);
return 1;
case 75*256:
case 8:
if(x<=xx) x=xx;
setfillstyle(1,back);
bar(x,y,x+8,y+8);
line(x,y,x,y+8);
i=i-2;
if(i<0) i=-1;
break;
defaut:
if(cc.ch[0])
{
line(x,y,x,y+8);
setfillstyle(1,back);
bar(x,y,x+8,y+8);
setcolor(fore);
settextstyle(0,0,1);
outtextxy(x,y,c);
// mouse_on(0);
x+=8;
}
break;
}
i++;
}
} while((i<length)&& (i>=0));
next:
setcolor(back);
setwritemode(0);
line(x,y,x,y+8);
key[i]='\0';
vsscanf(key,fmt,argptr);
va_end(argptr);
settextstyle(1,0,2);
return 0;
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -