20250808 C++ 不使用三方库,在 RGB 图像上打印信息

先看效果

在这里插入图片描述

直接上代码

// *********************************************
// FileName: text_overlay.hpp
// Brief:
//
// Date:   8 Aug. 2025
// Author: ...
// *********************************************#ifndef TEXT_OVERLAY_HPP
#define TEXT_OVERLAY_HPP#include <cstdint>
#include <algorithm>
#include <cstdio>
#include <cstring>namespace OVERLAY {
enum class PixFmt { YUV_NV12, RGB24 };/* ---------- 1. 8×8 字模表(ASCII) ---------- */
// https://github.com/dhepper/font8x8
const uint8_t font8x8_ib8x8u[224][8] = {// ---------------------------  0-127 ---------------------------{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},  // 0000 (uni0000.dup1){0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e},  // 0001 (uni0001){0x7e, 0xff, 0xdb, 0xff, 0xc3, 0xe7, 0xff, 0x7e},  // 0002 (uni0002){0x6c, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00},  // 0003 (uni0003){0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00},  // 0004 (uni0004){0x38, 0x7c, 0x38, 0xfe, 0xfe, 0x7c, 0x38, 0x7c},  // 0005 (uni0005){0x10, 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x7c},  // 0006 (uni0006){0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00},  // 0007 (uni0007){0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff},  // 0008 (uni0008){0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00},  // 0009 (uni0009){0xff, 0xc3, 0x99, 0xbd, 0xbd, 0x99, 0xc3, 0xff},  // 000a (uni000A){0x0f, 0x07, 0x0f, 0x7d, 0xcc, 0xcc, 0xcc, 0x78},  // 000b (uni000B){0x3c, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18},  // 000c (uni000C){0x3f, 0x33, 0x3f, 0x30, 0x30, 0x70, 0xf0, 0xe0},  // 000d (uni000D){0x7f, 0x63, 0x7f, 0x63, 0x63, 0x67, 0xe6, 0xc0},  // 000e (uni000E){0x99, 0x5a, 0x3c, 0xe7, 0xe7, 0x3c, 0x5a, 0x99},  // 000f (uni000F){0x80, 0xe0, 0xf8, 0xfe, 0xf8, 0xe0, 0x80, 0x00},  // 0010 (uni0010){0x02, 0x0e, 0x3e, 0xfe, 0x3e, 0x0e, 0x02, 0x00},  // 0011 (uni0011){0x18, 0x3c, 0x7e, 0x18, 0x18, 0x7e, 0x3c, 0x18},  // 0012 (uni0012){0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00},  // 0013 (uni0013){0x7f, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x00},  // 0014 (uni0014){0x3e, 0x63, 0x38, 0x6c, 0x6c, 0x38, 0xcc, 0x78},  // 0015 (uni0015){0x00, 0x00, 0x00, 0x00, 0x7e, 0x7e, 0x7e, 0x00},  // 0016 (uni0016){0x18, 0x3c, 0x7e, 0x18, 0x7e, 0x3c, 0x18, 0xff},  // 0017 (uni0017){0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x00},  // 0018 (uni0018){0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00},  // 0019 (uni0019){0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0x00, 0x00},  // 001a (uni001A){0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00},  // 001b (uni001B){0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xfe, 0x00, 0x00},  // 001c (uni001C){0x00, 0x24, 0x66, 0xff, 0x66, 0x24, 0x00, 0x00},  // 001d (uni001D){0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x00, 0x00},  // 001e (uni001E){0x00, 0xff, 0xff, 0x7e, 0x3c, 0x18, 0x00, 0x00},  // 001f (uni001F){0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},  // 0020 (space){0x30, 0x78, 0x78, 0x30, 0x30, 0x00, 0x30, 0x00},  // 0021 (exclam){0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00},  // 0022 (quotedbl){0x6c, 0x6c, 0xfe, 0x6c, 0xfe, 0x6c, 0x6c, 0x00},  // 0023 (numbersign){0x30, 0x7c, 0xc0, 0x78, 0x0c, 0xf8, 0x30, 0x00},  // 0024 (dollar){0x00, 0xc6, 0xcc, 0x18, 0x30, 0x66, 0xc6, 0x00},  // 0025 (percent){0x38, 0x6c, 0x38, 0x76, 0xdc, 0xcc, 0x76, 0x00},  // 0026 (ampersand){0x60, 0x60, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00},  // 0027 (quotesingle){0x18, 0x30, 0x60, 0x60, 0x60, 0x30, 0x18, 0x00},  // 0028 (parenleft){0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0x60, 0x00},  // 0029 (parenright){0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00},  // 002a (asterisk){0x00, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x00, 0x00},  // 002b (plus){0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x60},  // 002c (comma){0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00},  // 002d (hyphen){0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00},  // 002e (period){0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x80, 0x00},  // 002f (slash){0x7c, 0xc6, 0xce, 0xde, 0xf6, 0xe6, 0x7c, 0x00},  // 0030 (zero){0x30, 0x70, 0x30, 0x30, 0x30, 0x30, 0xfc, 0x00},  // 0031 (one){0x78, 0xcc, 0x0c, 0x38, 0x60, 0xc4, 0xfc, 0x00},  // 0032 (two){0x78, 0xcc, 0x0c, 0x38, 0x0c, 0xcc, 0x78, 0x00},  // 0033 (three){0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0x1e, 0x00},  // 0034 (four){0xfc, 0xc0, 0xf8, 0x0c, 0x0c, 0xcc, 0x78, 0x00},  // 0035 (five){0x38, 0x60, 0xc0, 0xf8, 0xcc, 0xcc, 0x78, 0x00},  // 0036 (six){0xfc, 0xcc, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x00},  // 0037 (seven){0x78, 0xcc, 0xcc, 0x78, 0xcc, 0xcc, 0x78, 0x00},  // 0038 (eight){0x78, 0xcc, 0xcc, 0x7c, 0x0c, 0x18, 0x70, 0x00},  // 0039 (nine){0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x30, 0x00},  // 003a (colon){0x00, 0x30, 0x30, 0x00, 0x30, 0x30, 0x60, 0x00},  // 003b (semicolon){0x18, 0x30, 0x60, 0xc0, 0x60, 0x30, 0x18, 0x00},  // 003c (less){0x00, 0x00, 0xfc, 0x00, 0x00, 0xfc, 0x00, 0x00},  // 003d (equal){0x60, 0x30, 0x18, 0x0c, 0x18, 0x30, 0x60, 0x00},  // 003e (greater){0x78, 0xcc, 0x0c, 0x18, 0x30, 0x00, 0x30, 0x00},  // 003f (question){0x7c, 0xc6, 0xde, 0xde, 0xde, 0xc0, 0x78, 0x00},  // 0040 (at){0x30, 0x78, 0xcc, 0xcc, 0xfc, 0xcc, 0xcc, 0x00},  // 0041 (A){0xfc, 0x66, 0x66, 0x7c, 0x66, 0x66, 0xfc, 0x00},  // 0042 (B){0x3c, 0x66, 0xc0, 0xc0, 0xc0, 0x66, 0x3c, 0x00},  // 0043 (C){0xf8, 0x6c, 0x66, 0x66, 0x66, 0x6c, 0xf8, 0x00},  // 0044 (D){0xfe, 0x62, 0x68, 0x78, 0x68, 0x62, 0xfe, 0x00},  // 0045 (E){0xfe, 0x62, 0x68, 0x78, 0x68, 0x60, 0xf0, 0x00},  // 0046 (F){0x3c, 0x66, 0xc0, 0xc0, 0xce, 0x66, 0x3e, 0x00},  // 0047 (G){0xcc, 0xcc, 0xcc, 0xfc, 0xcc, 0xcc, 0xcc, 0x00},  // 0048 (H){0x78, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00},  // 0049 (I){0x1e, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0x78, 0x00},  // 004a (J){0xe6, 0x66, 0x6c, 0x78, 0x6c, 0x66, 0xe6, 0x00},  // 004b (K){0xf0, 0x60, 0x60, 0x60, 0x62, 0x66, 0xfe, 0x00},  // 004c (L){0xc6, 0xee, 0xfe, 0xfe, 0xd6, 0xc6, 0xc6, 0x00},  // 004d (M){0xc6, 0xe6, 0xf6, 0xde, 0xce, 0xc6, 0xc6, 0x00},  // 004e (N){0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x00},  // 004f (O){0xfc, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0, 0x00},  // 0050 (P){0x78, 0xcc, 0xcc, 0xcc, 0xdc, 0x78, 0x1c, 0x00},  // 0051 (Q){0xfc, 0x66, 0x66, 0x7c, 0x6c, 0x66, 0xe6, 0x00},  // 0052 (R){0x78, 0xcc, 0xe0, 0x70, 0x1c, 0xcc, 0x78, 0x00},  // 0053 (S){0xfc, 0xb4, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00},  // 0054 (T){0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xfc, 0x00},  // 0055 (U){0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x00},  // 0056 (V){0xc6, 0xc6, 0xc6, 0xd6, 0xfe, 0xee, 0xc6, 0x00},  // 0057 (W){0xc6, 0xc6, 0x6c, 0x38, 0x38, 0x6c, 0xc6, 0x00},  // 0058 (X){0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x30, 0x78, 0x00},  // 0059 (Y){0xfe, 0xc6, 0x8c, 0x18, 0x32, 0x66, 0xfe, 0x00},  // 005a (Z){0x78, 0x60, 0x60, 0x60, 0x60, 0x60, 0x78, 0x00},  // 005b (bracketleft){0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x02, 0x00},  // 005c (backslash){0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, 0x00},  // 005d (bracketright){0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00},  // 005e (asciicircum){0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff},  // 005f (underscore){0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00},  // 0060 (grave){0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00},  // 0061 (a){0xe0, 0x60, 0x60, 0x7c, 0x66, 0x66, 0xdc, 0x00},  // 0062 (b){0x00, 0x00, 0x78, 0xcc, 0xc0, 0xcc, 0x78, 0x00},  // 0063 (c){0x1c, 0x0c, 0x0c, 0x7c, 0xcc, 0xcc, 0x76, 0x00},  // 0064 (d){0x00, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00},  // 0065 (e){0x38, 0x6c, 0x60, 0xf0, 0x60, 0x60, 0xf0, 0x00},  // 0066 (f){0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8},  // 0067 (g){0xe0, 0x60, 0x6c, 0x76, 0x66, 0x66, 0xe6, 0x00},  // 0068 (h){0x30, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00},  // 0069 (i){0x0c, 0x00, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0x78},  // 006a (j){0xe0, 0x60, 0x66, 0x6c, 0x78, 0x6c, 0xe6, 0x00},  // 006b (k){0x70, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00},  // 006c (l){0x00, 0x00, 0xcc, 0xfe, 0xfe, 0xd6, 0xc6, 0x00},  // 006d (m){0x00, 0x00, 0xf8, 0xcc, 0xcc, 0xcc, 0xcc, 0x00},  // 006e (n){0x00, 0x00, 0x78, 0xcc, 0xcc, 0xcc, 0x78, 0x00},  // 006f (o){0x00, 0x00, 0xdc, 0x66, 0x66, 0x7c, 0x60, 0xf0},  // 0070 (p){0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0x0c, 0x1e},  // 0071 (q){0x00, 0x00, 0xdc, 0x76, 0x66, 0x60, 0xf0, 0x00},  // 0072 (r){0x00, 0x00, 0x7c, 0xc0, 0x78, 0x0c, 0xf8, 0x00},  // 0073 (s){0x10, 0x30, 0x7c, 0x30, 0x30, 0x34, 0x18, 0x00},  // 0074 (t){0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00},  // 0075 (u){0x00, 0x00, 0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x00},  // 0076 (v){0x00, 0x00, 0xc6, 0xd6, 0xfe, 0xfe, 0x6c, 0x00},  // 0077 (w){0x00, 0x00, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0x00},  // 0078 (x){0x00, 0x00, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8},  // 0079 (y){0x00, 0x00, 0xfc, 0x98, 0x30, 0x64, 0xfc, 0x00},  // 007a (z){0x1c, 0x30, 0x30, 0xe0, 0x30, 0x30, 0x1c, 0x00},  // 007b (braceleft){0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00},  // 007c (bar){0xe0, 0x30, 0x30, 0x1c, 0x30, 0x30, 0xe0, 0x00},  // 007d (braceright){0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},  // 007e (asciitilde){0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0x00},  // 007f (uni007F)// ---------------------------  160-255 ---------------------------{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},  // 00a0 (uni00A0){0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00},  // 00a1 (exclamdown){0x18, 0x18, 0x7e, 0xc0, 0xc0, 0x7e, 0x18, 0x18},  // 00a2 (cent){0x38, 0x6c, 0x64, 0xf0, 0x60, 0xe6, 0xfc, 0x00},  // 00a3 (sterling){0x00, 0xc6, 0x7c, 0xc6, 0xc6, 0x7c, 0xc6, 0x00},  // 00a4 (currency){0xcc, 0xcc, 0x78, 0xfc, 0x30, 0xfc, 0x30, 0x30},  // 00a5 (yen){0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00},  // 00a6 (brokenbar){0x3e, 0x63, 0x38, 0x6c, 0x6c, 0x38, 0xcc, 0x78},  // 00a7 (section){0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},  // 00a8 (dieresis){0x7e, 0x81, 0x9d, 0xa1, 0xa1, 0x9d, 0x81, 0x7e},  // 00a9 (copyright){0x3c, 0x6c, 0x6c, 0x3e, 0x00, 0x7e, 0x00, 0x00},  // 00aa (ordfeminine){0x00, 0x33, 0x66, 0xcc, 0x66, 0x33, 0x00, 0x00},  // 00ab (guillemotleft){0x00, 0x00, 0x00, 0xfc, 0x0c, 0x0c, 0x00, 0x00},  // 00ac (logicalnot){0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00},  // 00ad (uni00AD){0x7e, 0x81, 0xb9, 0xa5, 0xb9, 0xa5, 0x81, 0x7e},  // 00ae (registered){0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},  // 00af (macron){0x38, 0x6c, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00},  // 00b0 (degree){0x30, 0x30, 0xfc, 0x30, 0x30, 0x00, 0xfc, 0x00},  // 00b1 (plusminus){0x70, 0x18, 0x30, 0x60, 0x78, 0x00, 0x00, 0x00},  // 00b2 (uni00B2){0x70, 0x18, 0x30, 0x18, 0x70, 0x00, 0x00, 0x00},  // 00b3 (uni00B3){0x0c, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00},  // 00b4 (acute){0x00, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x60, 0xc0},  // 00b5 (mu){0x7f, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x00},  // 00b6 (paragraph){0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00},  // 00b7 (periodcentered){0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0c, 0x38},  // 00b8 (cedilla){0x30, 0x70, 0x30, 0x30, 0x78, 0x00, 0x00, 0x00},  // 00b9 (uni00B9){0x38, 0x6c, 0x6c, 0x38, 0x00, 0x7c, 0x00, 0x00},  // 00ba (ordmasculine){0x00, 0xcc, 0x66, 0x33, 0x66, 0xcc, 0x00, 0x00},  // 00bb (guillemotright){0xc3, 0xc6, 0xcc, 0xdb, 0x37, 0x6f, 0xcf, 0x03},  // 00bc (onequarter){0xc3, 0xc6, 0xcc, 0xde, 0x33, 0x66, 0xcc, 0x0f},  // 00bd (onehalf){0xe0, 0x33, 0x66, 0x3c, 0xfb, 0x37, 0x6f, 0xc3},  // 00be (threequarters){0x30, 0x00, 0x30, 0x60, 0xc0, 0xcc, 0x78, 0x00},  // 00bf (questiondown){0xc0, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0xc6, 0x00},  // 00c0 (Agrave){0x06, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0xc6, 0x00},  // 00c1 (Aacute){0x7c, 0xc6, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0x00},  // 00c2 (Acircumflex){0x76, 0xdc, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0x00},  // 00c3 (Atilde){0xc6, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0xc6, 0x00},  // 00c4 (Adieresis){0x30, 0x30, 0x00, 0x78, 0xcc, 0xfc, 0xcc, 0x00},  // 00c5 (Aring){0x3e, 0x6c, 0xcc, 0xfe, 0xcc, 0xcc, 0xce, 0x00},  // 00c6 (AE){0x78, 0xcc, 0xc0, 0xcc, 0x78, 0x18, 0x0c, 0x78},  // 00c7 (Ccedilla){0xe0, 0x00, 0xfc, 0x60, 0x78, 0x60, 0xfc, 0x00},  // 00c8 (Egrave){0x1c, 0x00, 0xfc, 0x60, 0x78, 0x60, 0xfc, 0x00},  // 00c9 (Eacute){0x78, 0xcc, 0xfc, 0x60, 0x78, 0x60, 0xfc, 0x00},  // 00ca (Ecircumflex){0xcc, 0x00, 0xfc, 0x60, 0x78, 0x60, 0xfc, 0x00},  // 00cb (Edieresis){0xe0, 0x00, 0x78, 0x30, 0x30, 0x30, 0x78, 0x00},  // 00cc (Igrave){0x1c, 0x00, 0x78, 0x30, 0x30, 0x30, 0x78, 0x00},  // 00cd (Iacute){0x7e, 0xc3, 0x3c, 0x18, 0x18, 0x18, 0x3c, 0x00},  // 00ce (Icircumflex){0xcc, 0x00, 0x78, 0x30, 0x30, 0x30, 0x78, 0x00},  // 00cf (Idieresis){0xf8, 0x6c, 0x66, 0xf6, 0x66, 0x6c, 0xf8, 0x00},  // 00d0 (Eth){0xfc, 0x00, 0xcc, 0xec, 0xfc, 0xdc, 0xcc, 0x00},  // 00d1 (Ntilde){0xc0, 0x38, 0x6c, 0xc6, 0xc6, 0x6c, 0x38, 0x00},  // 00d2 (Ograve){0x06, 0x38, 0x6c, 0xc6, 0xc6, 0x6c, 0x38, 0x00},  // 00d3 (Oacute){0x7c, 0xc6, 0x38, 0x6c, 0xc6, 0x6c, 0x38, 0x00},  // 00d4 (Ocircumflex){0x76, 0xdc, 0x38, 0x6c, 0xc6, 0x6c, 0x38, 0x00},  // 00d5 (Otilde){0xc3, 0x18, 0x3c, 0x66, 0x66, 0x3c, 0x18, 0x00},  // 00d6 (Odieresis){0x00, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0x00, 0x00},  // 00d7 (multiply){0x3a, 0x6c, 0xce, 0xd6, 0xe6, 0x6c, 0xb8, 0x00},  // 00d8 (Oslash){0xe0, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x00},  // 00d9 (Ugrave){0x1c, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x00},  // 00da (Uacute){0x7c, 0xc6, 0x00, 0xc6, 0xc6, 0xc6, 0x7c, 0x00},  // 00db (Ucircumflex){0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x00},  // 00dc (Udieresis){0x1c, 0x00, 0xcc, 0xcc, 0x78, 0x30, 0x78, 0x00},  // 00dd (Yacute){0xf0, 0x60, 0x7c, 0x66, 0x7c, 0x60, 0xf0, 0x00},  // 00de (Thorn){0x78, 0xcc, 0xcc, 0xd8, 0xcc, 0xc6, 0xcc, 0x00},  // 00df (germandbls){0xe0, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x7e, 0x00},  // 00e0 (agrave){0x1c, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x7e, 0x00},  // 00e1 (aacute){0x7e, 0xc3, 0x3c, 0x06, 0x3e, 0x66, 0x3f, 0x00},  // 00e2 (acircumflex){0x76, 0xdc, 0x78, 0x0c, 0x7c, 0xcc, 0x7e, 0x00},  // 00e3 (atilde){0xcc, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x7e, 0x00},  // 00e4 (adieresis){0x30, 0x30, 0x78, 0x0c, 0x7c, 0xcc, 0x7e, 0x00},  // 00e5 (aring){0x00, 0x00, 0x7f, 0x0c, 0x7f, 0xcc, 0x7f, 0x00},  // 00e6 (ae){0x00, 0x00, 0x78, 0xc0, 0xc0, 0x78, 0x0c, 0x38},  // 00e7 (ccedilla){0xe0, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00},  // 00e8 (egrave){0x1c, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00},  // 00e9 (eacute){0x7e, 0xc3, 0x3c, 0x66, 0x7e, 0x60, 0x3c, 0x00},  // 00ea (ecircumflex){0xcc, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00},  // 00eb (edieresis){0xe0, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00},  // 00ec (igrave){0x38, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00},  // 00ed (iacute){0x7c, 0xc6, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00},  // 00ee (icircumflex){0xcc, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00},  // 00ef (idieresis){0x30, 0x7e, 0x0c, 0x7c, 0xcc, 0xcc, 0x78, 0x00},  // 00f0 (eth){0x00, 0xf8, 0x00, 0xf8, 0xcc, 0xcc, 0xcc, 0x00},  // 00f1 (ntilde){0x00, 0xe0, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00},  // 00f2 (ograve){0x00, 0x1c, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00},  // 00f3 (oacute){0x78, 0xcc, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00},  // 00f4 (ocircumflex){0x76, 0xdc, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00},  // 00f5 (otilde){0x00, 0xcc, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00},  // 00f6 (odieresis){0x30, 0x30, 0x00, 0xfc, 0x00, 0x30, 0x30, 0x00},  // 00f7 (divide){0x00, 0x02, 0x7c, 0xce, 0xd6, 0xe6, 0x7c, 0x80},  // 00f8 (oslash){0x00, 0xe0, 0x00, 0xcc, 0xcc, 0xcc, 0x7e, 0x00},  // 00f9 (ugrave){0x00, 0x1c, 0x00, 0xcc, 0xcc, 0xcc, 0x7e, 0x00},  // 00fa (uacute){0x78, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0x7e, 0x00},  // 00fb (ucircumflex){0x00, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0x7e, 0x00},  // 00fc (udieresis){0x00, 0x1c, 0x00, 0xcc, 0xcc, 0x7c, 0x0c, 0x78},  // 00fd (yacute){0xe0, 0x60, 0x7c, 0x66, 0x66, 0x7c, 0x60, 0xf0},  // 00fe (thorn){0x00, 0xcc, 0x00, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8},  // 00ff (ydieresis)
};static inline const uint8_t* charBitmap(char c) {uint8_t idx = static_cast<uint8_t>(c);return font8x8_ib8x8u[idx];
}static inline void drawChar(void *data,int w, int h, PixFmt fmt,int x0, int y0, char c,int scale,uint8_t r = 255, uint8_t g = 255, uint8_t b = 255,uint8_t Y = 235, uint8_t U = 128, uint8_t V = 128);static inline void writeText(void *data,int imgW, int imgH, PixFmt imgFmt,int x, int y, const char *text,uint8_t r = 255, uint8_t g = 0, uint8_t b = 0,uint8_t Y = 76, uint8_t U = 84, uint8_t V = 255,int scale = 4, int space = 9);/* ---------- 实现 ---------- */
static inline void putPixel(void *data,int w, int h, PixFmt fmt,int x, int y,uint8_t r, uint8_t g, uint8_t b,uint8_t Y, uint8_t U, uint8_t V)
{if (fmt == PixFmt::RGB24) {uint8_t* p = static_cast<uint8_t*>(data) + (y * w + x) * 3;p[0] = r; p[1] = g; p[2] = b;} else if (fmt == PixFmt::YUV_NV12) {uint8_t* Y_plane = static_cast<uint8_t*>(data);uint8_t* U_plane = Y_plane + w * h;uint8_t* V_plane = U_plane + (w / 2) * (h / 2);uint8_t* UV_plane = Y_plane + w * h;Y_plane[y * w + x] = Y;int x2 = x / 2, y2 = y / 2;UV_plane[y2 * w + x] = U;UV_plane[y2 * w + x + 1] = V;}
}static inline void drawChar(void *data,int w, int h, PixFmt fmt,int x0, int y0, char c,int scale,uint8_t r, uint8_t g, uint8_t b,uint8_t Y, uint8_t U, uint8_t V)
{const uint8_t* bm = charBitmap(c);for (int row = 0; row < 8; ++row) {uint8_t bits = bm[row];for (int col = 0; col < 8; ++col) {if (!(bits & (1 << (7 - col)))) continue;for (int dy = 0; dy < scale; ++dy)for (int dx = 0; dx < scale; ++dx) {int px = x0 + col * scale + dx;int py = y0 + row * scale + dy;if (px < 0 || px >= w || py < 0 || py >= h) continue;putPixel(data, w, h, fmt, px, py, r, g, b, Y, U, V);}}}
}static inline void writeText(void *data,int imgW, int imgH, PixFmt imgFmt,int x, int y,const char *text,uint8_t r, uint8_t g, uint8_t b,uint8_t Y, uint8_t U, uint8_t V,int scale, int space)
{for (; *text; ++text) {drawChar(data, imgW, imgH, imgFmt, x, y, *text, scale, r, g, b, Y, U, V);x += space * scale;}
}static inline void writeTextRgb(void *data, int imgW, int imgH,int x, int y, int fontSize,const char *text,uint8_t r=255, uint8_t g=0, uint8_t b=0)
{int space = 8;for (; *text; ++text){drawChar(data, imgW, imgH, PixFmt::RGB24, x, y, *text, fontSize, r, g, b);x += space * fontSize;}
}static inline bool savePPM(const char *filename, void *rgb, int w, int h) {FILE *fp = fopen(filename, "wb");if (!fp) return false;fprintf(fp, "P6\n%d %d\n255\n", w, h);fwrite(rgb, 1, w * h * 3, fp);fclose(fp);return true;
}
}int main() {int imgW = 600;int imgH = 200;uint8_t rgb[imgW * imgH * 3];// set background colorstd::memset(rgb, 255, imgW * imgH * 3);// write text// OVERLAY::writeTextRgb(rgb, imgW, imgH, 10, 20, 1, "Good Job~ ", 255);OVERLAY::writeTextRgb(rgb, imgW, imgH, 10, 10, 2, "Good Job~ ", 255);OVERLAY::writeTextRgb(rgb, imgW, imgH, 10, 40, 3, "Good Job~ ", 25, 150, 66);OVERLAY::writeTextRgb(rgb, imgW, imgH, 10, 80, 4, "Good Job~ ", 2, 4, 6);OVERLAY::writeTextRgb(rgb, imgW, imgH, 10, 120, 4, "Data: 8 Aug. 2025", 0, 0, 255);OVERLAY::savePPM("save.ppm", rgb, imgW, imgH);return 0;
}#endif

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.pswp.cn/news/918067.shtml
繁体地址,请注明出处:http://hk.pswp.cn/news/918067.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

