gpt4 book ai didi

c++ - 为 QImage 设置 DPI

转载 作者:太空狗 更新时间:2023-10-29 23:46:09 33 4
gpt4 key购买 nike

我在 QImage 上使用 QPainter 绘制文本,然后将其保存为 TIFF。

我需要将 DPI 增加到 300,这应该使文本在像素方面更大(对于相同的磅值)。

最佳答案

您可以尝试使用 QImage::setDotsPerMeterY() 和 QImage::setDotsPerMeterX()。 DPI 表示“每英寸点数”。 1 英寸等于 0.0254 米。因此,您应该能够转换为每米点数 (dpm):

int dpm = 300 / 0.0254; // ~300 DPI
image.setDotsPerMeterX(dpm);
image.setDotsPerMeterY(dpm);

它不会正好是 300DPI(实际上是 299.9994),因为这些函数只适用于整数值。但就所有意图和目的而言,它已经足够好了(我认为 299.9994 与 300 相当不错。)

关于c++ - 为 QImage 设置 DPI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13413213/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com