Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using ImageScanner.Properties;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Diagnostics;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace ImageScanner
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void btnScan_Click(object sender, EventArgs e)
- {
- Stopwatch sw = new Stopwatch();
- sw.Start();
- Bitmap screenCapture = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
- Graphics g = Graphics.FromImage(screenCapture);
- g.CopyFromScreen(Screen.PrimaryScreen.Bounds.X,
- Screen.PrimaryScreen.Bounds.Y,
- 0, 0,
- screenCapture.Size,
- CopyPixelOperation.SourceCopy);
- Bitmap myPic = Resources.Capture;
- bool isInCapture = IsInCapture(myPic, screenCapture);
- sw.Stop();
- TimeSpan ts = sw.Elapsed;
- }
- private bool IsInCapture(Bitmap searchFor, Bitmap searchIn)
- {
- for (int x = 0; x < searchIn.Width; x++)
- {
- for (int y = 0; y < searchIn.Height; y++)
- {
- bool invalid = false;
- int k = x, l = y;
- for (int a = 0; a < searchFor.Width; a++)
- {
- l = y;
- for (int b = 0; b < searchFor.Height; b++)
- {
- if (searchFor.GetPixel(a, b) != searchIn.GetPixel(k, l))
- {
- invalid = true;
- break;
- }
- else
- l++;
- }
- if (invalid)
- break;
- else
- k++;
- }
- if (!invalid)
- return true;
- }
- }
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement