22

If you have a really really large JPG and a BMP embedded on HTML and you load it into Firefox, you will notice that the JPG will load "downwards" (paint from left to right, then down) and the BMP will load "upwards" (paint from right to left, then up).

Just curious. :)

Ian
  • 5,625
  • 11
  • 57
  • 93
  • 1
    As an aside, you'll find PNG can do anything BMP files can, and in much less space due to compression. (And are thus much faster to load.) – Thanatos Aug 30 '10 at 17:35

2 Answers2

14

I wrote a bitmap parser a while back, and if I remember correctly, bitmaps store the image backwards. That is, it stores the lower rows first and the higher rows last. The data arrives to your browser in-order, so that's why you can watch it load from the bottom up.

EDIT: Here's a better link that pretty much tells you everything you would ever want to know about a bitmap file: http://en.wikipedia.org/wiki/BMP_file_format

MGSoto
  • 2,293
  • 5
  • 21
  • 29
  • Here's a link I found that has a some simple code that would show how to read a bitmap: http://www.nathanm.com/reading-a-bitmap-regardless-of-orientation/ – MGSoto Aug 30 '10 at 15:45
1

Bitmap coordinates start at the bottom left of the screen - this makes perfect sense if you think of a graph, you start the origin at the lower left.

Most graphics devices start at the top left - because raster scanning displays like CRTs started the scan at the top (why?) and LCDs continued the standard

Martin Beckett
  • 94,801
  • 28
  • 188
  • 263