المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : 1500x1500 image at 30fps on wpf



C# Programming
04-02-2013, 08:53 PM
Hello,

i'm moving my actual winform based application to WPF.

My application acquire 1500x1500 8bit depth images at 30 frame per second.

In winform i was used to BitBlt my images to a panel handle and that work fine.

In wpf i tried two ways:

// on every frame: int stride = img_w * ((PixelFormats.Gray8.BitsPerPixel + 7) / 8); bmpSource = BitmapSource.Create(img_w, img_h, 96, 96, PixelFormats.Gray8, null, my_arrb_8bit, stride); this.Image1.Source = bmpSource;
but this is too slow...then i try

// on every frame: int max = PixelFormats.Rgb24.BitsPerPixel; uint count = (uint)(img_w * img_h * PixelFormats.Rgb24.BitsPerPixel / 8); IntPtr section = CreateFileMapping(new IntPtr(-1), IntPtr.Zero, FileMapProtection.PageReadWrite, 0, count, null); IntPtr map = MapViewOfFile(section, FileMapAccess.FileMapAllAccess, 0, 0, (UIntPtr)count); System.Runtime.InteropServices.Marshal.Copy(my_arrb_24bit, 0, map, (int)count); my_ibs = System.Windows.Interop.Imaging.CreateBitmapSourceFromMemorySection( section, (int)img_w, (int)img_h, PixelFormats.Rgb24, (int)(img_w * PixelFormats.Rgb24.BitsPerPixel / 8), 0) as System.Windows.Interop.InteropBitmap; this.Image1.Source = my_ibs;
this is faster than the first solution, but still i can't manage to reach 30fps....am i doing something wrong? any suggestion?