Image size considering (or not) h/v resolution

為{幸葍}努か 提交于 2020-01-24 21:06:13

问题


I have two images:

Name   Type  Width  Height  HRes  VRes  
img01  GIF   256    256     384   96  
img02  TIFF  1728   1147    200   100

Windows internal viewer shows them using different patterns:

  • img01 is displayed as 256x256 image (square)
  • img02 is displayed as a vertical image (despite of width>height) and image format is correct

After seen img02 behaviour I thought that displayed size is given by:

Display_Width  = max(HRes,VRes) * Width / HRes
Display_Height = max(HRes,VRes) * Height / VRes

But that's not good for img01, which is displayed as 256x256!!
If I use Image class to load those images, resolution is not taken in account, so img02 is shown horizontally and distorced respect correct format.
If Windows internal viewer shows them correctly, I think there should be some property to understand if resolution should be considered or not.
With Image class I have Flags and PropertyItems properties, but I really don't understand if they are the ones I have to look at.

Can you teach me the right method to display images (using Image class) without distortion?
Thanks


回答1:


Aspect ratio in GIF files is very uncommon, since GIF is a format used to store graphics intended to be displayed on computer screens. In fact, GIF87a files do not have an aspect ratio at all, and GIF89a do not store the actual aspect ratio but an approximation.

On the other side, TIFF files for the most part are used by graphic designers, photographers and publishers, so the concept of pixel aspect ratio is core to the format as it allows these files to move between different display mediums.

My guess is that most GIF decoders ignore the aspect ratio from the GIF89a format. I think you should do the same.



来源:https://stackoverflow.com/questions/7720206/image-size-considering-or-not-h-v-resolution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!