前端开发(HTML,CSS,VUE,JS)从入门到精通!第八天(Vue框架及其安装)(完结篇) 重点 ! ! !

十三、Vue 单文件组件1&#xff0e;在前面学习的传统组件存在以下问题&#xff1a;&#xff08;1&#xff09;全局定义的组件必须保证组件名不能重复。&#xff08;2&#xff09;字符串的模板缺乏高亮语法&#xff0c;在写多行 HTML 片段的时候&#xff0c;需要用到丑陋的 ”\”…

2025最新国内服务器可用docker源仓库地址大全(2025年8月更新) · DockerHub镜像加速全面指南

2025最新国内服务器可用docker源仓库地址大全&#xff08;2025年8月更新&#xff09; DockerHub镜像加速全面指南 2025年8月&#xff0c;随着云原生技术的深入普及&#xff0c;开发者在使用 Docker 拉取 镜像 时&#xff0c;经常遭遇 超时、镜像下载失败、无法拉取 等网络瓶颈…

GitLab同步提交的用户设置

内容&#xff1a;在GitLab同步提交的用户设置中&#xff0c;部分用户的代码提交仍未与GitLab同步&#xff0c;导致无法在GitLab上显示提交者的用户名。1、检查下gitlab账户的设置 登录gitlab后&#xff0c;右上角个人头像点开后&#xff0c;可以看到姓名和账户2、不对的话&…

