Ejemplo n.º 1
0
        private static void RelicBackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            OCR_Counter += 1;
            string[] ResultHolder = e.Result.ToString().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            int      WorkerIndex  = int.Parse(ResultHolder[0]);

            OCR_Results[WorkerIndex] = ResultHolder[1];
            if (OCR_Results.Count == OCR_Counter)
            {
                //Needs more delay to remove blinking
                //_Form_OverlayRelic = new Form_OverlayRelic();
                //_Form_OverlayRelic.Show();
                Form_OverlayRelic._FormReference.BeginInvoke(new Action(() => { Form_OverlayRelic._FormReference.Controls.AddRange(OverlayHolder.ToArray()); }));

                Bitmap TimerScreenshotPart = new Bitmap(44, 52, PixelFormat.Format24bppRgb);
                Graphics.FromImage(TimerScreenshotPart).CopyFromScreen(935, 140, 0, 0, TimerScreenshotPart.Size);

                //Get Bytes
                BitmapData LockedBitmapData  = TimerScreenshotPart.LockBits(new Rectangle(0, 0, TimerScreenshotPart.Width, TimerScreenshotPart.Height), ImageLockMode.ReadWrite, TimerScreenshotPart.PixelFormat);
                int        numBytes          = Math.Abs(LockedBitmapData.Stride) * LockedBitmapData.Height;
                byte[]     LockedBitmapBytes = new byte[numBytes];
                Marshal.Copy(LockedBitmapData.Scan0, LockedBitmapBytes, 0, numBytes); // Copy the RGB values into the array.
                int PixelSize = 3;                                                    // 24 bits/8 = 3 bytes

                for (int PixelPosition = 0; PixelPosition <= (numBytes - PixelSize); PixelPosition += PixelSize)
                {
                    //RGB is reversed in bytes to BGR
                    int Color_Red   = LockedBitmapBytes[PixelPosition + 2];
                    int Color_Green = LockedBitmapBytes[PixelPosition + 1];
                    int Color_Blue  = LockedBitmapBytes[PixelPosition];
                    if (Color_Red == 239 && Color_Green == 239 && Color_Blue == 239)
                    {
                        LockedBitmapBytes[PixelPosition + 2] = 0;
                        LockedBitmapBytes[PixelPosition + 1] = 0;
                        LockedBitmapBytes[PixelPosition]     = 0;
                    }
                    else
                    {
                        LockedBitmapBytes[PixelPosition + 2] = 255;
                        LockedBitmapBytes[PixelPosition + 1] = 255;
                        LockedBitmapBytes[PixelPosition]     = 255;
                    }
                }
                Marshal.Copy(LockedBitmapBytes, 0, LockedBitmapData.Scan0, numBytes); // Copy the RGB values back into bitmap.
                TimerScreenshotPart.UnlockBits(LockedBitmapData);
                //TimerScreenshotPart.Save("ScreenshotTimer_" + DateTime.Now.ToString("*****@*****.**") + ".png", ImageFormat.Png);

                int RemainingTime = Module_OCR.OCR_Timer(TimerScreenshotPart) * 1000 - 500;
                Form_OverlayRelic._FormReference.BeginInvoke(new Action(() => { Form_OverlayRelic._FormReference.SetLocation(RemainingTime); }));

                OCR_Results.Clear();
                OCR_Counter = 0;
                Screenshot_Cuts.Clear();
                OverlayHolder.Clear();
            }
            GC.Collect();
            Form_Main._FormReference.RelicScanDelay_Timer.Start();
        }
Ejemplo n.º 2
0
        private void Form_Main_Load(object sender, EventArgs e)
        {
            _FormReference = this;

            ServicePointManager.DefaultConnectionLimit = 4;
            Module_Data.DataModule_Initialize();
            ListFissures();
            Module_OCR.OCR_Initialize();
            Module_Baro.RefreshBaro();
            this.CenterToScreen();
            Module_Hotkeys.Module_Hotkeys_Initialize();
            CB_Mute.Checked = Settings.Default.MuteSounds;
        }
