From a00e406907321be802ce4e60e60fb022b7238db8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?William=20B=C3=A9rub=C3=A9?= Date: Tue, 9 Apr 2024 11:11:36 -0400 Subject: [PATCH] Bitmap region creation is working, biCompression == BI_BITFIELDS to be added for those with transparency --- osd/bitmap.c | 2 +- osd/main.c | 10 +++++++++- osd/region.c | 20 +++----------------- osd/region.h | 3 ++- 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/osd/bitmap.c b/osd/bitmap.c index feef9c0..c4dbb08 100644 --- a/osd/bitmap.c +++ b/osd/bitmap.c @@ -205,7 +205,7 @@ int load_bitmapex(const char *filename, OSD_LOGO_T *pVideoLogo, OSD_COLOR_FMT_E if (!(pFile = fopen(filename, "rb"))) { - fprintf(stderr, "Open file faild:%s!\n", filename); + fprintf(stderr, "Open file failed:%s!\n", filename); return -1; } diff --git a/osd/main.c b/osd/main.c index 951614d..9b41f0d 100644 --- a/osd/main.c +++ b/osd/main.c @@ -150,7 +150,15 @@ void overlays() char img[32]; sprintf(img, "/tmp/osd%d.bmp", id); if (!access(img, F_OK)) - load_region(id, PIXEL_FORMAT_1555); + { + BITMAP bitmap; + if (!(prepare_bitmap(img, &bitmap, 0, 0, PIXEL_FORMAT_1555))) + { + create_region(id, osds[id].posx, osds[id].posy, bitmap.u32Width, bitmap.u32Height); + set_bitmap(id, &bitmap); + free(bitmap.pData); + } + } else unload_region(id); osds[id].updt = 0; diff --git a/osd/region.c b/osd/region.c index 6b52d3d..8da8092 100644 --- a/osd/region.c +++ b/osd/region.c @@ -209,7 +209,7 @@ int prepare_bitmap(const char *filename, BITMAP *bitmap, int bFil, unsigned int if (!(bitmap->pData = malloc(s32BytesPerPix * bmpInfo.bmiHeader.biWidth * bmpInfo.bmiHeader.biHeight))) { - fprintf(stderr, "malloc osd memory err!\n"); + fputs("malloc osd memory err!\n", stderr); return -1; } @@ -227,9 +227,9 @@ int prepare_bitmap(const char *filename, BITMAP *bitmap, int bFil, unsigned int { s32Width = DIV_UP(bmpInfo.bmiHeader.biWidth, 4); pu8Data = malloc(s32Width * bmpInfo.bmiHeader.biHeight); - if (NULL == pu8Data) + if (!pu8Data) { - fprintf(stderr, "malloc osd memory err!\n"); + fputs("malloc osd memory err!\n", stderr); return -1; } } @@ -308,20 +308,6 @@ int set_bitmap(unsigned int handle, BITMAP *bitmap) return s32Ret; } -int load_region(unsigned int handle, int enPixelFmt) -{ - BITMAP bitmap; - int s32Ret; - char path[32]; - sprintf(path, "/tmp/osd%d.bmp", handle); - if (!(s32Ret = prepare_bitmap(path, &bitmap, 0, 0, enPixelFmt))) - { - s32Ret = set_bitmap(handle, &bitmap); - free(bitmap.pData); - } - return s32Ret; -} - void unload_region(unsigned int handle) { #ifdef __SIGMASTAR__ diff --git a/osd/region.h b/osd/region.h index 35e2b66..db40515 100644 --- a/osd/region.h +++ b/osd/region.h @@ -12,7 +12,8 @@ extern "C" #include "bitmap.h" int create_region(int handle, int x, int y, int width, int height); - int load_region(unsigned int handle, int enPixelFmt); + int prepare_bitmap(const char *filename, BITMAP *bitmap, int bFil, unsigned int u16FilColor, int enPixelFmt); + int set_bitmap(unsigned int handle, BITMAP *bitmap); void unload_region(unsigned int handle); #ifdef __cplusplus