从 CGImageRef 获取分辨率

发布于 2024-09-13 04:07:03 字数 359 浏览 3 评论 0原文

在一种情况下,我通过 CGImageSource 从 TIFF 文件创建 CGImageRef,在另一种情况下,通过 CGDataProvider 从原始位图数据创建 CGImageRef,在另一种情况下,通过 NSImage 从 PDFPage 创建 CGImageRef。我需要知道 CGImage 的分辨率。有没有一种简单的方法可以找出这个问题?

在 PDFPage 情况下,我应该能够获取像素宽度和点宽度并进行算术。 但是,在其他两种情况下,我没有找到从源中获取分辨率(或点宽、物理宽度或类似内容)的方法。

实际上,在原始位图的情况下,我单独拥有分辨率,但我想我想知道是否需要单独携带它,或者是否有一种聪明的方法可以将其从 CGImageRef 中取出......

I'm creating a CGImageRef out of, in one case, a TIFF file, through a CGImageSource, in another case raw bitmap data via a CGDataProvider and in another case, from a PDFPage via an NSImage. I need to know the resolution of the CGImage. Is there an easy way to find this out?

in the PDFPage case, I should be able to get the pixelwidth and the pointwidth and do the arithmetic.
however, in the other two cases, I don't see a way to get resolution (or pointwidth, or physical width or anything like that) out of the source.

Actually, in the Raw bitmap case, I have the resolution separately, but I guess I'm wondering if I need to carry that along separately, or if there's a clever way to just get it out of the CGImageRef...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吃兔兔 2024-09-20 04:07:03

CGImage 对象是没有大量元数据的普通位图图像。它们不携带物理图像大小或分辨率(像素尺寸除外)等信息。您必须从最初获取图像的来源获取这些数据。对于图像文件,NSImage 有一个 size 属性。

CGImage objects are plain bitmap images without a lot of metadata. They do not carry around information like physical image size or resolution (other than pixel dimensions). You have to get this data from the sources from which you got the images in the first place. In case of image files, NSImage has a size property.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文