private void OnUpdate() { if (m_ObservedScreen != null) { lock (ScreenStateThread.ScreenBmpLock) lock (m_ObservedScreenLock) { BitmapUtility.Clone32BPPBitmap(ScreenStateThread.ScreenBmp, m_ObservedScreen); } } Invalidate?.Invoke(); }
public void StartNewImageSearch(Bitmap sampleImage) { lock (m_SampleImageLock) { var clonedSampleImage = new Bitmap(sampleImage.Width, sampleImage.Height); m_SampleImage = BitmapUtility.Clone32BPPBitmap(sampleImage, clonedSampleImage); WasLastCheckSuccess = false; WasImageFound = false; LastKnownPositions = null; TimeSinceLastFind = 0; m_Watch.Restart(); } }
protected override void ThreadAction() { Profiler.Start(Name); Profiler.Start(Name + "_TakeScreenshot"); BitmapUtility.TakeScreenshot(m_TempBitmap); Profiler.Stop(Name + "_TakeScreenshot"); Profiler.Start(Name + "_CloneBitmap"); lock (ScreenBmpLock) { BitmapUtility.Clone32BPPBitmap(m_TempBitmap, ScreenBmp); } Profiler.Stop(Name + "_CloneBitmap"); Profiler.Stop(Name); }
protected override void ThreadAction() { if (ObservedImage == null) { return; } if (m_SampleImage == null) { return; } Profiler.Start(Name); Profiler.Start(Name + "_CloneScreen"); lock (ScreenStateThread.ScreenBmpLock) { BitmapUtility.Clone32BPPBitmap(ScreenStateThread.ScreenBmp, ObservedImage); } Profiler.Stop(Name + "_CloneScreen"); Profiler.Start(Name + "_FindMatch"); var points = FindImagePositions(); var success = ValidatePointsCorrectness(points); Profiler.Stop(Name + "_FindMatch"); if (success) { PositionFound?.Invoke(points); LastKnownPositions = points; WasImageFound = true; WasLastCheckSuccess = true; TimeSinceLastFind = 0; m_Watch.Restart(); } else { WasLastCheckSuccess = false; TimeSinceLastFind = (int)m_Watch.ElapsedMilliseconds; } Profiler.Stop(Name); }