mirror of
https://github.com/opentx/opentx.git
synced 2025-07-15 12:25:12 +03:00
[Horus] Bitmaps dynamic load
This commit is contained in:
parent
63713578fe
commit
358badfed9
12 changed files with 117 additions and 99 deletions
|
@ -352,11 +352,20 @@ static int luaLcdDrawPixmap(lua_State *L)
|
|||
int x = luaL_checkinteger(L, 1);
|
||||
int y = luaL_checkinteger(L, 2);
|
||||
const char * filename = luaL_checkstring(L, 3);
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
uint8_t bitmap[BITMAP_BUFFER_SIZE(LCD_W/2, LCD_H)]; // width max is LCD_W/2 pixels for saving stack and avoid a malloc here
|
||||
const pm_char * error = bmpLoad(bitmap, filename, LCD_W/2, LCD_H);
|
||||
if (!error) {
|
||||
if (bmpLoad(bitmap, filename, LCD_W/2, LCD_H)) {
|
||||
lcdDrawBitmap(x, y, bitmap);
|
||||
}
|
||||
#else
|
||||
uint8_t * bitmap = bmpLoad(filename);
|
||||
if (bitmap) {
|
||||
lcdDrawBitmap(x, y, bitmap);
|
||||
free(bitmap);
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -905,10 +905,8 @@ void luaLoadThemeCallback()
|
|||
char path[LUA_FULLPATH_MAXLEN+1];
|
||||
strcpy(path, THEMES_PATH "/");
|
||||
strcpy(path+sizeof(THEMES_PATH), bitmap);
|
||||
uint8_t * bitmapData = (uint8_t *)malloc(BITMAP_BUFFER_SIZE(51, 31));
|
||||
TRACE("path=%s bitmapData=%p %d %p", path, bitmapData, BITMAP_BUFFER_SIZE(51, 31), path);
|
||||
bmpLoad(bitmapData, path, 51, 31);
|
||||
LuaTheme * theme = new LuaTheme(name, bitmapData, themeOptions);
|
||||
uint8_t * bitmap = bmpLoad(path/*, 51, 31*/); // TODO rescale
|
||||
LuaTheme * theme = new LuaTheme(name, bitmap, themeOptions);
|
||||
theme->loadFunction = loadFunction;
|
||||
theme->drawBackgroundFunction = drawBackgroundFunction;
|
||||
theme->drawTopbarBackgroundFunction = drawTopbarBackgroundFunction;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue