views:

240

answers:

1

I am using SampleGrabber in DirectShow on windows 7, I noticed that the Code supplied by Microsoft and many other providers dont work because the Bitmap data header reports that bitmap data is compressed, however the new Bitmap(width, height, stride, pixelformat, scanlines) doesnt have any parameters to specify that the buffer has compressed image. Certainly Bitmap will not identify that.

SampleGrabber's media type gives Bitmap Info Header, which has compression equal to something and the data received is less then the bytes indicated by bitmap info header.

Createing bitmap just creates garbage of all sort.

It appears that I have Bitmap Info Header and Scanlines, but there is no way to create bitmap from (Compressed format) Bitmap Info header and scanlines in WPF.

I tried using CreateDIBSection etc, but GDI+ doesnt work correctly in WPF, everything returning zero, I also tried to initialize GDI etc but no clue what to do now.

A: 

Configure the sample grabber's media type (sampleGrabber.SetMediaType) with one that has its subType set as RGB24.

Then the data will come as an uncompressed bitmap data in your BufferCB callback.

開発者