Web 图像捕获革命:ImageCapture API 全面解析与实战指南

概述 ImageCapture API 是 Web API 的一部分&#xff0c;允许网页应用直接访问和控制设备摄像头&#xff0c;实现高质量的图像捕获功能。该 API 提供了比传统的 getUserMedia() 更精细的控制能力&#xff0c;支持设置分辨率、白平衡、曝光等参数。 核心特性 1. 高质量图像捕…

ASP.NET三层架构成绩管理系统源码

一、系统简介 本次设计的成绩管理系统是基于ASP.NET WebForm技术开发的Web应用程序&#xff0c;采用经典的三层架构&#xff08;表示层、业务逻辑层、数据访问层&#xff09;设计模式&#xff0c;结合前端HTML、JavaScript、jQuery及ECharts图表库&#xff0c;后端使用C#语言、…

Linux 内存管理之page folios

文章目录前言一、简介struct folio二、page folios的好处2.1 compound page2.2 page cache三、buffer_head、iomap与page folios四、何时分配 Large Folio五、folio结构体演变六、内核主线folio的逐步使用参考资料前言 Linux 内核的内存管理子系统以“页”&#xff08;page&am…

[优选算法专题一双指针——两数之和](双指针和哈希表)

题目链接 LeetCode两数之和 题目描述 题目解析 注意&#xff1a;前提条件&#xff1a;输入的数组numbers是已排序的。 核心思路&#xff1a;双指针法 利用数组已排序的特性&#xff0c;通过两个指针从两端向中间移动&#xff0c;快速定位符合条件的两个数&#xff0c;时间…

