user581734
user581734

Reputation: 1239

How does C# write bitmap data. is it bottom up or top down?

According to Wikipedia :

The pixel array is a block of 32-bit DWORDs, that describes the image pixel by pixel. Normally pixels are stored "upside-down" with respect to normal image raster scan order, starting in the lower left corner, going from left to right, and then row by row from the bottom to the top of the image.1 Uncompressed Windows bitmaps also can be stored from the top to bottom, when the Image Height value is negative.

So, when I use this code:

b.Save(outputFilename, ImageFormat.Bmp);

How does C# actually save it ? Can I tell C# to save it with height value negative and write it in top down manner ?

Upvotes: 3

Views: 2323

Answers (2)

Stefan Paul Noack
Stefan Paul Noack

Reputation: 3734

The ImageCodecInfo for the BMP format does not seem to support any EncoderParameters. See here for more details on that. So there seems to be no way to specify how it should be stored. As to find out how it is stored, just try it. Make an image that's black in the upper half and white in the lower half and view it in a hex editor.

I bet it's 'upside-down' since it's the default.

Upvotes: 1

rfmodulator
rfmodulator

Reputation: 3738

No, the height property must be greater than 0.

Upvotes: 0

Related Questions