public IAreaConfig GetAreaConfig() { mAreaConfig.ClearPoint(); win32.RECT rect = new win32.RECT(); rect.left = 0; rect.top = 0; rect.right = 0; rect.bottom = 0; mAreaConfig.Rect = rect; double x_rate = WidthRate1; double y_rate = HeightRate1; Point[] points = GetPoints(); switch (Type) { case ShapeType.Line: mAreaConfig.AreaType = TAreaType.Line; if (points != null && points.Length == 2) { rect.left = (int)((double)points[0].X * x_rate); rect.top = (int)((double)points[0].Y * y_rate); rect.right = (int)((double)points[1].X * x_rate); rect.bottom = (int)((double)points[1].Y * y_rate); mAreaConfig.Rect = rect; } break; case ShapeType.Rect: mAreaConfig.AreaType = TAreaType.Rect; if (points != null && points.Length == 2) { rect.left = (int)((double)points[0].X * x_rate); rect.top = (int)((double)points[0].Y * y_rate); rect.right = (int)((double)points[1].X * x_rate); rect.bottom = (int)((double)points[1].Y * y_rate); mAreaConfig.Rect = rect; } break; default: mAreaConfig.AreaType = TAreaType.Polygon; if (points != null) { foreach (Point point in points) { mAreaConfig.AddPoint((int)((double)point.X * x_rate), (int)((double)point.Y * y_rate)); } } break; } return(mAreaConfig); }
public void Draw(IntPtr handle, Rectangle destRect, int width, int height) { if (img == (IntPtr)0) { return; } if (win32.IsWindow(handle) == 0) { return; } if (win32.IsWindowVisible(handle) == 0) { return; } Rectangle dr = destRect; if (dr.IsEmpty) { win32.RECT wr = new win32.RECT(); win32.GetClientRect(handle, ref wr); dr.X = wr.left + 2; dr.Y = wr.top + 2; dr.Width = wr.right - 5; dr.Height = wr.bottom - 5; } if (dr.Width < 2 || dr.Height < 2) { return; } IntPtr memdc = win32gdi.CreateCompatibleDC((IntPtr)0); if (memdc == (IntPtr)0) { return; } IntPtr dc = win32gdi.GetDC(handle); if (dc != (IntPtr)0) { IntPtr oldbmp = win32gdi.SelectObject(memdc, img); win32gdi.SetStretchBltMode(dc, win32gdi.COLORONCOLOR); win32gdi.StretchBlt(dc, dr.Left, dr.Top, dr.Width, dr.Height, memdc, 0, 0, width, height, win32gdi.SRCCOPY); win32gdi.SelectObject(memdc, oldbmp); win32gdi.DeleteDC(memdc); win32gdi.ReleaseDC(handle, dc); } }
protected override bool PrepPlay() { if ((uint)mChannelHandle != 0xFFFFFFFF) { win32.RECT rect = new win32.RECT(); win32.GetClientRect(HWnd, ref rect); if (DS40xxSDKWrap.StartVideoPreview(mChannelHandle, HWnd, ref rect, true, TypeVideoFormat.vdfRGB24, mFps) == 0) { return(true); } } return(false); }
public static void PreviewImage(Image image, IntPtr hWnd) { if (image != null && hWnd != IntPtr.Zero) { try { win32.RECT rect = new win32.RECT(); win32.GetClientRect(hWnd, ref rect); Graphics graophics = Graphics.FromHwnd(hWnd); graophics.DrawImage(image, 0, 0, rect.right, rect.bottom); } catch (Exception e) { System.Console.Out.WriteLine("PreviewImage Error: " + e.Message); } } }
protected void DoDrawFun(int handle, IntPtr hDc, int user) { //Console.Out.WriteLine("HKDrawImage DoDrawFun handle = " + handle); if (IsDrawImage && HWnd != IntPtr.Zero) { lock (mImageAttrLockObj) { if (DrawImage != null) { win32.RECT rect = new win32.RECT(); win32.GetClientRect(HWnd, ref rect); Graphics g = Graphics.FromHdcInternal(hDc); g.DrawImage(DrawImage, new Rectangle(0, rect.bottom - 24, 24, 24), 0, 0, DrawImage.Width, DrawImage.Height, GraphicsUnit.Pixel, mImgAttributes); } } } }
public bool RefreshPlayArea() { if (IsOpen) { if (IsPlay) { if (DS40xxSDKWrap.StopVideoPreview(mChannelHandle) == 0) { win32.RECT rect = new win32.RECT(); win32.GetClientRect(HWnd, ref rect); if (DS40xxSDKWrap.StartVideoPreview(mChannelHandle, HWnd, ref rect, true, TypeVideoFormat.vdfRGB24, mFps) == 0) { return(true); } else { Stop(); } } return(false); } } return(true); }
public extern static int StartVideoPreview(IntPtr hChannelHandle, IntPtr WndHandle, ref win32.RECT rect, bool bOverlay, TypeVideoFormat VideoFormat, int FrameRate);
private void PlayPath() { if (mPlayPath != null && !mPlayPath.Equals("") && mHWnd != IntPtr.Zero && mGraphics != null) { try { win32.RECT rect = new win32.RECT(); win32.GetClientRect(mHWnd, ref rect); string[] files = Directory.GetFiles(mPlayPath, "*.dat"); if (files != null && files.Length > 0) { Bitmap bmp; float progress = 0; Array.Sort(files, new FileComparer(true)); Stopwatch sw = new Stopwatch(); sw.Start(); for (int i = 0; i < files.Length; i++) { if (IsExit) { Progress = 100; break; } bmp = new Bitmap(files[i]); if (bmp != null) { try { mGraphics.DrawImage(bmp, 0, 0, rect.right, rect.bottom); } finally { bmp.Dispose(); } } progress += 1; Progress = (int)(progress / files.Length * 100); if (Progress == 100) { break; } sw.Stop(); int n = 40 - (int)sw.ElapsedMilliseconds; if (n > 0) { Thread.Sleep(n); } sw.Reset(); sw.Start(); } sw.Stop(); } } catch (Exception e) { System.Console.Out.WriteLine("PlayPath Exception: {0}", e); //throw e; } } }
private void PlayImages() { if (mImages != null && mHWnd != IntPtr.Zero && mGraphics != null) { try { win32.RECT rect = new win32.RECT(); win32.GetClientRect(mHWnd, ref rect); float progress = 0; Stopwatch sw = new Stopwatch(); sw.Start(); Bitmap bmp; foreach (ImageWrap image in mImages) { if (IsExit) { Progress = 100; break; } if (image != null) { bmp = image.CopyImage(); if (bmp != null) { try { mGraphics.DrawImage(bmp, 0, 0, rect.right, rect.bottom); } finally { bmp.Dispose(); } } } progress += 1; Progress = (int)(progress / mImages.Count * 100); if (Progress == 100) { break; } sw.Stop(); int n = 40 - (int)sw.ElapsedMilliseconds; if (n > 0) { Thread.Sleep(n); } sw.Reset(); sw.Start(); } sw.Stop(); } catch (Exception e) { System.Console.Out.WriteLine("PlayImages Exception: {0}", e); //throw e; } } }
private static void PlayImages(ThreadContext threadContext) { if (threadContext.HWnd != IntPtr.Zero) { try { win32.RECT rect = new win32.RECT(); win32.GetClientRect(threadContext.HWnd, ref rect); Graphics graphics = threadContext.CurGraphics; if (graphics == null) { return; } float progress = 0; Stopwatch sw = new Stopwatch(); sw.Start(); Bitmap bmp; foreach (ImageWrap image in threadContext.Images) { if (threadContext.IsExit) { threadContext.Progress = 100; break; } if (image != null) { bmp = image.CopyImage(); if (bmp != null) { try { graphics.DrawImage(bmp, 0, 0, rect.right, rect.bottom); } finally { bmp.Dispose(); } } } progress += 1; threadContext.Progress = (int)(progress / threadContext.Images.Count * 100); sw.Stop(); int n = 40 - (int)sw.ElapsedMilliseconds; if (n > 0) { Thread.Sleep(n); } sw.Reset(); sw.Start(); } sw.Stop(); } catch (Exception e) { System.Console.Out.WriteLine("PlayImages Exception: {0}", e); } } }