佳维视高亮度工业显示器,强光环境清晰可见

在工业、户外或高光照场景中&#xff0c;普通显示器常因环境光干扰导致画面模糊、色彩失真&#xff0c;甚至无法操作。高亮度工业显示器通过技术优化与专业设计&#xff0c;突破光线限制&#xff0c;确保在强光下仍能呈现清晰、稳定的视觉效果&#xff0c;成为关键任务环境中的…

系统的缓存(buff/cache)是如何影响系统性能的?

系统的缓存&#xff08;buff/cache&#xff0c;包括 buffer 和 cache&#xff09;是 Linux 内核为提升系统性能设计的关键机制&#xff0c;其对性能的影响主要体现在加速数据访问和平衡内存与磁盘速度差异上&#xff0c;具体如下&#xff1a; 一、buff/cache 的本质&#xff1a…

浅析 Berachain v2 ,对原有 PoL 机制进行了哪些升级?

Berachain 本身是一个特色鲜明的 Layer1 区块链项目&#xff0c;其最具辨识度的创新在于采用了 PoL&#xff08;Proof of Liquidity&#xff09;区块奖励分配机制。该机制把链的区块奖励转化为生态增长动力的协议内经济机制&#xff0c;通过将绝大部分奖励直接分配给生态中的用…

