示例#1
0
        public IDictionary<Core.Light, Core.PixelReader> Capture(ILightSetupPlugin lightSetup)
        {
            IDictionary<Core.Light, Core.PixelReader> dictionary = new Dictionary<Core.Light, Core.PixelReader>();

            if (_currentResponse != null)
            {
                _capturedImage = _currentResponse.CapturedBitmapAsImage;
                _fastBitmap = new FastBitmap(_capturedImage);

                foreach (var light in lightSetup.GetLightsForBounds(_capturedImage.Width, _capturedImage.Height, 0, 0))
                {
                    dictionary[light] = new PixelReader(_fastBitmap, light.Region);
                }
            }
            if (_captures > 0 && _captures % 10 == 0)
                Console.WriteLine("Time per capture: {0}", new TimeSpan(0, 0, 0, 0, (int)(DateTime.Now - _startTime).TotalMilliseconds / _captures));

            return dictionary;
        }
示例#2
0
        public IDictionary<Core.Light, Core.PixelReader> Capture(ILightSetupPlugin lightSetup)
        {
            IDictionary<Core.Light, Core.PixelReader> dictionary = new Dictionary<Core.Light, Core.PixelReader>();

            Capture.Interface.Screenshot response = null;

            if (_capturedProcess != null && _capturedProcess.CaptureInterface != null)
            {
                response = _capturedProcess.CaptureInterface.GetScreenshot();
            }

            if (response != null)
            {
                Interlocked.Increment(ref _captures);
            }

            Interlocked.Exchange(ref _currentResponse, response);
            
            if (_currentResponse != null)
            {    
                using (System.IO.MemoryStream ms = new System.IO.MemoryStream(_currentResponse.CapturedBitmap))
                    _capturedImage = new Bitmap(ms);
                _fastBitmap = new FastBitmap(_capturedImage);

                foreach (var light in lightSetup.GetLightsForBounds(_capturedImage.Width, _capturedImage.Height, 0, 0))
                {
                    dictionary[light] = new PixelReader(_fastBitmap, light.Region);
                }
            }

            if (_captures > 0 && _captures % 10 == 0)
            {
                AfterglowRuntime.Logger.Debug("Time per capture: {0}", new TimeSpan(0, 0, 0, 0, (int)((DateTime.Now - _startTime).TotalMilliseconds / _captures)));
            }

            return dictionary;
        }
示例#3
0
        private int GetTopBandingHeight()
        {
            double segmentHeightPercent = this.BlackSegmentHeight.Value / 100.00;

            int topHeight = _captureHeight / 2;
            int segmentHeightPixels = Convert.ToInt32(_captureHeight * segmentHeightPercent);
            if (segmentHeightPixels <= 0)
            {
                segmentHeightPixels = 1;
            }
            //TODO log info segmentHeightPixels

            int blackHeight = 0;

            //iterate long segments
            for (int i = 0; i < topHeight; i += segmentHeightPixels)
            {
                //create region
                Rectangle region = new Rectangle(0, i, _captureWidth, segmentHeightPixels);

                PixelReader pixelReader = new PixelReader(_fastBitmap, region);

                // Average the pixels
                int r = 0, g = 0, b = 0, pixelCount = 0;
                foreach (var pixel in pixelReader.GetEveryNthPixel(this.PixelSkip.Value))
                {
                    r += pixel.R;
                    g += pixel.G;
                    b += pixel.B;
                    pixelCount++;
                }

                int redAvg = r / pixelCount;

                int greenAvg = g / pixelCount;

                int blueAvg = b / pixelCount;

                if (redAvg <= this.DarknessThreshold && greenAvg <= this.DarknessThreshold && blueAvg <= this.DarknessThreshold)
                {
                    blackHeight = i + segmentHeightPixels;
                }
            }

            return blackHeight;
        }
示例#4
0
        public IDictionary<Core.Light, Core.PixelReader> Capture(ILightSetupPlugin lightSetup)
        {
            _graphics.CopyFromScreen(_dispBounds.Left, _dispBounds.Top, 0, 0, new Size(_dispBounds.Width, _dispBounds.Height));

            _fastBitmap = new FastBitmap(_img);

            //TODO every n th frame check for Black banding as config as sub plugin

            IDictionary<Core.Light, Core.PixelReader> dictionary = new Dictionary<Core.Light, Core.PixelReader>();
            foreach (Light light in lightSetup.GetLightsForBounds(_dispBounds.Width, _dispBounds.Height))
            {
                dictionary[light] = new PixelReader(_fastBitmap, light.Region);
            }

            return dictionary;
        }
示例#5
0
        public IDictionary<Core.Light, Core.PixelReader> Capture(ILightSetupPlugin lightSetup)
        {
            _graphics.CopyFromScreen(_dispBounds.Left, _dispBounds.Top, 0, 0, new Size(_dispBounds.Width, _dispBounds.Height));

            _fastBitmap = new FastBitmap(_img);

            GetCaptureSize();

            IDictionary<Core.Light, Core.PixelReader> dictionary = new Dictionary<Core.Light, Core.PixelReader>();
            foreach (Light light in lightSetup.GetLightsForBounds(_captureWidth, _captureHeight, _leftOffset, _topOffset))
            {
                dictionary[light] = new PixelReader(_fastBitmap, light.Region);
            }

            return dictionary;
        }