Bitmap storage

Started by
4 comments, last by don 18 years, 5 months ago
Hi, Anyone knows why a bitmap is stored vertically fliped? What is the reason or advantage for doing so? Thanks in advance
Advertisement
Hi,

The beam of a CRT monitor scans the screen surface from the left to ther right and from the top to the bottom. So historically the most natural memory layout for storing images is from the top left to the bottom right pixel.
A fullscreen image stored this way could be symply copied to the video memory in one memcpy (or DMA copy) and the RAMDAC would display it correctly.

Phil
PixelPhil: But the bitmaps that kayX is referring to are stored from the bottom row to the top row.

kayX: I don't know the answer offhand, but a quick search of Wikipedia would probably turn something up.
{[JohnE, Chief Architect and Senior Programmer, Twilight Dragon Media{[+++{GCC/MinGW}+++{Code::Blocks IDE}+++{wxWidgets Cross-Platform Native UI Framework}+++
If you're drawing diagram you normally have the X axis going from negative to positive from left to right.
The Y axis is going from negative to positive from bottom to up.

I think that the bmp format was invented eons ago by academics that thought that this was the logical thing to do.

"Modern" formats such as (.png, .dds, .jpg, .tif) store all bitmaps top-down.
.tga's can be stored in both ways as can .bmp's (I think that if the horizontal size is negative it's stored top-down, a bit unsure though).



Quote:Original post by eq
(I think that if the horizontal size is negative it's stored top-down, a bit unsure though).


That would be the vertical. Makes sense, too.
Kippesoep
In the case of Windows DIB format, a negative biHeight value signifies a top-down orientation, while a positive biHeight value refers to a bottom-up orientation.

This bottom-up format is a holdover from OS/2 Presentation Manager where location (0, 0) was at the bottom left corner of the screen.

This topic is closed to new replies.

Advertisement