校招秋招春招小米在线测评小米测评题库|测评解析和攻略|题库分享

秒收测评 小米校招投递简历之后会立马收到在线测评&#xff0c;在线测评考察的内容就是行测和性格测试。 具体内容 小米在线测评有五部分组成&#xff0c;其中第一、二、三部分各限时 10 分钟&#xff0c;并且每题只有 70 秒左右&#xff0c;时间到自动跳到下一题&#xff0…

遮天(帝国篇)

距离轩辕鸿天成为道盟盟主已经过去了三十年&#xff0c;卡萨帝国国君卡萨也在一次战争中被妖族所杀&#xff0c;留下了两个年幼的儿子&#xff0c;长子卡利尔&#xff0c;次子卡修。 卡萨死后一直是大将军戈隆掌控帝国事务&#xff0c;戈隆秉承着道盟见妖就杀的理念让卡萨帝国成…

批量将NC格式数据转换为TIF格式:解决转换后图像颠倒、镜像、翻转等问题

本文介绍基于Python中GDAL模块&#xff0c;批量将大量.nc格式的栅格文件转换为.tif格式&#xff0c;并解决可能出现的转换后图像颠倒、镜像、翻转等问题。最近&#xff0c;需要批量将大量.nc格式的栅格文件转换为.tif格式。如下图所示&#xff0c;有多个待转换的.nc格式文件&am…

