예제 #1
0
        protected override void OnPaint( PaintEventArgs e )
        {
            if ( ( webView != null ) && webView.IsEnabled && webView.IsDirty )
                rBuffer = webView.Render();

            if ( rBuffer != null )
                Utilities.DrawBuffer( rBuffer, e.Graphics, this.BackColor, ref frameBuffer );
            else
                base.OnPaint( e );
        }
        public Stream ConvertToEncodedImageStream(RenderBuffer buffer, out ImageFormat imageFormat)
        {
            var bitmap = new WriteableBitmap(buffer.Width, buffer.Height, 96, 96,
                                             PixelFormats.Bgra32, BitmapPalettes.WebPaletteTransparent);

            buffer.CopyToBitmap(bitmap);

            imageFormat = _encoder.ImageFormat;
            var encoder = _encoder.GetEncoder(bitmap);

            var imageStream = new MemoryStream();
            encoder.Save(imageStream);

            return imageStream;
        }