Skip to main content
GameDev.net gamedev.net
🔒 Locked

Bitmap storage

Started by kayX Oct 24, 2005 at 2:05 AM 4 replies 1.5k views
Original Post
kayX
kayX
Hi, Anyone knows why a bitmap is stored vertically fliped? What is the reason or advantage for doing so? Thanks in advance
PixelPhil
PixelPhil
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
eq
eq
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).



Kippesoep
Kippesoep
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
don
don
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.