public string GetPreview() { ScreenCapture sc = new ScreenCapture(); Bitmap b = (Bitmap)sc.CaptureScreen(); { Rectangle cropRect = new Rectangle(browser.PointToScreen(Point.Empty), browser.Size); Bitmap src = b; Bitmap target = new Bitmap(cropRect.Width, cropRect.Height); using (Graphics g = Graphics.FromImage(target)) { g.DrawImage(src, new Rectangle(0, 0, target.Width, target.Height), cropRect, GraphicsUnit.Pixel); } b = target; } using (Image image = b) { using (MemoryStream m = new MemoryStream()) { image.Save(m, ImageFormat.Tiff); byte[] imageBytes = m.ToArray(); // Convert byte[] to Base64 String string base64String = Convert.ToBase64String(imageBytes); return(base64String); } } }
public NuGenScreenCap() { InitializeComponent(); p = new Pen(Color.Black); p2 = new Pen(Color.White); p.DashCap = p2.DashCap = DashCap.Flat; p.DashStyle = p2.DashStyle = DashStyle.Custom; p.DashPattern = p2.DashPattern = new float[] { 4, 4 }; Color c = Color.Blue; c = Color.FromArgb(20, c.R, c.G, c.B); b = new SolidBrush(c); coordsBrush = new SolidBrush(coordsColor); this.redrawTimer.Start(); //Get the initial screen shot ScreenCapture sc = new ScreenCapture(); Bitmap img = sc.CaptureScreen(); if (this.Bitmap != null) { this.Bitmap.Dispose(); } this.Bitmap = img; if (autoSizeParentForm) { SetupParentForm(); } this.saveFileDialog.Filter = "Bitmap Files|*.bmp|JPEG Files|*.jpeg|PNG Files|*.png|GIF Files|*.gif|TIFF Files|*.tiff|Icon Files|*.ico"; }
/// <summary> /// 调整到输入法到英文状态 /// </summary> private void ToEnglish() { Boolean is_English = false; ScreenCapture SC = new ScreenCapture(); Image image = SC.CaptureScreen(2414, 1411, 20, 20); //抓取屏幕(层叠的窗口) string md5 = Md5.Md5.Get_imageMd5(image); //Console.WriteLine(md5); //2ff940e2ff8e4e79fc394494b489a935 中文 switch (md5) { case "2ff940e2ff8e4e79fc394494b489a935": is_English = true; break; case "333333333333": is_English = true; break; default: break; } if (is_English) { keybd_event(161, 0, 0, 0); //按下shift keybd_event(161, 0, 2, 0); //放开shift } }
public async void CaptureActiveScreen() { try { if (IsInternetConnected) { var result = UploadDataOnCloud(); } ScreenCapture obj = new ScreenCapture(); Image image = obj.CaptureScreen(); string ImageName = DateTime.Now.ToString("yyyyMMddHHmmss"); // case sensitive SaveImageLocal(ImageLocalPath, ImageName, image); //objLocal.InsertImage(DateTime.Now, MacId, ImageName, "0", ImageStream); await Task.Delay(TimeSpan.FromSeconds(3)); } catch (Exception e) { ErrorLog.WriteToFile("Exception while CaptureActiveScreen......."); ErrorLog.ErrorLogging(e); //write log informations } }
public static void CaptureScreen() { // Safe to create the directory // Determine whether the directory exists. if (!Directory.Exists(DIR_PATH)) { // Try to create the directory. DirectoryInfo di = Directory.CreateDirectory(DIR_PATH); } // Retrieve Active Window Name string title = GetActiveWindowTitle(); // Take Image Image img = sCapture.CaptureScreen(); // Naming Int32 unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; string fileName = unixTimestamp.ToString() + "_" + title + ".png"; fileName = MakeValidFilename(fileName); // Save Image sCapture.CaptureWindowToFile(DIR_PATH + "/" + fileName, ImageFormat.Png); }
public IResponsePayload <byte[]> Execute(Request request) { var image = screenCapture.CaptureScreen(); using var ms = new MemoryStream(); image.Save(ms, ImageFormat.Jpeg); return(new BytesResponsePayload(true, ms.ToArray(), new ResponseMetadata(GetType()))); }
//Metoda kojom radimo screenshot i šaljemo ga serveru private static void ScreenshotPacketHandler(Socket clientSocket) { ScreenCapture sc = new ScreenCapture(); Image img = sc.CaptureScreen(); ScreenshotPackage screenShotPackage = new ScreenshotPackage(img); clientSocket.Send(screenShotPackage.ToByteArray()); }
public static bool IsTradeAccepted() { Bitmap src = ScreenCapture.CaptureScreen(); Bgr low = new Bgr(12, 40, 0); Bgr high = new Bgr(50, 70, 41); return(OpenCV_Service.InColorRange(src, low, high)); }
/// <summary> /// Crea una captura de pantalla completa usando ScreenCapture(); /// </summary> /// <param name="filepath"></param> /// <param name="filename"></param> /// <param name="format"></param> public void FullScreenshotWithClass(String filepath, String filename, ImageFormat format) { ScreenCapture sc = new ScreenCapture(); Image img = sc.CaptureScreen(); string fullpath = filepath + "\\" + filename; img.Save(fullpath, format); }
public static byte[] GetScreen(int compression = 50) { ScreenCapture sc = new ScreenCapture(); Image img = sc.CaptureScreen(); using (MemoryStream ms = Compress.DoIt(img, compression)) { return(ms.ToArray()); } }
public static void HandleTakeScreenshot(PaceClient client, IPacket packet) { var screenshot = ScreenCapture.CaptureScreen(); byte[] screenshotBytes = ScreenCapture.ImageToBytes(screenshot); var screenshotResponsePacket = new TakeScreenshotResponsePacket(screenshotBytes); client.SendPacket(screenshotResponsePacket); }
public void CaptureScreenTest() { Image image = null; Assert.DoesNotThrow(delegate { image = _screenCapture.CaptureScreen(); }); Assert.NotNull(image); }
public string SnapScreenshot() { ScreenCapture sc = new ScreenCapture(); // capture entire screen, and save it to a file Image img = sc.CaptureScreen(); // display image in a Picture control named imageDisplay this.imageDisplay.Image = img; // capture this window, and save it sc.CaptureWindowToFile(this.Handle, "C:\\temp2.gif", ImageFormat.Gif); }
public void CaptureScreen() { ScreenCapture sc = new ScreenCapture(); Bitmap img = sc.CaptureScreen(); if (this.Bitmap != null) { this.Bitmap.Dispose(); } this.Bitmap = img; }
private string SaveErrorScreenshot() { var errorImageFileName = Settings.Default.LogsFolderPath + @"\" + "FATAL_ERROR_" + DateTime.Now.ToFileTime().ToString() + ".png"; var errMsg = "Image file: " + errorImageFileName; ScreenCapture sc = new ScreenCapture(); Image img = sc.CaptureScreen(); img.Save(errorImageFileName, ImageFormat.Png); return(errMsg); }
private bool ValidateFarmTabs() { // Detect Stash if (!_StashHelper.OpenStash()) { _loggerService.Log($"{MethodBase.GetCurrentMethod().Name} Stash is not found in the area."); return(false); } var lTabs = OpenCV_Service.GetText(ScreenCapture.CaptureScreen()); return(true); }
public static byte[] GetSnapshot() { ScreenCapture sc = new ScreenCapture(); Image img = sc.CaptureScreen(); img = ScreenCapture.ResizeImage(img, img.Width / 4 * 2, img.Height / 4 * 2); MemoryStream stream = new MemoryStream(); img.Save(stream, ImageFormat.Png); img.Dispose(); return(stream.ToArray()); }
private void button2_Click(object sender, System.EventArgs e) { this.Hide(); f = new frmCapture(); ScreenCapture sc = new ScreenCapture(); Image img = sc.CaptureScreen(); this.Show(); f.Image = img; f.Show(); f.Focus(); }
public void FullScreenshotWithClass(String filepath, String filename, ImageFormat format) { filename = uploadTemp.Numero_imagen + filename; ScreenCapture sc = new ScreenCapture(); Image img = sc.CaptureScreen(); string fullpath = filepath + "\\" + filename; uploadTemp.Imagen = img; uploadTemp.Nombre_imagen = filename; uploadTemp.Ruta_destino = fullpath; uploadTemp.AsignarImagen(img, filename); img.Save(fullpath, format); }
public ScreenCaptureWindow() { var fullScreenSize = GetFullScreenSize(); var fullScreenSizeWithMargin = GetFullScreenSizeWithMargin(fullScreenSize, m_Margin); m_ScreenImage = ScreenCapture.CaptureScreen(fullScreenSize.X, fullScreenSize.Y, fullScreenSize.Width, fullScreenSize.Height); m_ScreenImageWithMargin = ScreenCapture.CaptureScreen(fullScreenSizeWithMargin.X, fullScreenSizeWithMargin.Y, fullScreenSizeWithMargin.Width, fullScreenSizeWithMargin.Height); InitializeComponent(); SetSize(fullScreenSize); Background = new ImageBrush(Extensions.ImageSourceFromBitmap(m_ScreenImage)); m_ColorPickerViewModel = (ColorViewModel)ColorPicker.DataContext; }
private void GetScreen() { isSendVideo = true; Bitmap background; int numberImage = 0; timer = new Timer { Interval = 10 }; timer.Tick += (s, e) => { background = ScreenCapture.CaptureScreen(true); handler.SendImage(background, numberImage++); }; timer.Start(); }
private bool CardExists(IntPtr wndHandle, int posX, int posY) { const double initialSize = 40; // 40px @ height = 1080 const double minHue = 90; int size = (int)Math.Round(initialSize * WindowYRatioTo1080); var capture = ScreenCapture.CaptureScreen(wndHandle, new Point(posX, posY), size, size); if (capture == null) { return(false); } return(capture.GetAvgHue() > minHue); }
private void FuncCommandExecute() { //runflag = true; //stepnum = 0; //System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcessesByName("USBKB");//获取指定的进程名 //if (myProcesses.Length >= 1) //如果可以获取到知道的进程名则说明已经启动 //{ // var image = screenCapture.CaptureWindow(myProcesses[0].MainWindowHandle); var image = screenCapture.CaptureScreen(); var bitmap = new System.Drawing.Bitmap(image); CameraIamge = ImageConventer.ConvertBitmapToHalconImage(bitmap); //} }
private void TakeScreenshot() { var sc = new ScreenCapture(); var img = sc.CaptureScreen(); var stream = new MemoryStream(); img.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp); var image = new BitmapImage(); image.BeginInit(); image.StreamSource = stream; image.EndInit(); pictures.Add(image); }
/// <summary> /// 窗口指定区域截图 /// </summary> public void Window_specified_area_screenshot() { ScreenCapture SC = new ScreenCapture(); Image image = SC.CaptureScreen( int.Parse(textBox_x.Text), int.Parse(textBox_y.Text), int.Parse(textBox_width.Text), int.Parse(textBox_height.Text) ); Get_Md5 gm = new Get_Md5(); this.pictureBox_cut.Image = image; //07b48a26a5f2a8880e3c7de8352eedfc 英文 //0aae315c797b865c53fd40393540afea 中文 Console.WriteLine(gm.Get_imageMd5(image)); }
private void Snapshot_Click(object sender, EventArgs e) { ScreenCapture sc = new ScreenCapture(); // capture entire screen, and save it to a file Image img = sc.CaptureScreen(); // capture this window, and save it sc.CaptureWindowToFile(this.Handle, FILE_SAVE_PATH + graphName + ".png", ImageFormat.Png); notifyIcon.Visible = true; notifyIcon.BalloonTipTitle = "Movement Diagnose Data"; notifyIcon.Icon = SystemIcons.Application; notifyIcon.BalloonTipText = "Screenshot created succesfully"; notifyIcon.ShowBalloonTip(300); }
private void buttonCapture_Click(object sender, EventArgs e) { this.WindowState = FormWindowState.Minimized; ScreenCapture sc = new ScreenCapture(); string fn = string.Format(textInputMask.Text, 0); string dir = Path.GetDirectoryName(fn); Directory.CreateDirectory(dir); dir += @"\capturelog.txt"; StreamWriter log = new StreamWriter(new FileStream(dir, FileMode.Create)); Image im; Stopwatch sw = new Stopwatch(); Thread.Sleep(200); int frameNo = 0; long msCurrent; // time of the next capture in milliseconds long msTotal = (long)((double)numericDuration.Value * 1000.0); sw.Reset(); sw.Start(); do { im = sc.CaptureScreen(); fn = string.Format(textInputMask.Text, frameNo++); im.Save(fn, ImageFormat.Png); msCurrent = (long)(frameNo * 1000.0 / (double)numericFps.Value); long msSleep = msCurrent - sw.ElapsedMilliseconds; if (msSleep > 0) { log.WriteLine("Frame {0:0000}: sleeping {1} ms", frameNo, msSleep); Thread.Sleep((int)msSleep); } else { log.WriteLine("Frame {0:0000}: busy! ({1} ms)", frameNo, msSleep); } }while (sw.ElapsedMilliseconds < msTotal); labelSpeed.Text = string.Format("Captured {0} frames in {1:f} s!", frameNo, (float)(sw.ElapsedMilliseconds * 0.001)); log.Close(); sw.Stop(); this.WindowState = FormWindowState.Normal; }
public void SendRemoteScreen() { while (EnableRemoteControl) { try { //Thread.Sleep(1000 / 30); //30fps is max speed we can get... Bitmap ScreenImage = ScreenCapture.CaptureScreen(); byte[] ScreenBytes = ScreenCapture.BitmapToBytes(ScreenImage); GC.Collect(); FileTransfer info = new FileTransfer(); info.type = -1; //-1 = monitor spy SendFile(info, ScreenBytes, S_FileTransferSendBegin.SendType.MonitorSpy); } catch {} } }
private void NuGenScreenCap_Load(object sender, EventArgs e) { //Get the initial screen shot ScreenCapture sc = new ScreenCapture(); Bitmap img = sc.CaptureScreen(); if (this.Bitmap != null) { this.Bitmap.Dispose(); } this.Bitmap = img; if (autoSizeParentForm) { SetupParentForm(); } }
static void sendScreenshot()//very very slight memory leak here... { Console.WriteLine("Running screenshot sender..."); ScreenCapture sc = new ScreenCapture(); Image img = sc.CaptureScreen(); Console.WriteLine("screenshot saved."); if (img == null) { Console.WriteLine("Image is null!"); } ImageConverter imageConverter = new ImageConverter(); byte[] imageBytes = (byte[])imageConverter.ConvertTo(img, typeof(byte[])); Console.WriteLine("Starting screenshot send..."); openSock.Send(imageBytes); Console.WriteLine("Send completed."); img.Dispose(); }
public void KeepCapturing() { while (true) { Console.WriteLine("DEBUG: Server--> Entra nel While"); ScreenCapture sc = new ScreenCapture(); // capture entire screen img = sc.CaptureScreen(); img1 = (Image)img.Clone(); padre.setImage(img1); //if (img != null) //If you choosed an image //{ //videoServer.SendImage(img); //Send the image this.SendImage(img); //} } }
private void TakeScreenshot(TimeSpan awayTime) { var sc = new ScreenCapture(); var img = sc.CaptureScreen(); try { img.Save(String.Format(@"{0}\{1} - {2}.jpg", Today, DateTime.Now.ToString("HH mm"), String.Format("{0}m", awayTime.Minutes))); } finally { img.Dispose(); } }
public static List<ScreenZone> Get(List<ScreenZone> ScreenZones) { var sc = new ScreenCapture(); Image image = sc.CaptureScreen(); var sections = new List<Section>(); sections.Add(new Section { Name = "Top", Width = image.Width, Height = Convert.ToInt32(image.Height*0.1d), X = 0, Y = 0, Bitmap = new Bitmap(image.Width, Convert.ToInt32(image.Height*0.1d)), }); sections.Add(new Section { Name = "Left", Width = Convert.ToInt32(image.Width*0.1d), Height = image.Height, X = 0, Y = 0, Bitmap = new Bitmap(Convert.ToInt32(image.Width*0.1d), image.Height) }); sections.Add(new Section { Name = "Right", Width = Convert.ToInt32(image.Width*0.1d), Height = image.Height, X = image.Width - Convert.ToInt32(image.Width*0.1d), Y = 0, Bitmap = new Bitmap(Convert.ToInt32(image.Width*0.1d), image.Height), }); sections.Add(new Section { Name = "Bottom", Width = image.Width, Height = Convert.ToInt32(image.Height*0.1d), X = 0, Y = image.Height - Convert.ToInt32(image.Height*0.1d), Bitmap = new Bitmap(image.Width, Convert.ToInt32(image.Height*0.1d)) }); foreach (Section section in sections) { var bm = new Bitmap(sc.CaptureScreen(section)); bm.Dispose(); bm = null; section.Bitmap = new Bitmap(sc.CaptureScreen(section)); section.Bitmap.Save(section.Name + ".bmp"); using (var bmp = new Bitmap(1, 1)) { using (Graphics g = Graphics.FromImage(bmp)) { // updated: the Interpolation mode needs to be set to // HighQualityBilinear or HighQualityBicubic or this method // doesn't work at all. With either setting, the results are // slightly different from the averaging method. g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.DrawImage(section.Bitmap, new Rectangle(0, 0, 1, 1)); } Color pixel = bmp.GetPixel(0, 0); // pixel will contain average values for entire orig Bitmap section.AvgRed = pixel.R; section.AvgBlue = pixel.B; section.AvgGreen = pixel.G; //section.Dispose(); } } foreach (ScreenZone screenZone in ScreenZones) { Section tempScetion = sections.Where(x => x.Name.Equals(screenZone.Name)).Select(x => x).FirstOrDefault(); if (tempScetion != null) { screenZone.Color = Color.FromArgb(tempScetion.AvgRed, tempScetion.AvgGreen, tempScetion.AvgBlue); } } sc = null; sections = null; image.Dispose(); image = null; GC.Collect(); GC.WaitForPendingFinalizers(); return ScreenZones; }