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); }
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; }
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)); }
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); }
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)); }
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); }
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); }