关于图片分辨率处理

软件和网站开发以及相关技术探讨
回复
清风两袖装
帖子: 5
注册时间: 2015-04-22 9:47
系统: ubuntu 14.10

关于图片分辨率处理

#1

帖子 清风两袖装 » 2015-04-22 13:31

我调用了poppler库来提取pdf中的页面,我想通过Screen.pixelDensity×25.4来获取dpi从而让图片页面能适合屏幕的像素,但是我发现对于不同的pdf文件在给定pdi的情况下poppler返回的图片像素值是不一样的,我想问下怎么才能让获取的图片像素大小能适应屏幕。不能直接scale(),这样会严重影响清晰度。附上poppler的页面提取函数:

QImage Poppler::Page::renderToImage ( double xres = 72.0,
double yres = 72.0,
int x = -1,
int y = -1,
int w = -1,
int h = -1,
Rotation rotate = Rotate0
) const

Render the page to a QImage using the current Document renderer.

If x = y = w = h = -1, the method will automatically compute the size of the image from the horizontal and vertical resolutions specified in xres and yres. Otherwise, the method renders only a part of the page, specified by the parameters (x, y, w, h) in pixel coordinates. The returned QImage then has size (w, h), independent of the page size.

Parameters
x specifies the left x-coordinate of the box, in pixels.
y specifies the top y-coordinate of the box, in pixels.
w specifies the width of the box, in pixels.
h specifies the height of the box, in pixels.
xres horizontal resolution of the graphics device, in dots per inch
yres vertical resolution of the graphics device, in dots per inch
rotate how to rotate the page

Warning
The parameter (x, y, w, h) are not well-tested. Unusual or meaningless parameters may lead to rather unexpected results.

Returns
a QImage of the page, or a null image on failure.

w , h是对返回图片进行裁剪,而不会改变整个图片的像素值
清风两袖装
帖子: 5
注册时间: 2015-04-22 9:47
系统: ubuntu 14.10

Re: 关于图片分辨率处理

#2

帖子 清风两袖装 » 2015-04-22 13:52

自己先顶一下!!!老师,大神们出出主意呀
头像
astolia
论坛版主
帖子: 6396
注册时间: 2008-09-18 13:11

Re: 关于图片分辨率处理

#3

帖子 astolia » 2015-04-22 15:30

跟据pdf页面的像素大小和设备屏幕的尺寸,自己来算xres和yres的值,不要用固定值
清风两袖装
帖子: 5
注册时间: 2015-04-22 9:47
系统: ubuntu 14.10

Re: 关于图片分辨率处理

#4

帖子 清风两袖装 » 2015-04-22 19:26

astolia 写了:跟据pdf页面的像素大小和设备屏幕的尺寸,自己来算xres和yres的值,不要用固定值
谢谢大神的帮助,一直是这个思路,但却忘记了page size的作用,再次真诚感谢。
回复