69,373
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <conio.h>
const unsigned char bit[8]={128,64,32,16,8,4,2,1};
unsigned char buffer[32];
FILE *hzk;
unsigned long offset;
unsigned int q,w;
int x,y,qw;
//--------------------------------------------------------
void display(char *hz) {
qw=*((int *)hz);
q=(qw&0x00FF)-0xA1;
w=((qw>>8)&0x00FF)-0xA1;
offset=q*0x5E+w;
offset*=32;
if ((hzk=fopen("HZK16","rb"))==NULL) {
printf("Can not open file HZK16!\n");
return;
}
fseek(hzk,offset,SEEK_SET);
fread(buffer,1,32,hzk);
fclose(hzk);
for (y=0;y<16;y++) {
for (x=0;x<16;x++) {
if (buffer[y*2+x/8] & bit[x%8]) {
printf("%s",hz);
} else {
printf(" ");
}
}
printf("\n");
}
}
void main() {
display("啊");
getch();
}
// 啊
// 啊 啊啊啊啊 啊啊啊啊啊啊
//啊啊啊啊啊 啊 啊
//啊 啊 啊 啊 啊
//啊 啊 啊 啊 啊 啊
//啊 啊 啊 啊 啊啊啊啊啊
//啊 啊 啊啊 啊 啊 啊
//啊 啊 啊 啊 啊 啊 啊
//啊 啊 啊 啊 啊 啊 啊
//啊 啊 啊 啊 啊 啊 啊
//啊啊啊 啊 啊 啊啊啊 啊
//啊 啊 啊啊 啊 啊 啊 啊
// 啊 啊 啊
// 啊 啊
// 啊 啊 啊
// 啊 啊啊
#include <mem.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <graphics.h>
const unsigned char bit[8]={128,64,32,16,8,4,2,1};
//--------------------------------------------------------
void dis(xoff,code)
unsigned int xoff,code;
{
unsigned char *buffer;
FILE *hzk;
unsigned long offset;
unsigned int q,w;
int x,y,width;
buffer=calloc(32,1);
if ((code&0xFF00)!=0) {
w=(code&0x00FF)-0xA1;
q=((code>>8)&0x00FF)-0xA1;
offset=q*0x5E+w;
offset*=32;
if ((hzk=fopen("HZK16","rb"))==NULL) {
closegraph();
printf("Can not open HZK16\r\n");
exit(1);
}
fseek(hzk,offset,SEEK_SET);
fread(buffer,1,32,hzk);
fclose(hzk);
width=2;
}
else {
if ((hzk=fopen("ASC16","rb"))==NULL) {
closegraph();
printf("Can not open ASC16\r\n");
exit(1);
}
offset=code*16;
fseek(hzk,offset,SEEK_SET);
fread(buffer,1,16,hzk);
fclose(hzk);
width=1;
}
for (y=0;y<16;y++) for (x=0;x<8*width;x++) {
if (buffer[y*width+x/8]&bit[x%8]) putpixel(xoff+x,y,15);
}
free(buffer);
}
//--------------------------------------------------------
void display(p)
unsigned char *p;
{
int i;
unsigned int qw;
i=0;
while (1) {
if (p[i]==0x0D||p[i]==0x1A) break;
if (p[i]>0xA0) {
qw=((unsigned int)p[i]<<8)|((unsigned int)p[i+1]&0x00FF);
dis(8*i,qw);
i+=2;
}
else {
qw=(unsigned int)p[i]&0x00FF;
dis(8*i,qw);
i++;
}
}
}
//--------------------------------------------------------
void main()
{
int gdriver = DETECT, gmode, errorcode;
long fl;
FILE *hz;
unsigned char *p;
initgraph(&gdriver, &gmode, "c:\\borlandc\\bgi");
errorcode = graphresult();
if (errorcode != grOk) {
printf("Graphics error: %s\n", grapherrormsg(errorcode));
exit(1);
}
hz=fopen("hz","rb");
fseek(hz,0,SEEK_END);
fl=ftell(hz);
p=calloc((int)fl,sizeof(unsigned char));
rewind(hz);
fread(p,1,(int)fl,hz);
fclose(hz);
display(p);
free(p);
getch();
closegraph();
}