using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Emgu.CV; using Emgu.CV.Structure; using bbiwarg.Utility; namespace bbiwarg.Images { public enum TouchImageState { none = 0, touchArea = 1, touchAreaMatched = 2, touchAreaStatusBar = 3, touchDetected = 4, touchTracked = 5 } class TouchImage { private Image image; private List oldTouches; public TouchImage(int width, int height) { image = new Image(width, height); oldTouches = new List(); } public void setTouchAt(int x, int y, TouchImageState tis) { image.Data[y, x, 0] = (byte)tis; int size = 5; if (tis == TouchImageState.touchTracked || tis == TouchImageState.touchDetected) { for (int i = x - size; i < x + size; i++) { for (int j = y - size; j < y + size; j++) { if (i >= 0 && j >= 0 && i <= image.Width && j <= image.Height && Math.Sqrt(((x - i) * (x - i)) + ((y - j) * (y - j))) <= size) { image.Data[j, i, 0] = (byte)tis; } } } } } public TouchImageState getStateAt(int x, int y) { return (TouchImageState)image.Data[y, x, 0]; } } }