DEBUG and RELEASE mode
Just a short question, any help will be appreciated!
You can use the standard sizeof(struct) operator to get the size of whichever pixel format you need.
e.g. to find the size of the Rgba32 pixel struct you can just use var size = sizeof(Rgba32);.
Great! But if I don't know pixel format of an image? Default format for Image.Load() is Rgba32, even if I load 8 bpp PNG
That's right, the pixel format is always whatever the TPixel is in Image<TPixel> how the underlying file format stores the data is ignored outside the decoder, the decoders convert it to the correct TPixel type you asked for..
Yes, You load the image as the given TPixel type.
Image.Load(stream) and Image<Rgba32>.Load both load the type as Rgba32Image<Rgba24>.Load loads the type as Rgba24and so on...
I got it, but I have to determine what exact BPP has particular image stored in Stream/byte[]/etc. How can I do that?
AFAIK, you can't do that currently. @JimBobSquarePants shouldn't we convert this into a feature request issue or open a new one?
Really this is a misuse of the issue tracker. The question should have been asked in Gitter.
It's a sensible requirement though so let's continue here and add the correct tags.
You can use the standard sizeof(struct) operator to get the size of whichever pixel format you need.
e.g. to find the size of the Rgba32 pixel struct you can just use var size = sizeof(Rgba32);
@tocsoft, unfortunately I can't use even sizeof(Rgba32) due to compile time error CS0233: 'Rgba32' does not have a predefined size, therefore sizeof can only be used in an unsafe context (consider using System.Runtime.InteropServices.Marshal.SizeOf)
@xakep139 If you can't use unsafe code in your library use System.Runtime.CompilerServices.Unsafe That has a SizeOf<T> method.
Fixed with #292