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?