Tyrone
Tyrone

Reputation: 3

Garbled display of bitmap data

This is my first posting, so please bear with me. I am pretty new to Directshow and C++ programming but after spending hours after hours looking for this specific answer, I cannot help but asking my question here.

I am working on Viveks famous VCam sample. It is derived from the Directshow Pushsource sample so i thought it should be workable to display a bmp which the Pushsource Sample displays fine.

According to this source https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/11560cfc-41cc-4586-ada5-c1847b27b3f6/vcamax-input?forum=windowsdirectshowdevelopment the magic happens in the FillBuffer method. So I followed the Pushsource sample accordingly to load a bitmap but all I get is garbled output similar as it is shown here: ISampleGrabber::BufferCB to IplImage; display in OpenCV shows garbled image - C++

So I am doing something wrong and went through all steps of the samples again and again but cannot see much difference. Here is what I do: 1. Load a bitmap 2. Copy the bitmap into a buffer 3. Copying the buffer into the FillBuffer method with memcpy.

But what I get is this compared to this.

original and distortion

The output looks different with every bitmap I use, so I can see that the data changes with the images. But for some reason it does not get recognized as bitmap.

I am completely out of ideas. So I would be glad to receive some suggestions what I am doing wrong.

Upvotes: 0

Views: 158

Answers (1)

CPlusSharp
CPlusSharp

Reputation: 891

That's a classic one. You have problems wit the image stride in your MediaType. Here is a question with the same problem: stackoverflow.com/a/20054011/399561

Upvotes: 1

Related Questions