Question

I noticed that Color struct from System.Drawing represents color in ARGB color space. So there are some questions:

  • How to convert image beetween ARGB and YUV in c#? I found formulas describing RGB to YUV conversion. So what should I do with alpha channel?
  • Are there free/trial libraries that support different color spaces? Or how do I implement it myself in the best manner?
  • How do I represent 'Bitmap' as 2d array with ability to iterate over it? is Inheritance the only way to accomplish this?

That's all yet)

Thanks!

Was it helpful?

Solution

You cannot directly convert argb to YUV (without loss) cause YUV contains no alpha information.

Depending on what you wanna do with the color after you have these possibilities:

  • you just cut the alpha and discard the transparency

  • you convert to a AYUV which contains also an alpha channel

conversion between color spaces

One possibility to convert a bitmap to a byte[] is to write it in a memorystream and read it bite wise.

MemoryStream stream = new MemoryStream();
bitmap.Save(stream, ImageFormat.Bmp);
byte[] data = stream.ToArray();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top