yq7654
初级用户
积分 20
发帖 9
注册 2007-1-14
状态 离线
|
『楼 主』:
[原创]16x16及24x24点阵显示的c程序
16x16及24x24点阵显示的c程序:
get 16x16 dot.c
//沙尘暴 2007.8.6
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc,char **argv)
{
unsigned char *str=argv[1];
unsigned long int i,l=strlen(str);
FILE *hzlib;
if(argc!=2)
{
printf("argv is not enoug!\n");
return 1;
}
hzlib=fopen("hzk16","rb");
if(hzlib==NULL)
{
printf("Can't open hzk16!");
return 2;
}
printf("unsigned char *hzstr=\"%s\";\n",argv[1]);
printf("unsigned char hzdz[%d][32]=\n {\n",l/2);
while(*str)
{
fseek(hzlib,(long)(((*str-0xa0-1)*94L+*(str+1)-0xa0-1)*32L),SEEK_SET);
printf(" //\"%c%c\"的16×16点阵信息:\n ",*str,*(str+1));
for(i=1;i<33;i++)
{
printf("%#04X%s",fgetc(hzlib),i%8==0?i%32==0?",\n":",\n ":",");
}
printf(l==(str-argv[1]+2)?" };":"");
str+=2;
}
fclose(hzlib);
return 0;
}
display 16x16.c
//沙尘暴 2007.8.6
#include <graphics.h>
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
#include <stdlib.h>
#include <conio.h>
void DisplayHZ16x16(char *Font,int x, int y, int color) //x: 行坐标, y: 列坐标 color:汉字的显示色
{
int c,row;
for(row=0;row<16;row++)
{
for(c=0;c<8;c++)if((Font[row*2+0]>>(7-c))&0x1!=0)putpixel(c+0+(y*16),row+(x*16),color);
for(c=0;c<8;c++)if((Font[row*2+1]>>(7-c))&0x1!=0)putpixel(c+8+(y*16),row+(x*16),color);
}
}
void main()
{
int gd=DETECT,gm; //图形屏幕初始化
int x,y;
#include <a:\t.txt>//在这儿包含你刚才得到的点阵信息文件
char *t=hzstr;
registerbgidriver(EGAVGA_driver);
initgraph(&gd,&gm,"");
x=0; y=0; //显示位置设置,7行6列
while(*hzstr)
{
if(y>39){x++;y=0;}
DisplayHZ16x16(hzdz[(int)(hzstr-t)/2],x,y,WHITE);
y++;
hzstr+=2;
}
getch();
closegraph();
}
show 24x24.C
//沙尘暴 2007.8.6
char mo24x24[]= //"模"字的24X24点阵信息
{
0x00,0x00,0x00, 0x00,0x00,0x00, 0x07,0x0C,0xC0, 0x06,0x0C,0xC0,
0x06,0x0C,0xDC, 0x06,0x7F,0xF0, 0x06,0xCC,0xC0, 0x1F,0xF0,0x70,
0x06,0x3F,0xF0, 0x07,0x30,0x70, 0x0F,0xBF,0xF0, 0x0E,0xF0,0x70,
0x1E,0xF0,0x70, 0x1E,0x3F,0xF0, 0x36,0x06,0x18, 0x06,0xFF,0xFC,
0x06,0x07,0x00, 0x06,0x0F,0x80, 0x06,0x0C,0xE0, 0x06,0x38,0x7C,
0x06,0xE0,0x18, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00
};
//显示24x24点阵水平扫描C语言示例代码:
void DisplayHZ24x24(char * FontModule,int x, int y,int color)
{
int row,c;
for(row=0;row<24;row++)
{
for(c=0;c<8;c++)if(((FontModule[row*3+0]>>(7-c))&0x1)!=0)putpixel(c+00+(y*24),row+(x*24),color);
for(c=0;c<8;c++)if(((FontModule[row*3+1]>>(7-c))&0x1)!=0)putpixel(c+ 8+(y*24),row+(x*24),color);
for(c=0;c<8;c++)if(((FontModule[row*3+2]>>(7-c))&0x1)!=0)putpixel(c+16+(y*24),row+(x*24),color);
}
}
|
|