发布网友 发布时间:2022-04-23 21:09
共2个回答
热心网友 时间:2023-10-09 18:32
void drawmat(char *mat,int matsize,int x,int y,int color)
/*依次:字模指针、点阵大小、起始坐标(x,y)、颜色*/
{int i,j,k,n;
n=(matsize-1)/8+1;//n是点阵的列数
for(j=0;j<matsize;j++)//j代表点阵中第j行的字符意思
for(i=0;i<n;i++)//i代表点阵中第i列字符的意思
for(k=0;k<8;k++)//k代表在当前字模中,第k位的值
if(mat[j*n+i]&(0x80>>k)) /*测试为1的位则显示*/
putpixel(x+i*8+k,y+j,color);
}
你把字模的每个矩阵元素用二进制展开就知道k的意思了:
char shan16[]={
/* 以下是 '山' 的 16点阵宋体 字模,32 byte */
0x00,0x00,0x01,0x00,0x01,0x00,0x01,0x00,
0x01,0x00,0x01,0x00,0x01,0x08,0x21,0x08,
0x21,0x08,0x21,0x08,0x21,0xF8,0x2E,0x08,
0x30,0x08,0x00,0x00,0x00,0x00,0x00,0x00,
};
相当于:
0000 0000 0000 0000 0000 0001 0000 0000
0000 0001 0000 0000 0000 0001 0000 0000
0000 0001 0000 0000 0000 0001 0000 0000
0000 0001 0000 1000 0010 0001 0000 1000
0010 0001 0000 1000 0010 0001 0000 1000
0010 0001 1111 1000 0010 1110 0000 1000
0011 0000 0000 1000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
最后得到:
_______________8________________
___________8___8________________
___________8___8________________
______8____8___8________8___8___
__8___8____8___8________8___8___
__8___8____8888_8888____8___8___
__88____________________8_______
________________________________
热心网友 时间:2023-10-09 18:33
相关的主题文章:
we can provide you a lot of brand handbags,such as A&F,Nike Air Max 2003,Burberry,CA,Cartier,Chanel,Choles,COACH,D&G,Dooney&Bourke,ED Hardy,Fendi,Gucci,Hermes,Jimmy Choo,Loewe,LV,Miu Miu,Paul smith,POLO,Cheap Nike Air Max 90,PRADA,TOUS,VERSACE. The styles include every fashion bags,bagsAAA,Fashion purse,and purse AAA.And we have lots kinds of brand shoes,PUMA Tennis Shoes,clothing,jerseys,jewelry,brand Accessories and so on. You can pay attention to our website and send Email to us.