question

TamilPrakashS-6320 avatar image
0 Votes"
TamilPrakashS-6320 asked ·

How to display 3 single channel array in wpf?

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)
 {        
     unsafe
     {
         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.Lock();
         wbitmap.AddDirtyRect(new System.Windows.Int32Rect(0, 0, width, height));
         wbitmap.Unlock();
     }
 }

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






windows-wpf
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

vb2ae avatar image
0 Votes"
vb2ae answered ·

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.

https://www.wpftutorial.net/ValueConverters.html

https://docs.microsoft.com/en-us/dotnet/api/system.windows.data.ivalueconverter?view=netcore-3.1


·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.