Sample Image:
I'm using DirectShow.net to get webcam footage into my program. To accomplish this, I'm adding the source camera to the graph, and a VideoMixingRenderer9.
That part is all working swimmingly, but the part where I extract a frame using GetCurrentImage(out lpDib) is having what I can only describe as an odd issue.
What I am doing is using Marshal.PtrToSTructure to create a BitmapInfoHeader from lpDib, then calculating the width / height / stride / & pixel format.
The problem comes when I look at the image stored in bitmap - It has a 10 px wide line down the left side that came from what is actually the right!
It is worth noting that the data I am getting from the GetCurrentImage call is actually upside down - note the call to Cap.RotateFlip.
IntPtr lpDib;
windowlessCtrl.GetCurrentImage(out lpDib);
BitmapInfoHeader head;
head = (BitmapInfoHeader)Marshal.PtrToStructure(lpDib, typeof(BitmapInfoHeader));
int width = head.Width;
int height = head.Height;
int stride = width * (head.BitCount / 8);
PixelFormat pixelFormat = PixelFormat.Format24bppRgb;
switch (head.BitCount)
{
case 24: pixelFormat = PixelFormat.Format24bppRgb; break;
case 32: pixelFormat = PixelFormat.Format32bppRgb; break;
case 48: pixelFormat = PixelFormat.Format48bppRgb; break;
default: throw new Exception("Unknown BitCount");
}
Cap = new Bitmap(width, height, stride, pixelFormat, lpDib);
Cap.RotateFlip(RotateFlipType.RotateNoneFlipY);
//if we examine Cap here (Cap.Save, for example) I'm seeing the odd stripe.
I'm completely lost here. Seems like some sort of offset issue, and I've tried tweaking with stride some, but to no avail (just creates odd diagonal look).