【发布时间】:2015-06-28 14:49:24
【问题描述】:
我的图形对象确实存在以下问题。
编辑:
我确实有一个图片框图像 (imageRxTx),它是来自相机的实时流。我在绘画事件中所做的是在图像 imageRxTx 顶部绘制一些线条(下面的代码中未显示)。到目前为止,这没有问题。
现在我需要检查 imageRxTx 中的圆圈,因此我必须使用需要位图作为参数的方法 ProcessImage()。不幸的是,我没有位图图像,而是我的 imageRxTx 的句柄 (hDC)。
问题:如何从我的图形对象中获取 imageRxTx 并将其“转换”为我需要在方法 ProcessImage(Bitmap bitmap)?需要在绘画事件中不断调用此方法,以检查我的相机 (imageRxTx) 的实时流。
这是我的代码:
private void imageRxTx_paint(object sender, PaintEventArgs e)
{
var settings = new Settings();
// Create a local version of the graphics object for the PictureBox.
Graphics Draw = e.Graphics;
IntPtr hDC = Draw.GetHdc(); // Get a handle to image_RxTx.
Draw.ReleaseHdc(hDC); // Release image_RxTx handle.
//Here I need to send the picturebox_image 'image_RxTx' to ProcessImage as Bitmap
AForge.Point center = ProcessImage( ?....? );
}
// Check for circles in the bitmap-image
private AForge.Point ProcessImage(Bitmap bitmap)
{
//at this point I should read the picturebox_image 'image_RxTx'
...
视频图像在此更新:
private void timer1_Elapsed(object sender, EventArgs e)
{
// If Live and captured image has changed then update the window
if (PIXCI_LIVE && LastCapturedField != pxd_capturedFieldCount(1))
{
LastCapturedField = pxd_capturedFieldCount(1);
image_RxTx.Invalidate();
}
}
【问题讨论】: