开发者

Overlaying Text with transparent background on a 24bit webcam feed

I'm using the DirectShow.Net library to display a feed from a web cam. I've created the capture graph with an ISampleGrabber interface which uses a callback containing a pointer to the video frame buffer. I use this pointer to create a .net bitmap, and Graphics object which I use to ove开发者_如何学编程rlay some red text with the method Graphics.DrawString. This takes a Brush object parameter. When I draw the text, it gets displayed in multicolors instead of red. The Brush is correct because I'm using the preset Brushes.Red. At the moment I reckon this is caused by the fact that the Brush is painting in 32bpp but the web cam image is 24bpp. I could create a temporary 24bpp bitmap, draw the text onto that, then overlay it on the video frame, but this wont give me text with a transparent background.

Any ideas? (easy ones are more preferable)

Thanks


I think there is a solution: Create a new Bitmap with 32bpp, use this bitmap graphics to draw the webcam image on it "Graphics.FromImage(ourNewBitmap).Draw(theWebcam24Image)", and use the same graphics to draw the string, after that create a new 24 bitmap and draw our generated bitmap to it then append the last generated image to the webcam.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