Update LVGL (master 9.2+) and related libraries (#130)
- LVGL 9.2+ (master commit) - esp_lvgl_port (master with my PR hotfix changes) - espressif/esp_lcd_touch_gt911 1.1.1~2
This commit is contained in:
committed by
GitHub
parent
e4b8519f67
commit
80b69b7f45
@@ -1,12 +1,11 @@
|
||||
#include "lv_screenshot.h"
|
||||
|
||||
#include "save_bmp.h"
|
||||
#include "save_png.h"
|
||||
|
||||
static void data_pre_processing(lv_image_dsc_t* snapshot, uint16_t bpp, lv_100ask_screenshot_sv_t screenshot_sv);
|
||||
static void data_pre_processing(lv_draw_buf_t* snapshot, uint16_t bpp, lv_100ask_screenshot_sv_t screenshot_sv);
|
||||
|
||||
bool lv_screenshot_create(lv_obj_t* obj, lv_color_format_t cf, lv_100ask_screenshot_sv_t screenshot_sv, const char* filename) {
|
||||
lv_image_dsc_t* snapshot = lv_snapshot_take(obj, cf);
|
||||
lv_draw_buf_t* snapshot = lv_snapshot_take(obj, cf);
|
||||
|
||||
if (snapshot) {
|
||||
data_pre_processing(snapshot, LV_COLOR_DEPTH, screenshot_sv);
|
||||
@@ -17,22 +16,16 @@ bool lv_screenshot_create(lv_obj_t* obj, lv_color_format_t cf, lv_100ask_screens
|
||||
} else if (LV_COLOR_DEPTH == 32) {
|
||||
lv_screenshot_save_png_file(snapshot->data, snapshot->header.w, snapshot->header.h, 32, filename);
|
||||
}
|
||||
} else if (screenshot_sv == LV_100ASK_SCREENSHOT_SV_BMP) {
|
||||
if (LV_COLOR_DEPTH == 16) {
|
||||
lve_screenshot_save_bmp_file(snapshot->data, snapshot->header.w, snapshot->header.h, 24, filename);
|
||||
} else if (LV_COLOR_DEPTH == 32) {
|
||||
lve_screenshot_save_bmp_file(snapshot->data, snapshot->header.w, snapshot->header.h, 32, filename);
|
||||
}
|
||||
}
|
||||
|
||||
lv_snapshot_free(snapshot);
|
||||
lv_draw_buf_destroy(snapshot);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void data_pre_processing(lv_image_dsc_t* snapshot, uint16_t bpp, lv_100ask_screenshot_sv_t screenshot_sv) {
|
||||
static void data_pre_processing(lv_draw_buf_t* snapshot, uint16_t bpp, lv_100ask_screenshot_sv_t screenshot_sv) {
|
||||
if (bpp == 16) {
|
||||
uint16_t rgb565_data = 0;
|
||||
uint32_t count = 0;
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
#include "save_bmp.h"
|
||||
|
||||
typedef struct tagBITMAPFILEHEADER {
|
||||
uint16_t bfType;
|
||||
uint32_t bfSize;
|
||||
uint16_t bfReserved1;
|
||||
uint16_t bfReserved2;
|
||||
uint32_t bfOffBits;
|
||||
} __attribute__((packed)) BITMAPFILEHEADER, *PBITMAPFILEHEADER;
|
||||
|
||||
typedef struct tagBITMAPINFOHEADER {
|
||||
uint32_t biSize;
|
||||
uint32_t biwidth;
|
||||
uint32_t biheight;
|
||||
uint16_t biPlanes;
|
||||
uint16_t biBitCount;
|
||||
uint32_t biCompression;
|
||||
uint32_t biSizeImage;
|
||||
uint32_t biXPelsPerMeter;
|
||||
uint32_t biYPelsPerMeter;
|
||||
uint32_t biClrUsed;
|
||||
uint32_t biClrImportant;
|
||||
} __attribute__((packed)) BITMAPINFOHEADER, *PBITMAPINFOHEADER;
|
||||
|
||||
typedef struct tagRGBQUAD {
|
||||
uint8_t rgbBlue;
|
||||
uint8_t rgbGreen;
|
||||
uint8_t rgbRed;
|
||||
uint8_t rgbReserved;
|
||||
} __attribute__((packed)) RGBQUAD;
|
||||
|
||||
bool lve_screenshot_save_bmp_file(const uint8_t* image, uint32_t w, uint32_t h, uint32_t bpp, const char* filename) {
|
||||
BITMAPFILEHEADER tBmpFileHead;
|
||||
BITMAPINFOHEADER tBmpInfoHead;
|
||||
|
||||
uint32_t dwSize;
|
||||
|
||||
uint32_t bw;
|
||||
lv_fs_file_t f;
|
||||
|
||||
memset(&tBmpFileHead, 0, sizeof(BITMAPFILEHEADER));
|
||||
memset(&tBmpInfoHead, 0, sizeof(BITMAPINFOHEADER));
|
||||
|
||||
lv_fs_res_t res = lv_fs_open(&f, filename, LV_FS_MODE_WR);
|
||||
if (res != LV_FS_RES_OK) {
|
||||
LV_LOG_USER("Can't create output file %s", filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
tBmpFileHead.bfType = 0x4d42;
|
||||
tBmpFileHead.bfSize = 0x36 + w * h * (bpp / 8);
|
||||
tBmpFileHead.bfOffBits = 0x00000036;
|
||||
|
||||
tBmpInfoHead.biSize = 0x00000028;
|
||||
tBmpInfoHead.biwidth = w;
|
||||
tBmpInfoHead.biheight = h;
|
||||
tBmpInfoHead.biPlanes = 0x0001;
|
||||
tBmpInfoHead.biBitCount = bpp;
|
||||
tBmpInfoHead.biCompression = 0;
|
||||
tBmpInfoHead.biSizeImage = w * h * (bpp / 8);
|
||||
tBmpInfoHead.biXPelsPerMeter = 0;
|
||||
tBmpInfoHead.biYPelsPerMeter = 0;
|
||||
tBmpInfoHead.biClrUsed = 0;
|
||||
tBmpInfoHead.biClrImportant = 0;
|
||||
|
||||
res = lv_fs_write(&f, &tBmpFileHead, sizeof(tBmpFileHead), &bw);
|
||||
if (bw != sizeof(tBmpFileHead)) {
|
||||
LV_LOG_USER("Can't write BMP File Head to %s", filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
res = lv_fs_write(&f, &tBmpInfoHead, sizeof(tBmpInfoHead), &bw);
|
||||
if (bw != sizeof(tBmpInfoHead)) {
|
||||
LV_LOG_USER("Can't write BMP File Info Head to %s", filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
dwSize = w * bpp / 8;
|
||||
const uint8_t* pPos = image + (h - 1) * dwSize;
|
||||
|
||||
while (pPos >= image) {
|
||||
res = lv_fs_write(&f, pPos, dwSize, &bw);
|
||||
if (bw != dwSize) {
|
||||
LV_LOG_USER("Can't write date to BMP File %s", filename);
|
||||
return false;
|
||||
}
|
||||
pPos -= dwSize;
|
||||
}
|
||||
|
||||
lv_fs_close(&f);
|
||||
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user