The International Simutrans Forum

 

Author Topic: r2020 - BMP height map rotates 180 degree  (Read 2849 times)

0 Members and 1 Guest are viewing this topic.

Offline z9999

  • Devotees (Inactive)
  • *
  • Posts: 848
r2020 - BMP height map rotates 180 degree
« on: September 14, 2008, 12:56:45 AM »
simutrans 2020 GDI

When I load bmp height map, the image rotates 180 degree.
And superfluity pixel causes misalignment of image.

I think bmp stores last pixel first.

Offline VS

  • Senior Plumber (Devotee)
  • Devotees (Inactive)
  • *
  • Posts: 4856
  • Vladimír Slávik
    • VS's Simutrans site
  • Languages: CS,EN
Re: r2020 - BMP height map rotates 180 degree
« Reply #1 on: September 14, 2008, 07:25:00 AM »
Yes, bmp is written backwards, at least the 24bpp colour variant (open some on the web and see for yourself). But not really backwards, only lines are from bottom to top, pixels within lines are left to right:

Quote
The bitmap bits, immediately following the color table, consist of an array of BYTE values representing consecutive rows, or "scan lines," of the bitmap. Each scan line consists of consecutive bytes representing the pixels in the scan line, in left-to-right order. The number of bytes representing a scan line depends on the color format and the width, in pixels, of the bitmap. If necessary, a scan line must be zero-padded to end on a 32-bit boundary. However, segment boundaries can appear anywhere in the bitmap. The scan lines in the bitmap are stored from bottom up. This means that the first byte in the array represents the pixels in the lower-left corner of the bitmap and the last byte represents the pixels in the upper-right corner.
« Last Edit: September 14, 2008, 07:39:13 AM by VS »

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10627
  • Languages: De,EN,JP
Re: r2020 - BMP height map rotates 180 degree
« Reply #2 on: September 14, 2008, 10:08:17 AM »
Well, height can be negative, and in this case the bitmap is the other way round. Which bitmap is off? Usually padding in 24Bit is strange. (Actually, I have well working routines at university, but the backup is not working for some days, so I had the write them frommemory and Wikipedia docu.) Will look at it.

Offline z9999

  • Devotees (Inactive)
  • *
  • Posts: 848
[solved]Re: r2020 - BMP height map rotates 180 degree
« Reply #3 on: September 15, 2008, 04:46:06 AM »
solved in r2022. Thank you.