update
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
#include <QImage>
|
||||
#include <QRect>
|
||||
#include <QString>
|
||||
|
||||
namespace core {
|
||||
|
||||
/// 基于 libvips 的大图 I/O:随机访问裁剪、流式写 PNG、缩略预览,避免整图进内存。
|
||||
/// 未编译 libvips 时 API 返回 false,由调用方回退到 Qt。
|
||||
class VipsBackend {
|
||||
public:
|
||||
/// 须在 QApplication 创建后调用一次,argv0 建议为 argv[0]。
|
||||
static bool init(const char* argv0);
|
||||
static void shutdown();
|
||||
|
||||
static bool isAvailable();
|
||||
|
||||
/// 打开文件读取宽高(轻量,不解码全图)
|
||||
static bool probeSize(const QString& path, QSize* out);
|
||||
|
||||
/// 生成预览图(总像素约不超过 maxPixels),用于裁剪对话框 / 画布
|
||||
static bool loadThumbnailQImage(const QString& path, qint64 maxPixels, QImage* out);
|
||||
|
||||
/// 将原图中矩形区域(像素坐标,含边界)无损写入 PNG;区域为整图时直接流式转存。
|
||||
/// 适合 GB 级 PNG,不构建整幅 QImage。
|
||||
static bool saveRectToPng(const QString& sourcePath, const QRect& rectInSource, const QString& destPngPath);
|
||||
|
||||
/// 裁剪原图矩形区域;若超过 maxOutput* 则按比例缩小(不降采样整图,只处理该区域)。
|
||||
static bool loadRegionToQImage(const QString& sourcePath, const QRect& rectInSource, int maxOutputWidth,
|
||||
int maxOutputHeight, QImage* out);
|
||||
|
||||
private:
|
||||
VipsBackend() = default;
|
||||
};
|
||||
|
||||
} // namespace core
|
||||
Reference in New Issue
Block a user