Do you have any ideas why the pixels in a bmp file are stored upside-down ?
It depends on your definition of "upside down". The BMP file format uses the Cartesian coordinate system which puts point (0,0) in the bottom left. This is because BMP files were invented very early in the history of computing and the format maps quite closely to mathematical graphs, so this seemed more "natural" at the time.
The BMP file format stores the pixels (0,0), then (0, 1), then (0, 2)... (0,n) then (1, 0), (1,1) ... (1,n) and so on until it reaches the top right.
This is in contrast with much newer formats like JPG and PNG who inverse the y-axis, and store the pixels at the top of the image nearer the beginning of the file (i.e. 0,0 is in the top-left). This is a hold over from an optimisation that images stored in this way could output faster to a CRT faster, although this is no longer the case with modern monitors.