osd_end.c

来自「sample on embedded linux」· C语言 代码 · 共 91 行

C
91
字号
#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 + =
减小字号Ctrl + -
显示快捷键?