⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 osd_end.c

📁 sample on embedded linux
💻 C
字号:
#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <time.h>#include <hi_common_api.h>HI_S32 OSDEndService(void){    HI_S32 ret;    OSD_REGION_HANDLE region;    OSD_BITMAP_S Bitmap;    char * pdata;    int i = 0;    OSD_REGION_S RegionParam =     {        .struValidRect = {100, 20, 50, 90},        .u32Alpha = 10,        .u32TransparentColor = 0x000000,        .u32TopLevel = 0,    };   /*create region*/    if((ret = HI_OSD_CreateRegion(OSD_END, 0, &RegionParam, &region)) < 0)    {        return ret;    }    Bitmap.u32Width = 50;    Bitmap.u32Height = 90;    Bitmap.enPixelFormat = PIXEL_FORMAT_RGB_888;    Bitmap.pData = (void *)malloc(Bitmap.u32Width * Bitmap.u32Height * 3);      if(NULL == Bitmap.pData)    {        printf("Bitmap.pData malloc err!\n");        HI_OSD_DeleteRegion(region);        return HI_FAILURE;    }    pdata = (char *)Bitmap.pData;    /*top of the region is red*/    for(i = 0; i < Bitmap.u32Width*Bitmap.u32Height; i += 3)    {        *pdata++ = 0xff;        *pdata++ = 0x00;        *pdata++ = 0x00;    }    /*middle of the region is green*/    for(;i < Bitmap.u32Width*Bitmap.u32Height*2; i += 3)    {        *pdata++ = 0x00;        *pdata++ = 0xff;        *pdata++ = 0x00;    }    /*bottom of the region is blue*/    for(; i < Bitmap.u32Width*Bitmap.u32Height*3; i += 3)    {        *pdata++ = 0x00;        *pdata++ = 0x00;        *pdata++ = 0xff;    }    /*fill the rigon with the bitmap*/    if((ret = HI_OSD_PutBitmapToRegion(region, &Bitmap, 0, 0)) < 0)    {        free(Bitmap.pData);        HI_OSD_DeleteRegion(region);        return ret;    }    free(Bitmap.pData);    /*set transparence*/    for(i = 10; i <= 100; i += 10 )    {        HI_OSD_SetRegionAlpha(region, i);        /*stop 1 second to make all the effect much better*/        sleep(1);    }        /*delete the region*/        HI_OSD_DeleteRegion(region);      return HI_SUCCESS;}int main(){    OSDEndService();    return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -