位图数据乱码显示

Garbled display of bitmap data

这是我第一次发帖,请多多包涵。 我对 Directshow 和 C++ 编程还很陌生,但在花了几个小时寻找这个具体答案后,我忍不住要在这里问我的问题。

我正在研究 Viveks 著名的 VCam 样本。它源自 Directshow Pushsource 示例,因此我认为显示 Pushsource 示例可以正常显示的 bmp 应该是可行的。

根据此来源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++

所以我做错了什么,一遍又一遍地检查样本的所有步骤,但看不出有什么区别。 这是我所做的: 1.加载位图 2.将位图复制到缓冲区 3.使用memcpy将缓冲区复制到FillBuffer方法中。

但我得到的是这个与这个相比。

original and distortion

我使用的每个位图的输出看起来都不一样,所以我可以看到数据随图像而变化。但由于某种原因,它没有被识别为位图。

我完全没思路了。所以我很高兴收到一些关于我做错的建议。

那是经典之作。 image stride in your MediaType. Here is a question with the same problem: whosebug.com/a/20054011/399561

有问题