Ejemplo n.º 3
0
        private static void RelicBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            int    WorkerIndex  = (int)e.Argument;
            Bitmap PassedBitmap = Screenshot_Cuts[WorkerIndex];
            string FoundText    = Module_OCR.OCR_Image(PassedBitmap);

            e.Result = WorkerIndex + "," + FoundText;

            if (FoundText.Contains("Forma"))
            {
                return;
            }
            if (Module_Data.PrimeItemsData.ContainsKey(FoundText))
            {
                Overlay OverlayItem = new Overlay(FoundText, LocationHolder["1920x1080"][Screenshot_Cuts.Count][WorkerIndex]);
                OverlayHolder.Add(OverlayItem);
                //_Form_OverlayRelic.Invoke((Action) (()=> { _Form_OverlayRelic.Controls.Add(OverlayItem); }));
            }
            else
            {
                Debug.Print(FoundText);
                FlowLayoutPanel TempFLP = new FlowLayoutPanel()
                {
                    FlowDirection = FlowDirection.TopDown,
                    Margin        = new Padding(0, 0, 0, 0),
                    Location      = new Point(LocationHolder["1920x1080"][Screenshot_Cuts.Count][WorkerIndex], 32),
                    AutoSize      = true
                };
                Label FailLabel = new Label()
                {
                    Text        = string.Format(@"OCR Fail!!! - {0}", FoundText.Replace("&", "&&")),
                    Font        = new Font("Microsoft Sans Serif", 10, FontStyle.Bold),
                    MaximumSize = new Size(235, 0),
                    AutoSize    = true,
                    BackColor   = SystemColors.Control,
                    BorderStyle = BorderStyle.FixedSingle
                };
                PictureBox SomePic = new PictureBox()
                {
                    BackgroundImage       = PassedBitmap,
                    BackgroundImageLayout = ImageLayout.Center,
                    Size        = new Size(235, 50),
                    BorderStyle = BorderStyle.FixedSingle
                };
                TempFLP.Controls.AddRange(new Control[] { FailLabel, SomePic });
                Form_OverlayRelic._FormReference.BeginInvoke(new Action(() => { Form_OverlayRelic._FormReference.Controls.Add(TempFLP); }));
            }
        }
Ejemplo n.º 4
0
        private static string Baro_ReadWindow(ref Bitmap ScreenshotReference, Point StartPoint)
        {
            Bitmap BaroItem = new Bitmap(400, 60, PixelFormat.Format24bppRgb);

            Graphics.FromImage(BaroItem).DrawImage(ScreenshotReference, 0, 0, new Rectangle(StartPoint, BaroItem.Size), GraphicsUnit.Pixel);

            BitmapData LockedBitmapData = BaroItem.LockBits(new Rectangle(0, 0, BaroItem.Width, BaroItem.Height), ImageLockMode.ReadWrite, BaroItem.PixelFormat);
            int        numBytes         = Math.Abs(LockedBitmapData.Stride) * LockedBitmapData.Height;

            byte[] LockedBitmapBytes = new byte[numBytes];
            Marshal.Copy(LockedBitmapData.Scan0, LockedBitmapBytes, 0, numBytes); // Copy the RGB values into the array.
            int PixelSize = 3;                                                    // 24 bits/8 = 3 bytes

            for (int PixelPosition = 0; PixelPosition < numBytes; PixelPosition += PixelSize)
            {
                //RGB is reversed in bytes to BGR
                int Color_Red   = LockedBitmapBytes[PixelPosition + 2];
                int Color_Green = LockedBitmapBytes[PixelPosition + 1];
                int Color_Blue  = LockedBitmapBytes[PixelPosition];
                if (Color_Red == TextColour.R && Color_Green == TextColour.G && Color_Blue == TextColour.B)
                {
                    LockedBitmapBytes[PixelPosition + 2] = 255;
                    LockedBitmapBytes[PixelPosition + 1] = 255;
                    LockedBitmapBytes[PixelPosition]     = 255;
                }
                else
                {
                    LockedBitmapBytes[PixelPosition + 2] = 0;
                    LockedBitmapBytes[PixelPosition + 1] = 0;
                    LockedBitmapBytes[PixelPosition]     = 0;
                }
            }
            Marshal.Copy(LockedBitmapBytes, 0, LockedBitmapData.Scan0, numBytes); // Copy the RGB values back into bitmap.
            BaroItem.UnlockBits(LockedBitmapData);
            //BaroItem.Save("ScreenshotBaroItem_" + DateTime.Now.ToString("*****@*****.**") + ".png", ImageFormat.Png);

            string BaroResult = Module_OCR.OCR_Image(BaroItem).ToLower();

            if (BaroResult.Contains("blueprint"))
            {
                BaroResult = BaroResult.Substring(0, BaroResult.IndexOf("blueprint") + "blueprint".Length);
            }
            BaroResult = new CultureInfo("en-US", false).TextInfo.ToTitleCase(BaroResult);
            BaroItem.Dispose();

            return(BaroResult);
        }