简体   繁体   中英

How to load a bitmap from file into the samples buffer

I am trying to add text to the bitmaps i get from directshow filter. First I tried using gdiplus but that didn't work. So now i just call a .Net program that manipulates the bitmap.

The problem is that I don't know how to reload the bitmap from a file into the samples buffer in directshow.

Here's my code:

Bitmap bmp(640, 480, 2560, 139273, newBuffer);
//save
CLSID pngClsid;
GetEncoderClsid(L"image/png", &pngClsid);
WCHAR* file = L"D:\\TEMP\\sample.bmp";
bmp.Save(file, &pngClsid, NULL);

std::string command("D:\\yourcontrol\\bitmapDraw.exe D:\\TEMP\\sample.bmp \"test text\" D:\\yourcontrol\\out.bmp");
//manipulate
system(command.c_str());

//load
Bitmap bmp2(D:\\yourcontrol\\out.bmp");

How do I forward the bitmap from file to the sample?

Media samples are a part of the agreement between filters, on specific pin connection. You normally don't load media samples unless you run a filter and you are delivering data on its output pin.

In latter case you have media type of media samples, you allocate and initialize the media samples, and your task is straightforward: to load image, get access to its data, memcpy into media sample buffer making sure media type matches the image format (or you are responsble to convert otherwise). Once you're done you deliver the media sample as you usually do it ( PushSource Filter is the closest sample on Windows SDK).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM