4

From the docs:

...The format also defines the order of the color components within a single pixel of data.

Where is the order documented? I know that, for example,locking the bitmap with format 24bppRgb gives me a region in memory filled with pixel data in the form:

  1. B(first byte)- G(second) - R(third)
  2. Each row has an alignment of 4 byte

I found "2" in the documentation, however I didn't manage to find anything about "1" (color component order). Could you help me find that info somewhere in the documentation?

  • 1
    It depends on the pixel format. And though `PixelFormat`'s documentation is not detailed very well either, [here](https://docs.kgysoft.net/drawing/html/T_KGySoft_Drawing_Imaging_KnownPixelFormat.htm) you can find a more detailed description from a fairly compatible library. Btw. the library [allows](https://github.com/koszeggy/KGySoft.Drawing#fast-bitmap-manipulation) you to access the bitmap data of any pixel format in the same way, which doesn't require to bother with the actual color layout and is also very performant (disclaimer: written by me). – György Kőszeg Jun 07 '23 at 13:10
  • Thanks @GyörgyKőszeg. I'll take a look at that library. However, where can I find something equivalent to `KnownPixelFormat` documentation, where the color component order is well defined for a format, for `System.Drawing.Imaging.PixelFormat`? – leone ruggiero Jun 07 '23 at 13:42
  • Unfortunately `PixelFormat`'s documentation doesn't go into the details very much. But exception with the 48/64 bpp formats my `KnownPixelFormat` is completely compatible with `PixelFormat`. You can fond more `System.Drawing`-specific pixel format related information [here](https://docs.kgysoft.net/drawing/html/M_KGySoft_Drawing_ImageExtensions_ConvertPixelFormat_1.htm) (see the table and also the notes below it). Please note that the actual behavior is platform dependent (Windows vs. Linux[/Mono] vs. ReactOS) – György Kőszeg Jun 08 '23 at 09:23

0 Answers0