Dana
2025-12-01 dd7c75d0d989835c1437e0cfa071408a23d993cd
usbcameralib/src/main/cpp/watermark.cpp
File was renamed from usbcameralib/src/main/cpp/watermark.c
@@ -12,6 +12,7 @@
#include "watermark.h"
#include "charencode.h"
#include "ImageProc.h"
#include "apptimer.h"
//static pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
typedef enum {
@@ -33,6 +34,22 @@
static int pic_width = 0, pic_height = 0;
static color_t wm_color;
static void PrintTime(apptimer_var_t val)
{
    text_t text;
    text.x = 10;
    text.y = 10;
    memset(text.text, 0, sizeof (text.text));
    strcpy(text.text, FormatTime().c_str());
    PrepareWatermark(RED, 24, 2, 1, &text);
    AppTimer_add(PrintTime, D_SEC(1));
}
void InitWatermark(const char *font, int width, int height)
{
    LOGI("InitWatermark");
@@ -48,6 +65,8 @@
    pic_width = width;
    pic_height = height;
    AppTimer_add(PrintTime, D_SEC(1));
}
void UninitWatermark(void)
@@ -58,6 +77,7 @@
        wm = NULL;
    }
    wm_num = 0;
    AppTimer_delete(PrintTime);
}
void PrepareWatermark(int color, int font_size, int multiple, int num, const text_t *texts)
@@ -75,7 +95,7 @@
    const int bytes_per_line = font_size / 8;
    wm_num = 0;
    wm_color = color;
    wm_color = static_cast<color_t>(color);
    //FILE *fp = fopen("/storage/self/primary/ms_unicode.bin", "rb");
    //FILE *fp = fopen("/system/ms_unicode.bin", "rb");
@@ -86,14 +106,14 @@
        uint8_t zm[64*64/8];        // 最大
        for (int m = 0; m < num; ++m) {
            char *str = texts[m].text;
            const char *str = texts[m].text;
            int screen_x = texts[m].x;
            int screen_y = texts[m].y;
            offset = 0;
            while (str != NULL && offset < strlen(str)) {
                int skip = enc_utf8_to_unicode_one(str + offset, &unicode);
                int skip = enc_utf8_to_unicode_one(reinterpret_cast<const unsigned char *>(str + offset), &unicode);
                int next_x = 0;
                if (skip == 0) {