Hi,

I'm capturing an image from a video card into a buffer as a memory stream. the format is "BMP,which contains BITMAPFILEHEADER, BITMAPINFOHEADER and RGB24 raw data".
I then need to write it down as a BGR32.
I can do it the following code (basically, Marshal.copy) but this procedure is LONG AND S-L-O-W, and I have the feeling that the whole transformation is unnecessary.

Is there a faster, simple way to perform this conversion?
It looks to me as if I'm missing something very trivial...

Thanks

Code:
  Dim streamm As New MemoryStream(bBuffer)
   Dim img2 As Bitmap
   img2 = Image.FromStream(streamm)
   Dim buffer = New Byte(SharpStream.Width * SharpStream.Height * 4 - 1) {}
   Dim bmpData As Imaging.BitmapData = img2.LockBits(New Rectangle(0, 0, SharpStream.Width, SharpStream.Height), Imaging.ImageLockMode.ReadOnly, Imaging.PixelFormat.Format32bppRgb)
   Dim ptr As IntPtr = bmpData.Scan0
   Dim numBytes As Integer = bmpData.Stride * img2.Height
   Marshal.Copy(bmpData.Scan0, buffer, 0, buffer.length)
   img2.UnlockBits(bmpData)
   SharpStream.WriteFrame(True, buffer, 0, buffer.length)