none
Converting WriteableBitmap To Bitmap Real-Time giving an exception (System.OutofMemoryException "Insufficient memory to continue the execution of program") RRS feed

  • Question

  • I'll try my best to understand my question to you @Carmine 

    Here is my code that I have tried to Convert WriteableBitmap to Bitmap in realtime but I got an exception of "Insufficient memory to continue the execution of program" using C# 

     private void ConvertWriteAbleBitmapToBitmap(WriteableBitmap writeableBmp, int colorFrameWidth, int colorFrameHeight)
            {
                var bmapSource = writeableBmp.Clone(); 
                //Create new Bitmap
                Bitmap bmp = new Bitmap(colorFrameWidth, colorFrameHeight,
                    System.Drawing.Imaging.PixelFormat.Format32bppRgb);
                //Specifies the attributes of a bitmap image
                //LockBits locks a Bitmap into system memory
                BitmapData dataBitmap = bmp.LockBits(new System.Drawing.Rectangle
                    (System.Drawing.Point.Empty, bmp.Size),
                    ImageLockMode.WriteOnly,
                    System.Drawing.Imaging.PixelFormat.Format32bppRgb);
                //Copies the bitmap pixel data within the specified range 
                bmapSource.CopyPixels(Int32Rect.Empty,
                    dataBitmap.Scan0,
                    dataBitmap.Height * dataBitmap.Stride,
                    dataBitmap.Stride);
                //Unlocks the Bitmap from system memory
                bmp.UnlockBits(dataBitmap);               
            }  

    if anyone knows about the solution please guide me with the rite code. how can be this solve ?

    Best Regards 

    From MOeez

    Friday, February 24, 2017 7:09 PM