Get the correct image width and height of an NSImage

后端 未结 5 2019
北荒
北荒 2021-02-04 02:20

I use the code below to get the width and height of a NSImage:

NSImage *image = [[[NSImage alloc] initWithContentsOfFile:[NSString stringWithFormat:s]] autorelea         


        
5条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-04 02:40

    Apple uses a point system based on DPI to map points to physical device pixels. It doesnt matter what the EXIF says, it matters how many logical screen points your canvas has to display the image.

    iOS and OSX perform this mapping for you. The only size you should be concerned about is the size returned from UIImage.size

    You cant (read shouldnt have to shouldnt care) do the mapping to device pixels yourself, thats why apple does it.

提交回复
热议问题