3056
- 收藏
- 点赞
- 分享
- 举报
hi3519通过hifb显示菜单以实现中英文sensor使用imx274,imx226也调出
本帖最后由 924742206 于 2018-5-22 14:54 编辑
最近通过hifb通过点阵的方式实现了OSD菜单的显示(参考论坛里的程序),已经实现中英文
主要函数如下
void YtoRGB1555ToChar(unsigned char Y,unsigned char *rgb1555_0,unsigned char *rgb1555_1,int nColor)
{
if(Y>0x01){
Y=0xF0;
switch(nColor){
case 0://白色
*rgb1555_0=0xFF;
*rgb1555_1=0xFF;
break;
case 1://
*rgb1555_0=0x80;
*rgb1555_1=0x80;
break;
case 2:
*rgb1555_0=0xFF;
*rgb1555_1=0x80;
break;
case 3:
*rgb1555_0=0x14;
*rgb1555_1=0x14;
break;
}
return;
}
}
void DrawOSD(unsigned char *buf, unsigned short *hzLib,int stride,int nColor)
{
int i, font;
int lumi;
int lum=1;
int *p1 = (int *)(buf+(stride<<4));
float mult_f = (float)(lum?0.20:1);
mult_f=0.5;
float mult_b = 1 - mult_f;
int avglum = (buf[0] + buf[1] + buf[2] + buf[3] + buf[4] +buf[5] + buf[6] + buf[7] + buf[8] + buf[9] + buf[10] +buf[11] + buf[12] + buf[13] + buf[14] + buf[15])/16;
if(!lum&&(avglum>145))
lumi = 0x1;
else
lumi = 0xff;
//1字节个亮度信息转为2字节1555
int nD=2;//翻倍
unsigned short Y;
int nPos=0;
for (i=0; i<16; i++) {
font = *hzLib ++;
nPos=0;//buf[0*nD]和buf[0*nD+1] 2个字节就是1555
Y = (unsigned char)MUX(font&0x0080, lumi*mult_f+buf[0*nD]*mult_b, buf[0*nD]); //这个就是一个Y 变成1555 2个字节
YtoRGB1555ToChar(Y,buf+nPos*nD,buf+nPos*nD+1,nColor);
nPos=1;
Y = (unsigned char)MUX(font&0x0040, lumi*mult_f+buf[1*nD]*mult_b, buf[1*nD]);
YtoRGB1555ToChar(Y,buf+nPos*nD,buf+nPos*nD+1,nColor);
nPos=2;
Y = (unsigned char)MUX(font&0x0020, lumi*mult_f+buf[2*nD]*mult_b, buf[2*nD]);
YtoRGB1555ToChar(Y,buf+nPos*nD,buf+nPos*nD+1,nColor);
nPos=3;
Y = (unsigned char)MUX(font&0x0010, lumi*mult_f+buf[3*nD]*mult_b, buf[3*nD]);
YtoRGB1555ToChar(Y,buf+nPos*nD,buf+nPos*nD+1,nColor);
nPos=4;
Y = (unsigned char)MUX(font&0x0008, lumi*mult_f+buf[4*nD]*mult_b, buf[4*nD]);
YtoRGB1555ToChar(Y,buf+nPos*nD,buf+nPos*nD+1,nColor);
nPos=5;
Y = (unsigned char)MUX(font&0x0004, lumi*mult_f+buf[5*nD]*mult_b,buf[5*nD]);
YtoRGB1555ToChar(Y,buf+nPos*nD,buf+nPos*nD+1,nColor);
nPos=6;
Y = (unsigned char)MUX(font&0x0002, lumi*mult_f+buf[6*nD]*mult_b,buf[6*nD]);
YtoRGB1555ToChar(Y,buf+nPos*nD,buf+nPos*nD+1,nColor);
nPos=7;
Y = (unsigned char)MUX(font&0x0001, lumi*mult_f+buf[7*nD]*mult_b,buf[7*nD]);
YtoRGB1555ToChar(Y,buf+nPos*nD,buf+nPos*nD+1,nColor);
nPos=8;
Y = (unsigned char)MUX(font&0x8000, lumi*mult_f+buf[8*nD]*mult_b,buf[8*nD]);
YtoRGB1555ToChar(Y,buf+nPos*nD,buf+nPos*nD+1,nColor);
nPos=9;
Y = (unsigned char)MUX(font&0x4000, lumi*mult_f+buf[9*nD]*mult_b,buf[9*nD]);
YtoRGB1555ToChar(Y,buf+nPos*nD,buf+nPos*nD+1,nColor);
nPos=10;
Y = (unsigned char)MUX(font&0x2000, lumi*mult_f+buf[10*nD]*mult_b, buf[10*nD]);
YtoRGB1555ToChar(Y,buf+nPos*nD,buf+nPos*nD+1,nColor);
nPos=11;
Y = (unsigned char)MUX(font&0x1000, lumi*mult_f+buf[11*nD]*mult_b, buf[11*nD]);
YtoRGB1555ToChar(Y,buf+nPos*nD,buf+nPos*nD+1,nColor);
nPos=12;
Y = (unsigned char)MUX(font&0x0800, lumi*mult_f+buf[12*nD]*mult_b, buf[12*nD]);
YtoRGB1555ToChar(Y,buf+nPos*nD,buf+nPos*nD+1,nColor);
nPos=13;
Y = (unsigned char)MUX(font&0x0400, lumi*mult_f+buf[13*nD]*mult_b, buf[13*nD]);
YtoRGB1555ToChar(Y,buf+nPos*nD,buf+nPos*nD+1,nColor);
nPos=14;
Y = (unsigned char)MUX(font&0x0200, lumi*mult_f+buf[14*nD]*mult_b, buf[14*nD]);
YtoRGB1555ToChar(Y,buf+nPos*nD,buf+nPos*nD+1,nColor);
nPos=15;
Y = (unsigned char)MUX(font&0x0100, lumi*mult_f+buf[15*nD]*mult_b, buf[15*nD]);
YtoRGB1555ToChar(Y,buf+nPos*nD,buf+nPos*nD+1,nColor);
buf += stride*2;
}
}
int ShowOSD_DEC_BOX_MX(unsigned char *pBase, char *pStr, unsigned short x, unsigned short y,int width, int height,int nColor)
{
if(!pBase||!pStr||width<1||height<1||x>width||y>=height)
return 0;
UInt32 nChar=0,wd=0,nOffset=0,nSize, l, r;
Int8 q=3;
Int8 w;
Int8 *p=(char *)pStr;
UInt8 *pHZLib=0;
UInt8 *pp = (unsigned char *)p;
pBase += width*2*y+x*2;
while (*p) {
pp = (unsigned char *)p;
q = *p&0x80?(*p++)-161:2; // Get qu code
w=((*p++)&0x7f)-33; // Get wei code
if ((int)(nOffset = q*94+w) >= g_real_HZ16_count)
continue;
pHZLib = (HZ16Lib+(nOffset<<5));
if (q<10) {
l = UBYTESEL(HZ16_Space[nOffset],1);
r = UBYTESEL(HZ16_Space[nOffset],0);
nSize = HZLIB_ZISE-(l+r);
}
else {
nSize = HZLIB_ZISE;
l = r = 0;
}
if ((int)(x+wd+nSize)>width)
break;
DrawOSD(pBase+(wd+nChar)*2,(unsigned short *)pHZLib,width,nColor);
nChar++;
wd += 14;//12 自体间距
}
return nChar;
}
static int OSD_MENU_Init()
{
int colordata=15;
char colorbuf[1]={0};
int nWndWidth = WIDTH_720;
int nWndHeight = HEIGHT_576;
sprintf(colorbuf,"%d",colordata);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"SYSTEM",150,64,nWndWidth,nWndHeight,0);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"COLOR",128,96,nWndWidth,nWndHeight,0);ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,colorbuf,240,96,nWndWidth,nWndHeight,0);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"DNR",128,128,nWndWidth,nWndHeight,0);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"DIS",128,160,nWndWidth,nWndHeight,0);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"*DEFOG",112,192,nWndWidth,nWndHeight,2);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"picture",128,224,nWndWidth,nWndHeight,0);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"ZOOM",128,256,nWndWidth,nWndHeight,0);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"VIDEO",128,288,nWndWidth,nWndHeight,0);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"WBMODEL",128,320,nWndWidth,nWndHeight,0);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"RETURN",128,352,nWndWidth,nWndHeight,0);
return 0;
}
static int OSD_MENU_update()
{
int nWndWidth = WIDTH_720;
int nWndHeight = HEIGHT_576;
HI_S32 s32Ret = HI_SUCCESS;
sprintf(colorbuf,"%d",colordata);
sprintf(dnrbuf,"%d",dnrdata);
if (ioctl(osdfb, FBIOPUT_SCREEN_ORIGIN_HIFB, &stPoint) < 0)
{
SAMPLE_PRT("set screen original show position failed!\n");
close(osdfb);
return HI_NULL;
}
memset(pOSDRGB,0x0,SAMPLE_IMAGE_WIDTH * SAMPLE_IMAGE_HEIGHT * 2);
memset(pBuf,0x0,maxW*maxH*2);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"SYSTEM",150,64,nWndWidth,nWndHeight,0);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"COLOR",128,96,nWndWidth,nWndHeight,0);ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,colorbuf,240,96,nWndWidth,nWndHeight,0);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"DNR",128,128,nWndWidth,nWndHeight,2);ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,dnrbuf,240,128,nWndWidth,nWndHeight,2);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"DIS",128,160,nWndWidth,nWndHeight,0);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"DEFOG",128,192,nWndWidth,nWndHeight,0);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"picture",128,224,nWndWidth,nWndHeight,0);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"ZOOM",128,256,nWndWidth,nWndHeight,0);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"VIDEO",128,288,nWndWidth,nWndHeight,0);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"WBMODEL",128,320,nWndWidth,nWndHeight,0);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"RETURN",128,352,nWndWidth,nWndHeight,0);
/*copy memeroy*/
memcpy(pBuf,pOSDRGB,maxW*maxH*2);
//stCanvasBuf.UpdateRect.x = 180;
//stCanvasBuf.UpdateRect.y = 180;
stCanvasBuf.UpdateRect.x = 0;
stCanvasBuf.UpdateRect.y = 0;
stCanvasBuf.UpdateRect.w = maxW;
stCanvasBuf.UpdateRect.h = maxH;
s32Ret = ioctl(osdfb, FBIO_REFRESH, &stCanvasBuf);
if (s32Ret < 0)
{
SAMPLE_PRT("REFRESH failed!\n");
HI_MPI_SYS_MmzFree(Phyaddr, pOSDRGB);
HI_MPI_SYS_MmzFree(stCanvasBuf.stCanvas.u32PhyAddr, pBuf);
close(osdfb);
return HI_NULL;
}
// printf("Enter any key to exit\n");
// getchar();
// HI_MPI_SYS_MmzFree(Phyaddr, pOSDRGB);
// HI_MPI_SYS_MmzFree(stCanvasBuf.stCanvas.u32PhyAddr, pBuf);
// close(fd);
return 0;
}
HI_S32 OSD_MENU_HIFB_init()
{
HI_S32 s32Ret = HI_SUCCESS;
HIFB_LAYER_INFO_S stLayerInfo = {0};
HI_U8* pDst = NULL;
//HI_U32 x;
//HI_U32 y;
//HI_U32 i;
HI_CHAR image_name[128];
HI_BOOL bShow;
struct fb_var_screeninfo stVarInfo;
HI_CHAR file[12] = "/dev/fb0";
int fd;
HIFB_COLORKEY_S stColorKey;
TDE2_RECT_S stSrcRect, stDstRect;
TDE2_SURFACE_S stSrc, stDst;
TDE_HANDLE s32Handle;
fd = open("/dev/fb0", O_RDWR, 0);
osdfb = fd;
if (fd < 0)
{
SAMPLE_PRT("open %s failed!\n", file);
return HI_NULL;
}
/*all layer surport colorkey*/
stColorKey.bKeyEnable = HI_TRUE;
stColorKey.u32Key = 0x0;
if (ioctl(fd, FBIOPUT_COLORKEY_HIFB, &stColorKey) < 0)
{
SAMPLE_PRT("FBIOPUT_COLORKEY_HIFB!\n");
close(fd);
return HI_NULL;
}
s32Ret = ioctl(fd, FBIOGET_VSCREENINFO, &stVarInfo);
if (s32Ret < 0)
{
SAMPLE_PRT("GET_VSCREENINFO failed!\n");
close(fd);
return HI_NULL;
}
if (ioctl(fd, FBIOPUT_SCREEN_ORIGIN_HIFB, &stPoint) < 0)
{
SAMPLE_PRT("set screen original show position failed!\n");
close(fd);
return HI_NULL;
}
maxW = WIDTH_720;
maxH = HEIGHT_576;
stVarInfo.transp = s_a16;
stVarInfo.red = s_r16;
stVarInfo.green = s_g16;
stVarInfo.blue = s_b16;
stVarInfo.bits_per_pixel = 16;
stVarInfo.activate = FB_ACTIVATE_NOW;
stVarInfo.xres = stVarInfo.xres_virtual = maxW;
stVarInfo.yres = stVarInfo.yres_virtual = maxH;
s32Ret = ioctl(fd, FBIOPUT_VSCREENINFO, &stVarInfo);
if (s32Ret < 0)
{
SAMPLE_PRT("PUT_VSCREENINFO failed!\n");
close(fd);
return HI_NULL;
}
stLayerInfo.BufMode = HIFB_LAYER_BUF_NONE;
stLayerInfo.u32Mask = HIFB_LAYERMASK_BUFMODE;
s32Ret = ioctl(fd, FBIOPUT_LAYER_INFO, &stLayerInfo);
if (s32Ret < 0)
{
SAMPLE_PRT("PUT_LAYER_INFO failed!\n");
close(fd);
return HI_NULL;
}
// bShow = HI_TRUE;
bShow = HI_FALSE;
if (ioctl(fd, FBIOPUT_SHOW_HIFB, &bShow) < 0)
{
SAMPLE_PRT("FBIOPUT_SHOW_HIFB failed!\n");
close(fd);
return HI_NULL;
}
if (HI_FAILURE == HI_MPI_SYS_MmzAlloc(&(stCanvasBuf.stCanvas.u32PhyAddr), ((void**)&pBuf),
NULL, NULL, maxW * maxH * 2))
{
SAMPLE_PRT("allocate memory (maxW*maxH*2 bytes) failed\n");
close(fd);
return HI_NULL;
}
stCanvasBuf.stCanvas.u32Height = maxH;
stCanvasBuf.stCanvas.u32Width = maxW;
stCanvasBuf.stCanvas.u32Pitch = maxW * 2;
stCanvasBuf.stCanvas.enFmt = HIFB_FMT_ARGB1555;
memset(pBuf, 0x00, stCanvasBuf.stCanvas.u32Pitch * stCanvasBuf.stCanvas.u32Height);
/*change bmp*/
if (HI_FAILURE == HI_MPI_SYS_MmzAlloc(&Phyaddr, ((void**)&pOSDRGB),
NULL, NULL, SAMPLE_IMAGE_WIDTH * SAMPLE_IMAGE_HEIGHT * 2))
{
SAMPLE_PRT("allocate memory failed\n");
HI_MPI_SYS_MmzFree(stCanvasBuf.stCanvas.u32PhyAddr, pBuf);
close(fd);
return HI_NULL;
}
if(NULL != pOSDRGB){
memset(pOSDRGB,0x0,SAMPLE_IMAGE_WIDTH * SAMPLE_IMAGE_HEIGHT * 2);
}
return 0;
}
HI_S32 OSD_MENU_HIFB_Refresh()
{
HI_S32 s32Ret = HI_SUCCESS;
/*init osd menu*/
OSD_MENU_Init();
/*copy memeroy*/
memcpy(pBuf,pOSDRGB,maxW*maxH*2);
//stCanvasBuf.UpdateRect.x = 180;
//stCanvasBuf.UpdateRect.y = 180;
stCanvasBuf.UpdateRect.x = 0;
stCanvasBuf.UpdateRect.y = 0;
stCanvasBuf.UpdateRect.w = maxW;
stCanvasBuf.UpdateRect.h = maxH;
s32Ret = ioctl(osdfb, FBIO_REFRESH, &stCanvasBuf);
if (s32Ret < 0)
{
SAMPLE_PRT("REFRESH failed!\n");
HI_MPI_SYS_MmzFree(Phyaddr, pOSDRGB);
HI_MPI_SYS_MmzFree(stCanvasBuf.stCanvas.u32PhyAddr, pBuf);
close(osdfb);
return HI_NULL;
}
// printf("Enter any key to exit\n");
// getchar();
// HI_MPI_SYS_MmzFree(Phyaddr, pOSDRGB);
// HI_MPI_SYS_MmzFree(stCanvasBuf.stCanvas.u32PhyAddr, pBuf);
// close(fd);
return 0;;
}
/**********************************************
*
* Name: OSD_MENU_HandleSig
* Description: ctrl + c / z
* Param:
* Return:
*
*********************************************/
HI_VOID OSD_MENU_HandleSig(HI_S32 signo)
{
if (SIGINT == signo || SIGTERM == signo)
{
//HI_MPI_SYS_MmzFree(Phyaddr, pOSDRGB);
//HI_MPI_SYS_MmzFree(stCanvasBuf.stCanvas.u32PhyAddr, pBuf);
//close(fd);
printf("\033[0;31mprogram exit abnormally!\033[0;39m\n");
}
exit(0);
}
下面是串口处理程序
void uartservice(void)
{
HI_BOOL bShow;
if(Recvdatas[0]==0x5a&&Recvdatas[1]==0x00&&Recvdatas[2]==0x00&&Recvdatas[3]==0x5b)//menu
{
menuflag++;
printf("menu\n");
dnrdata++;
if(menuflag)
{
bShow = HI_TRUE;//display menu
OSD_MENU_update();
}
// else
// {
// menuflag=0;
// bShow = HI_FALSE; //undisplay menu
// }
if (ioctl(osdfb, FBIOPUT_SHOW_HIFB, &bShow) < 0)//control menu display or undisplay
{
SAMPLE_PRT("FBIOPUT_SHOW_HIFB failed!\n");
close(osdfb);
return HI_NULL;
}
}
if(Recvdatas[0]==0x5a&&Recvdatas[1]==0x00&&Recvdatas[2]==0x01&&Recvdatas[3]==0x5b)//up
{
printf("up\n");
}
if(Recvdatas[0]==0x5a&&Recvdatas[1]==0x00&&Recvdatas[2]==0x02&&Recvdatas[3]==0x5b)//down
{
printf("down\n");
}
if(Recvdatas[0]==0x5a&&Recvdatas[1]==0x00&&Recvdatas[2]==0x03&&Recvdatas[3]==0x5b)//left
{
printf("left\n");
}
if(Recvdatas[0]==0x5a&&Recvdatas[1]==0x00&&Recvdatas[2]==0x04&&Recvdatas[3]==0x5b)//rignt
{
printf("left\n");
}
}
最近通过hifb通过点阵的方式实现了OSD菜单的显示(参考论坛里的程序),已经实现中英文
主要函数如下
void YtoRGB1555ToChar(unsigned char Y,unsigned char *rgb1555_0,unsigned char *rgb1555_1,int nColor)
{
if(Y>0x01){
Y=0xF0;
switch(nColor){
case 0://白色
*rgb1555_0=0xFF;
*rgb1555_1=0xFF;
break;
case 1://
*rgb1555_0=0x80;
*rgb1555_1=0x80;
break;
case 2:
*rgb1555_0=0xFF;
*rgb1555_1=0x80;
break;
case 3:
*rgb1555_0=0x14;
*rgb1555_1=0x14;
break;
}
return;
}
}
void DrawOSD(unsigned char *buf, unsigned short *hzLib,int stride,int nColor)
{
int i, font;
int lumi;
int lum=1;
int *p1 = (int *)(buf+(stride<<4));
float mult_f = (float)(lum?0.20:1);
mult_f=0.5;
float mult_b = 1 - mult_f;
int avglum = (buf[0] + buf[1] + buf[2] + buf[3] + buf[4] +buf[5] + buf[6] + buf[7] + buf[8] + buf[9] + buf[10] +buf[11] + buf[12] + buf[13] + buf[14] + buf[15])/16;
if(!lum&&(avglum>145))
lumi = 0x1;
else
lumi = 0xff;
//1字节个亮度信息转为2字节1555
int nD=2;//翻倍
unsigned short Y;
int nPos=0;
for (i=0; i<16; i++) {
font = *hzLib ++;
nPos=0;//buf[0*nD]和buf[0*nD+1] 2个字节就是1555
Y = (unsigned char)MUX(font&0x0080, lumi*mult_f+buf[0*nD]*mult_b, buf[0*nD]); //这个就是一个Y 变成1555 2个字节
YtoRGB1555ToChar(Y,buf+nPos*nD,buf+nPos*nD+1,nColor);
nPos=1;
Y = (unsigned char)MUX(font&0x0040, lumi*mult_f+buf[1*nD]*mult_b, buf[1*nD]);
YtoRGB1555ToChar(Y,buf+nPos*nD,buf+nPos*nD+1,nColor);
nPos=2;
Y = (unsigned char)MUX(font&0x0020, lumi*mult_f+buf[2*nD]*mult_b, buf[2*nD]);
YtoRGB1555ToChar(Y,buf+nPos*nD,buf+nPos*nD+1,nColor);
nPos=3;
Y = (unsigned char)MUX(font&0x0010, lumi*mult_f+buf[3*nD]*mult_b, buf[3*nD]);
YtoRGB1555ToChar(Y,buf+nPos*nD,buf+nPos*nD+1,nColor);
nPos=4;
Y = (unsigned char)MUX(font&0x0008, lumi*mult_f+buf[4*nD]*mult_b, buf[4*nD]);
YtoRGB1555ToChar(Y,buf+nPos*nD,buf+nPos*nD+1,nColor);
nPos=5;
Y = (unsigned char)MUX(font&0x0004, lumi*mult_f+buf[5*nD]*mult_b,buf[5*nD]);
YtoRGB1555ToChar(Y,buf+nPos*nD,buf+nPos*nD+1,nColor);
nPos=6;
Y = (unsigned char)MUX(font&0x0002, lumi*mult_f+buf[6*nD]*mult_b,buf[6*nD]);
YtoRGB1555ToChar(Y,buf+nPos*nD,buf+nPos*nD+1,nColor);
nPos=7;
Y = (unsigned char)MUX(font&0x0001, lumi*mult_f+buf[7*nD]*mult_b,buf[7*nD]);
YtoRGB1555ToChar(Y,buf+nPos*nD,buf+nPos*nD+1,nColor);
nPos=8;
Y = (unsigned char)MUX(font&0x8000, lumi*mult_f+buf[8*nD]*mult_b,buf[8*nD]);
YtoRGB1555ToChar(Y,buf+nPos*nD,buf+nPos*nD+1,nColor);
nPos=9;
Y = (unsigned char)MUX(font&0x4000, lumi*mult_f+buf[9*nD]*mult_b,buf[9*nD]);
YtoRGB1555ToChar(Y,buf+nPos*nD,buf+nPos*nD+1,nColor);
nPos=10;
Y = (unsigned char)MUX(font&0x2000, lumi*mult_f+buf[10*nD]*mult_b, buf[10*nD]);
YtoRGB1555ToChar(Y,buf+nPos*nD,buf+nPos*nD+1,nColor);
nPos=11;
Y = (unsigned char)MUX(font&0x1000, lumi*mult_f+buf[11*nD]*mult_b, buf[11*nD]);
YtoRGB1555ToChar(Y,buf+nPos*nD,buf+nPos*nD+1,nColor);
nPos=12;
Y = (unsigned char)MUX(font&0x0800, lumi*mult_f+buf[12*nD]*mult_b, buf[12*nD]);
YtoRGB1555ToChar(Y,buf+nPos*nD,buf+nPos*nD+1,nColor);
nPos=13;
Y = (unsigned char)MUX(font&0x0400, lumi*mult_f+buf[13*nD]*mult_b, buf[13*nD]);
YtoRGB1555ToChar(Y,buf+nPos*nD,buf+nPos*nD+1,nColor);
nPos=14;
Y = (unsigned char)MUX(font&0x0200, lumi*mult_f+buf[14*nD]*mult_b, buf[14*nD]);
YtoRGB1555ToChar(Y,buf+nPos*nD,buf+nPos*nD+1,nColor);
nPos=15;
Y = (unsigned char)MUX(font&0x0100, lumi*mult_f+buf[15*nD]*mult_b, buf[15*nD]);
YtoRGB1555ToChar(Y,buf+nPos*nD,buf+nPos*nD+1,nColor);
buf += stride*2;
}
}
int ShowOSD_DEC_BOX_MX(unsigned char *pBase, char *pStr, unsigned short x, unsigned short y,int width, int height,int nColor)
{
if(!pBase||!pStr||width<1||height<1||x>width||y>=height)
return 0;
UInt32 nChar=0,wd=0,nOffset=0,nSize, l, r;
Int8 q=3;
Int8 w;
Int8 *p=(char *)pStr;
UInt8 *pHZLib=0;
UInt8 *pp = (unsigned char *)p;
pBase += width*2*y+x*2;
while (*p) {
pp = (unsigned char *)p;
q = *p&0x80?(*p++)-161:2; // Get qu code
w=((*p++)&0x7f)-33; // Get wei code
if ((int)(nOffset = q*94+w) >= g_real_HZ16_count)
continue;
pHZLib = (HZ16Lib+(nOffset<<5));
if (q<10) {
l = UBYTESEL(HZ16_Space[nOffset],1);
r = UBYTESEL(HZ16_Space[nOffset],0);
nSize = HZLIB_ZISE-(l+r);
}
else {
nSize = HZLIB_ZISE;
l = r = 0;
}
if ((int)(x+wd+nSize)>width)
break;
DrawOSD(pBase+(wd+nChar)*2,(unsigned short *)pHZLib,width,nColor);
nChar++;
wd += 14;//12 自体间距
}
return nChar;
}
static int OSD_MENU_Init()
{
int colordata=15;
char colorbuf[1]={0};
int nWndWidth = WIDTH_720;
int nWndHeight = HEIGHT_576;
sprintf(colorbuf,"%d",colordata);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"SYSTEM",150,64,nWndWidth,nWndHeight,0);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"COLOR",128,96,nWndWidth,nWndHeight,0);ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,colorbuf,240,96,nWndWidth,nWndHeight,0);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"DNR",128,128,nWndWidth,nWndHeight,0);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"DIS",128,160,nWndWidth,nWndHeight,0);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"*DEFOG",112,192,nWndWidth,nWndHeight,2);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"picture",128,224,nWndWidth,nWndHeight,0);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"ZOOM",128,256,nWndWidth,nWndHeight,0);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"VIDEO",128,288,nWndWidth,nWndHeight,0);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"WBMODEL",128,320,nWndWidth,nWndHeight,0);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"RETURN",128,352,nWndWidth,nWndHeight,0);
return 0;
}
static int OSD_MENU_update()
{
int nWndWidth = WIDTH_720;
int nWndHeight = HEIGHT_576;
HI_S32 s32Ret = HI_SUCCESS;
sprintf(colorbuf,"%d",colordata);
sprintf(dnrbuf,"%d",dnrdata);
if (ioctl(osdfb, FBIOPUT_SCREEN_ORIGIN_HIFB, &stPoint) < 0)
{
SAMPLE_PRT("set screen original show position failed!\n");
close(osdfb);
return HI_NULL;
}
memset(pOSDRGB,0x0,SAMPLE_IMAGE_WIDTH * SAMPLE_IMAGE_HEIGHT * 2);
memset(pBuf,0x0,maxW*maxH*2);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"SYSTEM",150,64,nWndWidth,nWndHeight,0);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"COLOR",128,96,nWndWidth,nWndHeight,0);ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,colorbuf,240,96,nWndWidth,nWndHeight,0);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"DNR",128,128,nWndWidth,nWndHeight,2);ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,dnrbuf,240,128,nWndWidth,nWndHeight,2);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"DIS",128,160,nWndWidth,nWndHeight,0);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"DEFOG",128,192,nWndWidth,nWndHeight,0);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"picture",128,224,nWndWidth,nWndHeight,0);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"ZOOM",128,256,nWndWidth,nWndHeight,0);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"VIDEO",128,288,nWndWidth,nWndHeight,0);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"WBMODEL",128,320,nWndWidth,nWndHeight,0);
ShowOSD_DEC_BOX_MX((unsigned char *)pOSDRGB,"RETURN",128,352,nWndWidth,nWndHeight,0);
/*copy memeroy*/
memcpy(pBuf,pOSDRGB,maxW*maxH*2);
//stCanvasBuf.UpdateRect.x = 180;
//stCanvasBuf.UpdateRect.y = 180;
stCanvasBuf.UpdateRect.x = 0;
stCanvasBuf.UpdateRect.y = 0;
stCanvasBuf.UpdateRect.w = maxW;
stCanvasBuf.UpdateRect.h = maxH;
s32Ret = ioctl(osdfb, FBIO_REFRESH, &stCanvasBuf);
if (s32Ret < 0)
{
SAMPLE_PRT("REFRESH failed!\n");
HI_MPI_SYS_MmzFree(Phyaddr, pOSDRGB);
HI_MPI_SYS_MmzFree(stCanvasBuf.stCanvas.u32PhyAddr, pBuf);
close(osdfb);
return HI_NULL;
}
// printf("Enter any key to exit\n");
// getchar();
// HI_MPI_SYS_MmzFree(Phyaddr, pOSDRGB);
// HI_MPI_SYS_MmzFree(stCanvasBuf.stCanvas.u32PhyAddr, pBuf);
// close(fd);
return 0;
}
HI_S32 OSD_MENU_HIFB_init()
{
HI_S32 s32Ret = HI_SUCCESS;
HIFB_LAYER_INFO_S stLayerInfo = {0};
HI_U8* pDst = NULL;
//HI_U32 x;
//HI_U32 y;
//HI_U32 i;
HI_CHAR image_name[128];
HI_BOOL bShow;
struct fb_var_screeninfo stVarInfo;
HI_CHAR file[12] = "/dev/fb0";
int fd;
HIFB_COLORKEY_S stColorKey;
TDE2_RECT_S stSrcRect, stDstRect;
TDE2_SURFACE_S stSrc, stDst;
TDE_HANDLE s32Handle;
fd = open("/dev/fb0", O_RDWR, 0);
osdfb = fd;
if (fd < 0)
{
SAMPLE_PRT("open %s failed!\n", file);
return HI_NULL;
}
/*all layer surport colorkey*/
stColorKey.bKeyEnable = HI_TRUE;
stColorKey.u32Key = 0x0;
if (ioctl(fd, FBIOPUT_COLORKEY_HIFB, &stColorKey) < 0)
{
SAMPLE_PRT("FBIOPUT_COLORKEY_HIFB!\n");
close(fd);
return HI_NULL;
}
s32Ret = ioctl(fd, FBIOGET_VSCREENINFO, &stVarInfo);
if (s32Ret < 0)
{
SAMPLE_PRT("GET_VSCREENINFO failed!\n");
close(fd);
return HI_NULL;
}
if (ioctl(fd, FBIOPUT_SCREEN_ORIGIN_HIFB, &stPoint) < 0)
{
SAMPLE_PRT("set screen original show position failed!\n");
close(fd);
return HI_NULL;
}
maxW = WIDTH_720;
maxH = HEIGHT_576;
stVarInfo.transp = s_a16;
stVarInfo.red = s_r16;
stVarInfo.green = s_g16;
stVarInfo.blue = s_b16;
stVarInfo.bits_per_pixel = 16;
stVarInfo.activate = FB_ACTIVATE_NOW;
stVarInfo.xres = stVarInfo.xres_virtual = maxW;
stVarInfo.yres = stVarInfo.yres_virtual = maxH;
s32Ret = ioctl(fd, FBIOPUT_VSCREENINFO, &stVarInfo);
if (s32Ret < 0)
{
SAMPLE_PRT("PUT_VSCREENINFO failed!\n");
close(fd);
return HI_NULL;
}
stLayerInfo.BufMode = HIFB_LAYER_BUF_NONE;
stLayerInfo.u32Mask = HIFB_LAYERMASK_BUFMODE;
s32Ret = ioctl(fd, FBIOPUT_LAYER_INFO, &stLayerInfo);
if (s32Ret < 0)
{
SAMPLE_PRT("PUT_LAYER_INFO failed!\n");
close(fd);
return HI_NULL;
}
// bShow = HI_TRUE;
bShow = HI_FALSE;
if (ioctl(fd, FBIOPUT_SHOW_HIFB, &bShow) < 0)
{
SAMPLE_PRT("FBIOPUT_SHOW_HIFB failed!\n");
close(fd);
return HI_NULL;
}
if (HI_FAILURE == HI_MPI_SYS_MmzAlloc(&(stCanvasBuf.stCanvas.u32PhyAddr), ((void**)&pBuf),
NULL, NULL, maxW * maxH * 2))
{
SAMPLE_PRT("allocate memory (maxW*maxH*2 bytes) failed\n");
close(fd);
return HI_NULL;
}
stCanvasBuf.stCanvas.u32Height = maxH;
stCanvasBuf.stCanvas.u32Width = maxW;
stCanvasBuf.stCanvas.u32Pitch = maxW * 2;
stCanvasBuf.stCanvas.enFmt = HIFB_FMT_ARGB1555;
memset(pBuf, 0x00, stCanvasBuf.stCanvas.u32Pitch * stCanvasBuf.stCanvas.u32Height);
/*change bmp*/
if (HI_FAILURE == HI_MPI_SYS_MmzAlloc(&Phyaddr, ((void**)&pOSDRGB),
NULL, NULL, SAMPLE_IMAGE_WIDTH * SAMPLE_IMAGE_HEIGHT * 2))
{
SAMPLE_PRT("allocate memory failed\n");
HI_MPI_SYS_MmzFree(stCanvasBuf.stCanvas.u32PhyAddr, pBuf);
close(fd);
return HI_NULL;
}
if(NULL != pOSDRGB){
memset(pOSDRGB,0x0,SAMPLE_IMAGE_WIDTH * SAMPLE_IMAGE_HEIGHT * 2);
}
return 0;
}
HI_S32 OSD_MENU_HIFB_Refresh()
{
HI_S32 s32Ret = HI_SUCCESS;
/*init osd menu*/
OSD_MENU_Init();
/*copy memeroy*/
memcpy(pBuf,pOSDRGB,maxW*maxH*2);
//stCanvasBuf.UpdateRect.x = 180;
//stCanvasBuf.UpdateRect.y = 180;
stCanvasBuf.UpdateRect.x = 0;
stCanvasBuf.UpdateRect.y = 0;
stCanvasBuf.UpdateRect.w = maxW;
stCanvasBuf.UpdateRect.h = maxH;
s32Ret = ioctl(osdfb, FBIO_REFRESH, &stCanvasBuf);
if (s32Ret < 0)
{
SAMPLE_PRT("REFRESH failed!\n");
HI_MPI_SYS_MmzFree(Phyaddr, pOSDRGB);
HI_MPI_SYS_MmzFree(stCanvasBuf.stCanvas.u32PhyAddr, pBuf);
close(osdfb);
return HI_NULL;
}
// printf("Enter any key to exit\n");
// getchar();
// HI_MPI_SYS_MmzFree(Phyaddr, pOSDRGB);
// HI_MPI_SYS_MmzFree(stCanvasBuf.stCanvas.u32PhyAddr, pBuf);
// close(fd);
return 0;;
}
/**********************************************
*
* Name: OSD_MENU_HandleSig
* Description: ctrl + c / z
* Param:
* Return:
*
*********************************************/
HI_VOID OSD_MENU_HandleSig(HI_S32 signo)
{
if (SIGINT == signo || SIGTERM == signo)
{
//HI_MPI_SYS_MmzFree(Phyaddr, pOSDRGB);
//HI_MPI_SYS_MmzFree(stCanvasBuf.stCanvas.u32PhyAddr, pBuf);
//close(fd);
printf("\033[0;31mprogram exit abnormally!\033[0;39m\n");
}
exit(0);
}
下面是串口处理程序
void uartservice(void)
{
HI_BOOL bShow;
if(Recvdatas[0]==0x5a&&Recvdatas[1]==0x00&&Recvdatas[2]==0x00&&Recvdatas[3]==0x5b)//menu
{
menuflag++;
printf("menu\n");
dnrdata++;
if(menuflag)
{
bShow = HI_TRUE;//display menu
OSD_MENU_update();
}
// else
// {
// menuflag=0;
// bShow = HI_FALSE; //undisplay menu
// }
if (ioctl(osdfb, FBIOPUT_SHOW_HIFB, &bShow) < 0)//control menu display or undisplay
{
SAMPLE_PRT("FBIOPUT_SHOW_HIFB failed!\n");
close(osdfb);
return HI_NULL;
}
}
if(Recvdatas[0]==0x5a&&Recvdatas[1]==0x00&&Recvdatas[2]==0x01&&Recvdatas[3]==0x5b)//up
{
printf("up\n");
}
if(Recvdatas[0]==0x5a&&Recvdatas[1]==0x00&&Recvdatas[2]==0x02&&Recvdatas[3]==0x5b)//down
{
printf("down\n");
}
if(Recvdatas[0]==0x5a&&Recvdatas[1]==0x00&&Recvdatas[2]==0x03&&Recvdatas[3]==0x5b)//left
{
printf("left\n");
}
if(Recvdatas[0]==0x5a&&Recvdatas[1]==0x00&&Recvdatas[2]==0x04&&Recvdatas[3]==0x5b)//rignt
{
printf("left\n");
}
}
我来回答
回答8个
时间排序
认可量排序
认可0
认可0
认可0
认可0
认可0
认可0
认可0
认可0
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币
Markdown 语法
- 加粗**内容**
- 斜体*内容*
- 删除线~~内容~~
- 引用> 引用内容
- 代码`代码`
- 代码块```编程语言↵代码```
- 链接[链接标题](url)
- 无序列表- 内容
- 有序列表1. 内容
- 缩进内容
- 图片![alt](url)
相关问答
-
2019-04-04 16:12:55
-
2012-11-24 17:00:00
-
2017-08-13 16:27:24
-
2018-12-14 10:18:10
-
02019-03-18 20:45:34
-
2018-06-21 17:18:58
-
2023-02-08 12:02:39
-
2018-10-24 22:07:28
-
2018-11-24 23:25:01
-
2018-12-12 15:04:03
-
2019-01-03 14:37:10
-
2017-08-24 19:25:54
-
2018-05-09 11:07:22
-
2017-07-20 11:07:35
-
2019-01-07 14:56:45
-
2016-12-16 11:33:50
-
2019-01-15 15:49:34
-
2017-05-08 09:36:35
-
2019-06-04 11:26:12
无更多相似问答 去提问
点击登录
-- 积分
-- E币
提问
—
收益
—
被采纳
—
我要提问
切换马甲
上一页
下一页
悬赏问答
-
5Hi3516CV610 如何使用SD卡升级固件
-
5cat /dev/logmpp 报错 <3>[ vi] [func]:vi_send_frame_node [line]:99 [info]:vi pic queue is full!
-
50如何获取vpss chn的图像修改后发送至vo
-
5FPGA通过Bt1120传YUV422数据过来,vi接收不到数据——3516dv500
-
50SS928 运行PQtools 拼接 推到设备里有一半画面会异常
-
53536AV100的sample_vdec输出到CVBS显示
-
10海思板子mpp怎么在vi阶段改变视频数据尺寸
-
10HI3559AV100 多摄像头同步模式
-
9海思ss928单路摄像头vio中加入opencv处理并显示
-
10EB-RV1126-BC-191板子运行自己编码的程序
举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
提醒
你的问题还没有最佳答案,是否结题,结题后将扣除20%的悬赏金
取消
确认
提醒
你的问题还没有最佳答案,是否结题,结题后将根据回答情况扣除相应悬赏金(1回答=1E币)
取消
确认