考虑(或不考虑)水平/垂直分辨率的图像大小
我有两个图像:
Name Type Width Height HRes VRes
img01 GIF 256 256 384 96
img02 TIFF 1728 1147 200 100
Windows 内部查看器使用不同的模式显示它们:
- img01 显示为 256x256 图像(方形)
- img02 显示为垂直图像(尽管宽度>高度)和图像格式是正确的
在看到 img02 行为之后,我认为显示的尺寸是由以下给出的:
Display_Width = max(HRes,VRes) * Width / HRes
Display_Height = max(HRes,VRes) * Height / VRes
但这并不适合img01,显示为256x256!!
如果我使用 图像类 加载这些图像,分辨率未考虑在内,因此 img02 水平显示并扭曲,符合正确的格式。
如果 Windows 内部查看器正确显示它们,我认为应该有一些属性来了解是否应考虑分辨率。
使用 图像类 我有 标志 和 PropertyItems 属性,但我真的不明白是否他们是我必须要看的人。
你能教我正确的方法来显示图像(使用 Image 类)而不失真吗?
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
GIF 文件中的长宽比非常罕见,因为 GIF 是一种用于存储要在计算机屏幕上显示的图形的格式。事实上,GIF87a 文件根本没有长宽比,而 GIF89a 不存储实际的长宽比,而是近似值。
另一方面,TIFF 文件大部分由图形设计师、摄影师和出版商使用,因此像素长宽比的概念是该格式的核心,因为它允许这些文件在不同的显示介质之间移动。
我的猜测是,大多数 GIF 解码器都会忽略 GIF89a 格式的宽高比。我认为你也应该这样做。
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.