Skip to content

Commit

Permalink
Bitmap region creation is working, biCompression == BI_BITFIELDS to b…
Browse files Browse the repository at this point in the history
…e added for those with transparency
  • Loading branch information
wberube committed Apr 9, 2024
1 parent 28b5549 commit a00e406
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
2 changes: 1 addition & 1 deletion osd/bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
10 changes: 9 additions & 1 deletion osd/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 3 additions & 17 deletions osd/region.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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__
Expand Down
3 changes: 2 additions & 1 deletion osd/region.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a00e406

Please sign in to comment.