《论三生原理》重构数学哲学基础语义场‌?

AI辅助创作&#xff1a;《论三生原理》通过算法化转译传统文化符号、重构数学对象本体论及创新术语体系&#xff0c;系统性重构数学哲学基础语义场&#xff0c;其核心路径如下&#xff1a;&#x1f50d; 一、哲学符号的数学实体化‌阴阳范畴的数理转译‌将《周易》“阴/阳”抽象…

适用于在线3D测量和检测的3D激光轮廓仪

Z-Trak™ Express 1K5 系列是Z-Trak系列中的最新创新成果&#xff0c;专为实现经济高效的在线3D测量和检测而设计&#xff0c;在整个测量范围内可实现每秒最多 5,000 个轮廓的测量速率&#xff0c;具有高速检测能力和实时处理性能。Z-Trak™ Express 1K5系列 3D激光轮廓仪Z-Tra…

主播生活模拟器2|主播人生模拟器2 (Streamer Life Simulator 2)免安装中文版

网盘链接&#xff1a; 七主播生活模拟器2|主播人生模拟器2 名称&#xff1a;七主播生活模拟器2|主播人生模拟器2 &#xff08;Streamer Life Simulator 2&#xff09;免安装中文版 描述&#xff1a;《主播人生模拟器》是一款从零开始&#xff0c;努力成为一名受欢迎的网络主…

