public BitmapImage TakeScreenshot()
        {
#if GUI_DISABLED
            throw new RecoverableException("Taking screenshots with a disabled GUI is not supported");
#else
            if (buffer == null)
            {
                throw new RecoverableException("Frame buffer is empty.");
            }

            // this is inspired by FrameBufferDisplayWidget.cs:102
            var pixelFormat = PixelFormat.RGBA8888;
    #if PLATFORM_WINDOWS
            pixelFormat = PixelFormat.BGRA8888;
    #endif

            var converter = PixelManipulationTools.GetConverter(Format, Endianess, pixelFormat, ELFSharp.ELF.Endianess.BigEndian);
            var outBuffer = new byte[Width * Height * pixelFormat.GetColorDepth()];
            converter.Convert(buffer, ref outBuffer);

            var img = new ImageBuilder(Width, Height).ToBitmap();
            img.Copy(outBuffer);
            return(img);
#endif
        }
        public void SetDisplayParameters(int desiredWidth, int desiredHeight, PixelFormat colorFormat, Endianess endianess)
        {
            if (desiredWidth == 0 && desiredHeight == 0)
            {
                return;
            }

            DesiredDisplayWidth  = desiredWidth;
            DesiredDisplayHeight = desiredHeight;

            lock (imgLock)
            {
                var pixelFormat = PixelFormat.RGBA8888;
#if PLATFORM_WINDOWS
                pixelFormat = PixelFormat.BGRA8888;
#endif
                converter = PixelManipulationTools.GetConverter(colorFormat, endianess, pixelFormat, Endianess.BigEndian);
                outBuffer = new byte[desiredWidth * desiredHeight * pixelFormat.GetColorDepth()];

                img             = new ImageBuilder(DesiredDisplayWidth, DesiredDisplayHeight).ToBitmap();
                drawMethod      = CalculateDrawMethod();
                ActualImageArea = CalculateActualImageRectangle();

                anythingDrawnAfterLastReconfiguration = false;
            }

            OnDisplayParametersChanged(DesiredDisplayWidth, DesiredDisplayHeight, colorFormat);
        }
예제 #3
0
        private void HandlePixelFormatChange()
        {
            var outputFormat     = outputColorModeField.Value.ToPixelFormat();
            var backgroundFormat = backgroundColorModeField.Value.ToPixelFormat();
            var foregroundFormat = foregroundColorModeField.Value.ToPixelFormat();

            converter = PixelManipulationTools.GetConverter(foregroundFormat, Endianness, outputFormat, Endianness, foregroundClutColorModeField.Value.ToPixelFormat());
            blender   = PixelManipulationTools.GetBlender(backgroundFormat, Endianness, foregroundFormat, Endianness, outputFormat, Endianness, foregroundClutColorModeField.Value.ToPixelFormat(), backgroundClutColorModeField.Value.ToPixelFormat());
        }
        private void HandleConfigurationChange(int width, int height, Backends.Display.PixelFormat format, ELFSharp.ELF.Endianess endianess)
        {
            if (width == 0 || height == 0)
            {
                return;
            }

            converter = PixelManipulationTools.GetConverter(format, endianess, Backends.Display.PixelFormat.ARGB8888, ELFSharp.ELF.Endianess.LittleEndian);
            frameSize = width * height * 4;
        }
예제 #5
0
        public RawImageData TakeScreenshot()
        {
            if (buffer == null)
            {
                throw new RecoverableException("Frame buffer is empty.");
            }

            var converter = PixelManipulationTools.GetConverter(Format, Endianess, RawImageData.PixelFormat, ELFSharp.ELF.Endianess.BigEndian);
            var outBuffer = new byte[Width * Height * RawImageData.PixelFormat.GetColorDepth()];

            converter.Convert(buffer, ref outBuffer);

            return(new RawImageData(outBuffer, Width, Height));
        }
