private List <Color> GetOutOfBattleDetectionColors(TemtemWindowData windowData, User32.POINT lpPoint) { List <Color> detectionSpotColors = new List <Color>(); using (Bitmap pixel = new Bitmap(1, 1, PixelFormat.Format32bppArgb)) { using (Graphics g = Graphics.FromImage(pixel)) { for (int i = 4; i < 6; i++) { g.CopyFromScreen(new Point(lpPoint.X + windowData.detectionSpots[i].X, lpPoint.Y + windowData.detectionSpots[i].Y), new Point(0, 0), pixel.Size); detectionSpotColors.Add(pixel.GetPixel(0, 0)); } } } return(detectionSpotColors); }
private void RecalculateDetectionElements(TemtemWindowData windowData, Rectangle gameWindowRect) { //For loading the detection spots ScreenConfig screenConfig; screenConfig = ConfigLoader.GetConfigForAspectRatio(config, windowData.gameWindowSize); double spot1WidthPercentage = screenConfig.spot1WidthPercentage; double spot1HeightPercentage = screenConfig.spot1HeightPercentage; double spot2WidthPercentage = screenConfig.spot2WidthPercentage; double spot2HeightPercentage = screenConfig.spot2HeightPercentage; double spot3WidthPercentage = screenConfig.spot3WidthPercentage; double spot3HeightPercentage = screenConfig.spot3HeightPercentage; double spot4WidthPercentage = screenConfig.spot4WidthPercentage; double spot4HeightPercentage = screenConfig.spot4HeightPercentage; double spot5WidthPercentage = screenConfig.spot5WidthPercentage; double spot5HeightPercentage = screenConfig.spot5HeightPercentage; double spot6WidthPercentage = screenConfig.spot6WidthPercentage; double spot6HeightPercentage = screenConfig.spot6HeightPercentage; //Create points for the spots windowData.detectionSpots = new List <Point> { new Point((int)Math.Ceiling(spot1WidthPercentage * gameWindowRect.Width), (int)Math.Ceiling(spot1HeightPercentage * gameWindowRect.Height)), new Point((int)Math.Ceiling(spot2WidthPercentage * gameWindowRect.Width), (int)Math.Ceiling(spot2HeightPercentage * gameWindowRect.Height)), new Point((int)Math.Ceiling(spot3WidthPercentage * gameWindowRect.Width), (int)Math.Ceiling(spot3HeightPercentage * gameWindowRect.Height)), new Point((int)Math.Ceiling(spot4WidthPercentage * gameWindowRect.Width), (int)Math.Ceiling(spot4HeightPercentage * gameWindowRect.Height)), new Point((int)Math.Ceiling(spot5WidthPercentage * gameWindowRect.Width), (int)Math.Ceiling(spot5HeightPercentage * gameWindowRect.Height)), new Point((int)Math.Ceiling(spot6WidthPercentage * gameWindowRect.Width), (int)Math.Ceiling(spot6HeightPercentage * gameWindowRect.Height)) }; //Calculate frame locations and widths for the new size/aspect ratio double frame1PercentageLeft = screenConfig.frame1PercentageLeft; double frame1PercentageTop = screenConfig.frame1PercentageTop; double frame2PercentageLeft = screenConfig.frame2PercentageLeft; double frame2PercentageTop = screenConfig.frame2PercentageTop; double frameWidthPercentage = screenConfig.frameWidthPercentage; double frameHeightPercentage = screenConfig.frameHeightPercentage; Size frameSize = new Size((int)Math.Ceiling(gameWindowRect.Size.Width * frameWidthPercentage), (int)Math.Ceiling(gameWindowRect.Size.Height * frameHeightPercentage)); Point frame1Location = new Point((int)Math.Ceiling(gameWindowRect.Size.Width * frame1PercentageLeft), (int)Math.Ceiling(gameWindowRect.Size.Height * frame1PercentageTop)); Point frame2Location = new Point((int)Math.Ceiling(gameWindowRect.Size.Width * frame2PercentageLeft), (int)Math.Ceiling(gameWindowRect.Size.Height * frame2PercentageTop)); //Create a new list of OCR viewports windowData.OCRViewports = new List <Rectangle> { new Rectangle(frame1Location, frameSize), new Rectangle(frame2Location, frameSize) }; }