解决React白板应用中的画布内容丢失问题

解决React白板应用中的画布内容丢失问题 在开发基于React的在线白板应用时&#xff0c;我们遇到了一个棘手问题&#xff1a;当用户滚动到底部自动扩展画布时&#xff0c;原有绘制内容会神秘消失。经过系统排查&#xff0c;最终通过Canvas API的巧妙运用解决了这个问题。以下是完…

韩国宝蓝集团与Alpha World、非小号Alpha正式达成战略合作

2025年8月1日&#xff0c;Boram Group(宝蓝集团)旗下Boram Sangjo特销团队正式宣布&#xff0c;已与全球Web3平台 Alpha World 以及加密数据平台 非小号Alpha&#xff08;FXH Alpha&#xff09;达成三方战略合作。始于1991–1992年创立的 Boram Sangjo Development隶属于Boram …

手动开发一个TCP服务器调试工具(二):无界面 TCP 通信服最小实现

本篇将讲解如何使用 Qt 构建一个简单但完整的TCP 服务端&#xff0c;无需图形界面。✦ 程序功能概览 启动一个监听本地 12345 端口的 TCP 服务&#xff1b;有客户端连接时输出信息&#xff1b;每秒向客户端发送一次当前时间&#xff1b;支持接收客户端数据&#xff1b;客户端断…

​​大语言模型(LLM)实战应用:从微调到部署全流程​​

摘要​​ 大语言模型&#xff08;LLM&#xff09;已成为AI落地的核心驱动力&#xff0c;但其从预训练状态到生产环境的转化仍面临技术复杂度高、资源消耗大等挑战。本文系统梳理LLM实战全流程&#xff0c;涵盖​​微调策略选择​​、​​量化压缩技术​​、​​部署优化方案​​…