开发者

Getting resolution from a CGImageRef

开发者 https://www.devze.com 2023-01-10 15:55 出处:网络
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

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 b开发者_StackOverflow社区itmap 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...


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消