2026年7月16日 缓存

This commit is contained in:
2026-07-16 08:28:55 +08:00
parent 31726535b0
commit 570f359339
35 changed files with 945 additions and 1275 deletions
+7 -5
View File
@@ -55,8 +55,8 @@ static QImage renderDataMatrix(const unsigned char *grid, int cols, int rows, in
return QImage();
}
int width = cols * moduleSize;
int height = rows * moduleSize;
int width = rows * moduleSize;
int height = cols * moduleSize;
QImage image(width, height, QImage::Format_ARGB32);
image.fill(background);
@@ -64,8 +64,8 @@ static QImage renderDataMatrix(const unsigned char *grid, int cols, int rows, in
for (int x = 0; x < cols; ++x) {
bool bit = (grid[y * cols + x] & 0x01) != 0;
QRgb color = bit ? foreground : background;
int px = x * moduleSize;
int py = y * moduleSize;
int px = y * moduleSize;
int py = (cols - 1 - x) * moduleSize;
for (int dy = 0; dy < moduleSize; ++dy) {
for (int dx = 0; dx < moduleSize; ++dx) {
image.setPixel(px + dx, py + dy, color);
@@ -573,6 +573,8 @@ QImage ItemUtils::txtToImage(const QString &txt, const QFont &font, const QColor
painter.drawText(img.rect(), txt);
painter.end();
return img;
// 按背景色裁剪,使输出图像紧贴文字像素的最小包围盒(详见函数注释)
return clipTxtImage(img, bgRgb);
}
}