none
"Not enough storage is available to process this command" exception on BitmapSource.Create RRS feed

  • Question

  • Hello all,

    i've been developing an application that uses Directshow Sample grabber to take snapshots from a video capture and to show it in a WPF control and save it to a local file. I'm using VS2010. Every thing went fine in the development and tests, except when i tried the app in a non-development computer with Windows 7 installed. I caught this exception on application logs:

    System.ArgumentException: Not enough storage is available to process this command.  ---> System.Runtime.InteropServices.COMException (0x88982F8C): Excepção de HRESULT: 0x88982F8C
       em System.Windows.Media.Imaging.CachedBitmap.InitFromMemoryPtr(Int32 pixelWidth, Int32 pixelHeight, Double dpiX, Double dpiY, PixelFormat pixelFormat, BitmapPalette palette, IntPtr buffer, Int32 bufferSize, Int32 stride)
       em System.Windows.Media.Imaging.BitmapSource.Create(Int32 pixelWidth, Int32 pixelHeight, Double dpiX, Double dpiY, PixelFormat pixelFormat, BitmapPalette palette, IntPtr buffer, Int32 bufferSize, Int32 stride)
    Snapshot.Views.SnapshotBasic.SetSnapshot() 

    The code that generates this exception follows

    byte[] imageBytes = new byte[w * h * b_];
            
    unsafe
    {
      byte* origin = (byte*)pBuffer.ToPointer();
      for (int target = (h - 1) * s; target >= 0; target -= s)
      {
         Marshal.Copy((IntPtr)origin, imageBytes, target, s);
         origin += s;
       }
      }
    
    byte[] rawImageData = imageBytes;
    
    
    PixelFormat pf = PixelFormats.Bgr24;
    int width = 640;
    int height = 480;
    int rawStride = (width * pf.BitsPerPixel) / 8;
    
    BitmapSource bitmapSource = BitmapSource.Create(width,
                                height,
                                96,
                                96,
                                pf,
                                null,
                                rawImageData,
                                rawStride);
    
            
    

    I've tried to use an overload of BitmapSource.Create with the same results. Would there be something missing in the the non development computer ? How can't seem to sort this out easily.

    Thank you,

    Francisco

     

    Tuesday, September 28, 2010 11:03 AM

All replies