不用字库,用取取模方式在7寸TFTLCD上显示汉字请问下面的函数怎么修改,谢谢。哪位高手可以帮忙修改下,谢谢。
//code ×Ö·ûÖ¸Õë¿aê¼
//′ó×Ö¿aÖD2éÕò3ö×ÖÄ£
//code ×Ö·û′®μÄ¿aê¼μØÖ·,GBKÂë
//mat êy¾Y′æ·ÅμØÖ· size*2 bytes′óD¡
void Get_HzMat(unsigned char *code,unsigned char *mat,u8 size)
{
unsigned char qh,ql;
unsigned char i;
unsigned long foffset;
qh=*code;
ql=*(++code);
if(qh<0x81||ql<0x40||ql==0xff||qh==0xff)//·Ç 3£óÃoo×Ö
{
for(i=0;i<(size*2);i++)*mat++=0x00;//ìî3äÂú¸ñ
return; //½áêø·ÃÎê
}
if(ql<0x7f)ql-=0x40;//×¢òa!
else ql-=0x41;
qh-=0x81;
foffset=((unsigned long)190*qh+ql)*(size*2);//μÃμ½×Ö¿aÖDμÄ×Ö½úÆ«òÆá¿
if(size==16)SPI_Flash_Read(mat,foffset+ftinfo.f16addr,32);
else SPI_Flash_Read(mat,foffset+ftinfo.f12addr,24);
}
//ÏÔê¾ò»¸öÖ¸¶¨′óD¡μÄoo×Ö
//x,y
o×ÖμÄ×ø±ê
//font
o×ÖGBKÂë
//size:×Öìå′óD¡
//mode:0,Õy3£ÏÔê¾,1,μt¼óÏÔê¾
void Show_Font(u16 x,u16 y,u8 *font,u8 size,u8 mode)
{
u8 temp,t,t1;
u16 y0=y;
u8 dzk[32];
u16 tempcolor;
if(size!=12&&size!=16)return;//2»Ö§3ÖμÄsize
Get_HzMat(font,dzk,size);//μÃμ½Ïàó|′óD¡μÄμãÕóêy¾Y
if(mode==0)//Õy3£ÏÔê¾
{
for(t=0;t<size*2;t++)
{
temp=dzk[t];//μÃμ½12êy¾Y
for(t1=0;t1<8;t1++)
{
if(temp&0x80)LCD_DrawPoint(x,y);
else
{
tempcolor=POINT_COLOR;
POINT_COLOR=BACK_COLOR;
LCD_DrawPoint(x,y);
POINT_COLOR=tempcolor;//»1Ô-
}
temp<<=1;
y++;
if((y-y0)==size)
{
y=y0;
x++;
break;
}
}
}
}else//μt¼óÏÔê¾
{
for(t=0;t<size*2;t++)
{
temp=dzk[t];//μÃμ½12êy¾Y
for(t1=0;t1<8;t1++)
{
if(temp&0x80)LCD_DrawPoint(x,y);
temp<<=1;
y++;
if((y-y0)==size)
{
y=y0;
x++;
break;
}
}
}
}
}
//ÔúÖ¸¶¨Î»Öÿaê¼ÏÔê¾ò»¸ö×Ö·û′®
//Ö§3Ö×Ô¶ˉ»»DD
//(x,y):Æeê¼×ø±ê
//width,height:Çøóò
//str :×Ö·û′®
//size :×Öìå′óD¡
//mode:0,·Çμt¼ó·½ê½;1,μt¼ó·½ê½
void Show_Str(u16 x,u16 y,u16 width,u16 height,u8*str,u8 size,u8 mode)
{
u16 x0=x;
u16 y0=y;
u8 bHz=0; //×Ö·û»òÕßÖDÎÄ
while(*str!=0)//êy¾YÎ′½áêø
{
if(!bHz)
{
if(*str>0x80)bHz=1;//ÖDÎÄ
else //×Ö·û
{
if(x>(x0+width-size/2))//»»DD
{
y+=size;
x=x0;
}
if(y>(y0+height-size))break;//Ô½½ç·μ»Ø
if(*str==13)//»»DD·ûoÅ
{
y+=size;
x=x0;
str++;
}
else LCD_ShowChar(x,y,*str,size,mode);//óDD§2¿·ÖD′èë
str++;
x+=size/2; //×Ö·û,Îaè«×ÖμÄò»°ë
}
}else//ÖDÎÄ
{
bHz=0;//óDoo×Ö¿a
if(x>(x0+width-size))//»»DD
{
y+=size;
x=x0;
}
if(y>(y0+height-size))break;//Ô½½ç·μ»Ø
Show_Font(x,y,str,size,mode); //ÏÔê¾Õa¸öoo×Ö,¿ÕDÄÏÔê¾
str+=2;
x+=size;//ÏÂò»¸öoo×ÖÆ«òÆ
}
}
}
//ÔúÖ¸¶¨¿í¶èμÄÖD¼äÏÔê¾×Ö·û′®
//èç1û×Ö·û3¤¶è3¬1yáËlen,ÔòóÃShow_StrÏÔê¾
//len:Ö¸¶¨òaÏÔê¾μÄ¿í¶è
void Show_Str_Mid(u16 x,u16 y,u8*str,u8 size,u8 len)
{
u16 strlenth=0;
strlenth=strlen((const char*)str);
strlenth*=size/2;
if(strlenth>len)Show_Str(x,y,240,320,str,size,1);
else
{
strlenth=(len-strlenth)/2;
Show_Str(strlenth+x,y,240,320,str,size,1);
}
}
一周热门 更多>