2、例程:
<pre name="code" class="cpp">int Fb_QrDisp(int iPenX,int iPenY,QRcode*pQRcode)
{
T_PixelDatasg_tOriginPixelDatas
T_PixelDatasg_tZoomPixelDatas
//intiZoom
inti
g_tOriginPixelDatas.iWidth= pQRcode->width
g_tOriginPixelDatas.iHeight=pQRcode->width
g_tOriginPixelDatas.iLineBytes=g_tOriginPixelDatas.iWidth
g_tOriginPixelDatas.aucPixelDatas= pQRcode->data
/判激亩*
if(pQRcode->version <= 1)
{
iZoom= 2
}
else
{
iZoom= 2
}
g_tZoomPixelDatas.iWidth = pQRcode->width*iZoom
g_tZoomPixelDatas.iHeight=pQRcode->width*iZoom
g_tZoomPixelDatas.iLineBytes=g_tZoomPixelDatas.iWidth
g_tZoomPixelDatas.aucPixelDatas= malloc(g_tZoomPixelDatas.iWidth* g_tZoomPixelDatas.iHeight)
if(g_tZoomPixelDatas.aucPixelDatas== NULL)
{
printf("g_tZoomPixelDatas->aucPixelDatasmalloc failed\n")
return-1
}
PicZoom(&g_tOriginPixelDatas,&g_tZoomPixelDatas)
#if 0
printf("g_tZoomPixelDatas.iWidth=%d,g_tZoomPixelDatas.iHeight=%d\n", g_tZoomPixelDatas.iWidth,g_tZoomPixelDatas.iHeight)
for(i=0i<(g_tZoomPixelDatas.iWidth*g_tZoomPixelDatas.iHeight)i++)
{
printf("0x%x,",g_tZoomPixelDatas.aucPixelDatas[i])
}
printf("\n")
#endif
*/
Disp_FixelPic(iPenX,iPenY,&g_tZoomPixelDatas)
return 0
}
因为stmf429运行起来后内存不够,这里不用申请内存再扩充放大二维码数据的方法,而是直接描点。所以这里注释掉了放大部分
e) 紧接着铅州调用Disp_FixelPic根据qrcode进行描点
</pre><pre name="code" class="cpp"><pre name="code" class="cpp">void Disp_FixelPic(int iPenX,int iPenY,PT_PixelDatas ptPixelDatas)
{
int i=0,j=0
GUI_SetBkColor(GUI_WHITE)
GUI_Clear()
GUI_SetPenSize(1)
for(i=0i<ptPixelDatas->iHeighti++)
{
for(j=0j<掘森ptPixelDatas->iWidthj++)
{
if(ptPixelDatas->aucPixelDatas[i*ptPixelDatas->iHeight+j]&0x01)
{
//lcd_pixel_show(j+iPenX, i+iPenY,0x00)
GUI_SetColor(GUI_BLACK)
GUI_FillRect(j*8+iPenX, i*8+iPenY,j*8+8+iPenX, i*8+8+iPenY)
}
else
{
GUI_SetColor(GUI_WHITE)
//lcd_pixel_show(j+iPenX, i+iPenY, 0xffffff)
//GUI_DrawPoint(j*8+iPenX, i*8+iPenY)
GUI_FillRect(j*8+iPenX, i*8+iPenY,j*8+8+iPenX, i*8+8+iPenY)
}
}
}
}
这里注释掉了原lcd描点函数,而是采用了stemwin提供的矩形填充函数
f) 编译运行,能看到LCD显示出二维码。至此移植完毕
void Disp_FixelPic(int iPenX,intiPenY,PT_PixelDatas ptPixelDatas)
{
int i=0,j=0
GUI_SetBkColor(GUI_WHITE)
GUI_Clear()
GUI_SetPenSize(1)
for(i=0i<ptPixelDatas->iHeighti++)
{
for(j=0j<ptPixelDatas->iWidthj++)
{
if(ptPixelDatas->aucPixelDatas[i*ptPixelDatas->iHeight+j]&0x01)
{
//lcd_pixel_show(j+iPenX,i+iPenY,0x00)
GUI_SetColor(GUI_BLACK)
GUI_FillRect(j*8+iPenX, i*8+iPenY,j*8+8+iPenX, i*8+8+iPenY)
}
else
{
GUI_SetColor(GUI_WHITE)
//lcd_pixel_show(j+iPenX,i+iPenY, 0xffffff)
//GUI_DrawPoint(j*8+iPenX, i*8+iPenY)
GUI_FillRect(j*8+iPenX, i*8+iPenY,j*8+8+iPenX, i*8+8+iPenY)
}
}
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)