How to display 3 single channel array in wpf?

asked 2020-06-12T10:31:41.967+00:00
Tamil Prakash S 1 Reputation point

I have 3 IntPtr Pointers of Red, Green, and Blue channels. I need to display these pointers as an RGB image. I know the width and height of the image. If I convert it as a single pointer it takes processing cost.

Here is my Conversion Code,

public static void UpdateImage(WriteableBitmap wbitmap, IntPtr red, IntPtr green, IntPtr blue, int totalSize, int width, int height)
        byte* redByt = (byte*)red;
        byte* blueByt = (byte*)blue;
        byte* greenByt = (byte*)green;
        byte* buffer = (byte*)wbitmap.BackBuffer;

        for (int i = 0; i < totalSize; i+=3)
            buffer[i ] = redByt[i];
            buffer[i + 1] = blueByt[i];
            buffer[i+ 2] = greenByt[i];
        wbitmap.AddDirtyRect(new System.Windows.Int32Rect(0, 0, width, height));

I need to display these 3 single channeled pointers to UI without above conversion, Is there any way?

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,169 questions
No comments
{count} votes

1 answer

Sort by: Most helpful
  1. answered 2020-06-14T15:41:43.49+00:00
    Ken Tucker 5,796 Reputation points

    Not exactly sure what you are asking. There is a thing called an IValueConverter you can use to Modify the image before you display it.

    No comments