예제 #6
0
            private void HandleLayerBackgroundColorChange()
            {
                var colorBuffer = new byte[4 * video.Width * video.Height];

                for (var i = 0; i < colorBuffer.Length; i += 4)
                {
                    colorBuffer[i]     = (byte)DefaultColorAlphaField.Value;
                    colorBuffer[i + 1] = (byte)DefaultColorRedField.Value;
                    colorBuffer[i + 2] = (byte)DefaultColorGreenField.Value;
                    colorBuffer[i + 3] = (byte)DefaultColorBlueField.Value;
                }

                PixelManipulationTools.GetConverter(PixelFormat.ARGB8888, video.Endianess, PixelFormatField.Value.ToPixelFormat(), video.Endianess)
                .Convert(colorBuffer, ref LayerBackgroundBuffer);
            }
예제 #7
0
        public RawImageData GetLastFrame(bool grab = false)
        {
            if (grab)
            {
                GrabFrame();
            }

            if (lastFrame == null)
            {
                return(new RawImageData(new byte[0], 0, 0));
            }

            var decompressed = DecompressJpgToRaw(lastFrame);
            var converter    = PixelManipulationTools.GetConverter(PixelFormat.RGB888, ELFSharp.ELF.Endianess.BigEndian, RawImageData.PixelFormat, ELFSharp.ELF.Endianess.BigEndian);
            var result       = new byte[decompressed.Width * decompressed.Height * RawImageData.PixelFormat.GetColorDepth()];

            converter.Convert(decompressed.Data, ref result);

            return(new RawImageData(result, decompressed.Width, decompressed.Height));
        }
예제 #8
0
        private void HandlePixelFormatChange()
        {
            var outputFormat         = outputColorModeField.Value.ToPixelFormat();
            var backgroundFormat     = backgroundColorModeField.Value.ToPixelFormat();
            var backgroundFixedColor = new Pixel(
                (byte)backgroundColorRedChannelField.Value,
                (byte)backgroundColorGreenChannelField.Value,
                (byte)backgroundColorBlueChannelField.Value,
                (byte)0xFF);

            var foregroundFormat     = foregroundColorModeField.Value.ToPixelFormat();
            var foregroundFixedColor = new Pixel(
                (byte)foregroundColorRedChannelField.Value,
                (byte)foregroundColorGreenChannelField.Value,
                (byte)foregroundColorBlueChannelField.Value,
                (byte)0xFF);

            bgConverter = PixelManipulationTools.GetConverter(backgroundFormat, Endianness, outputFormat, Endianness, backgroundClutColorModeField.Value.ToPixelFormat(), backgroundFixedColor);
            fgConverter = PixelManipulationTools.GetConverter(foregroundFormat, Endianness, outputFormat, Endianness, foregroundClutColorModeField.Value.ToPixelFormat(), foregroundFixedColor);
            blender     = PixelManipulationTools.GetBlender(backgroundFormat, Endianness, foregroundFormat, Endianness, outputFormat, Endianness, foregroundClutColorModeField.Value.ToPixelFormat(), backgroundClutColorModeField.Value.ToPixelFormat(), backgroundFixedColor, foregroundFixedColor);
        }
예제 #9
0
        public void SetDisplayParameters(int desiredWidth, int desiredHeight, PixelFormat colorFormat, Endianess endianess)
        {
            if (desiredWidth == 0 && desiredHeight == 0)
            {
                return;
            }

            DesiredDisplayWidth  = desiredWidth;
            DesiredDisplayHeight = desiredHeight;

            lock (imgLock)
            {
                converter = PixelManipulationTools.GetConverter(colorFormat, endianess, PixelFormat.RGBA8888, Endianess.BigEndian);
                outBuffer = new byte[desiredWidth * desiredHeight * PixelFormat.RGBA8888.GetColorDepth()];

                img             = new ImageBuilder(DesiredDisplayWidth, DesiredDisplayHeight).ToBitmap();
                drawMethod      = CalculateDrawMethod();
                ActualImageArea = CalculateActualImageRectangle();
            }

            OnDisplayParametersChanged(DesiredDisplayWidth, DesiredDisplayHeight, colorFormat);
        }