为什么颠簸存放? [英] Why are bmps stored upside down?

查看:108
本文介绍了为什么颠簸存放?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么BMP图像上下颠倒并零填充,因此它们是四字节对齐的?

Why are BMP images stored upside down and zero-padded so they are four-byte aligned?

推荐答案

这是一个引用来自Petzold:

Here's a quote from Petzold:


因此,在DIB中,图像的最下一行是文件的第一行,
和图像的顶行是文件的最后一行。这是
,称为自下而上的组织。因为这个组织是
违反直觉,你可能会问为什么这样做。

So, in DIBs, the bottom row of the image is the first row of the file, and the top row of the image is the last row in the file. This is called a bottom-up organization. Because this organization is counterintuitive, you may ask why it's done this way.

嗯,这一切都回到了OS / 2 Presentation Manager。
的人IBM确定PM中的所有坐标系统 - 包括
窗口,图形和位图的坐标系统 - 应该是一致的。这引发了一场
辩论:大多数人,包括使用
全屏幕文本编程或窗口环境工作的程序员,按照
的垂直坐标来考虑增加屏幕下方。然而,
硬核计算机图形程序员从
接近视频显示,这一观点源于解析几何的数学。
这涉及一个矩形(或笛卡尔)坐标系,其中
增加的垂直坐标在空间中上升。

Well, it all goes back to the OS/2 Presentation Manager. Someone at IBM decided that all coordinate systems in PM—including those for windows, graphics, and bitmaps—should be consistent. This provoked a debate: Most people, including programmers who have worked with full-screen text programming or windowing environments, think in terms of vertical coordinates that increase going down the screen. However, hardcore computer graphics programmers approach the video display from a perspective that originates in the mathematics of analytic geometry. This involves a rectangular (or Cartesian) coordinate system where increasing vertical coordinates go up in space.

简而言之,数学家赢了。 PM中的所有东西都背负着
的左下角原点,包括窗口坐标。这就是DIBs
如何变成这样的方式。

In short, the mathematicians won. Everything in PM was saddled with a bottom-left origin, including window coordinates. And that's how DIBs came to be this way.

来源:Charles Petzold, Windows 5版编程,第15章。

Source: Charles Petzold, Programming for Windows 5th Edition, Chapter 15.

这篇关于为什么颠簸存放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