Ejemplo n.º 1
0
        void RefreshImage(Bitmap bmpData)
        {
            if (pictureBox1.InvokeRequired == false)
            {
                pictureBox1.Image = bmpData;



                // if (btnStop.Enabled == false) btnStop.Enabled = true;
                //if (btnCalibrate.Enabled == true && liveStream == true) btnCalibrate.Enabled = false;
            }
            else
            {
                RefreshImageDelegate showProgress = new RefreshImageDelegate(RefreshImage);
                BeginInvoke(showProgress, new object[] { bmpData });
            }
        }
Ejemplo n.º 2
0
        private void RefreshImage()
        {
            if (picPanel.InvokeRequired)
            {
                var d = new RefreshImageDelegate(RefreshImage);
                picPanel.Invoke(d);
            }
            else
            {
                // Generate base image
                m_currentBitmap = GameBoyPixelsToImage(m_listTiles, (Palette)comboColorPalette.SelectedItem);

                // Handle cropping
                if (checkRemoveBorder.Checked)
                {
                    const int toRemove = TILE_PIXEL_WIDTH * 2;
                    m_currentBitmap = CropBitmap(m_currentBitmap,
                                                 new Rectangle
                    {
                        X      = toRemove,
                        Y      = toRemove,
                        Width  = m_currentBitmap.Width - toRemove * 2,
                        Height = m_currentBitmap.Height - toRemove * 2
                    }
                                                 );
                }
                // Handle magnification
                int magnification = new int[] { 1, 2, 4 }[Math.Max(0, comboMagnify.SelectedIndex)];
                if (magnification > 1)
                {
                    m_currentBitmap = ResizeBitmap(m_currentBitmap, magnification);
                }



                picPanel.BackgroundImage = m_currentBitmap;
            }
        }
Ejemplo n.º 3
0
        //-------------------------------------------------------------------------

        void RunRefresh()
        {
            try
            {
                RefreshImageDelegate refreshDelegate =
                    new RefreshImageDelegate(RefreshImage);

                RefreshRunnerIsAlive = true;

                while (RefreshRunnerIsAlive)
                {
                    try
                    {
                        for (int i = 0; i < RefreshRateInSecs; i++)
                        {
                            Thread.Sleep(1000);

                            if (RefreshRunnerIsAlive == false)
                            {
                                break;
                            }
                        }
                    }
                    catch (Exception)
                    {
                        // Ignore.
                    }

                    Invoke(refreshDelegate);
                }
            }
            catch (Exception ex)
            {
                Log(ex);
            }
        }
Ejemplo n.º 4
0
        public void UpdateFrame(Bitmap frame)
        {
            RefreshImageDelegate del = RefreshImage;

            this.BeginInvoke(del, new[] { frame });
        }