【发布时间】:2014-05-11 07:58:25
【问题描述】:
我已经编写了一个捕获图像并将其保存在特定文件夹中的代码。现在我需要通过其他线程访问此方法,但我不能,因为我已经使用从剪贴板获取数据。现在我需要重新用 WM_CAP_SAVEDIB 写代码。我以前看过这个链接:How to copy image without using the clipboard?,但我真的很困惑,因为我是编程新手。你能帮我在不使用剪贴板的情况下重写代码吗?
这是我需要从其他线程访问的方法:
#region Capture
public void CaptureFunc()
{
PhotoNo = PhotoNo + 1;
// get the next frame;
SendMessage(mCapHwnd, WM_CAP_GET_FRAME, 0, 0);
// copy the frame to the clipboard
SendMessage(mCapHwnd, WM_CAP_COPY, 0, 0);
tempObj = Clipboard.GetDataObject();
tempImg =(System.Drawing.Bitmap)tempObj.GetData(System.Windows.Forms.DataFormats.Bitmap);
Graphics graphics = Graphics.FromImage(tempImg);
// Create Directory & Save
CreateDir();
tempImg.Save(Path.Combine(Dirname,PhotoNo.ToString()) + ".jpeg", jgpEncoder, myEncoderParameters); }
#endregion
【问题讨论】:
-
你能帮我在 C# 中使用 WM_CAP_SAVEDIB 吗?