コード例 #1
0
ファイル: DrawableHandler.cs プロジェクト: Exe0/Eto
		public override Graphics CreateGraphics()
		{
			if (graphics == null)
				return null;
			var handler = new GraphicsHandler((GraphicsHandler)graphics.Handler);
			handler.BeginDrawing();
			return new Graphics(Generator, handler);
		}
コード例 #2
0
        public override Graphics CreateGraphics()
        {
            if (graphics == null)
            {
                return(null);
            }
            var handler = new GraphicsHandler((GraphicsHandler)graphics.Handler);

            handler.BeginDrawing();
            return(new Graphics(Generator, handler));
        }
コード例 #3
0
        public void Render()
        {
            // Note: there ought to be a more efficient way to do this, as this is
            // critical. However, after much searching, the only way I found to
            // convert a Wic bitmap to a BitmapImage was by serializing to/from
            // a memory stream.

            if (!isRendering &&
                GraphicsHandler != null &&
                GraphicsHandler.Control != null)
            {
                isRendering = true;
                GraphicsHandler.BeginDrawing();
                Callback.OnPaint(Widget, new PaintEventArgs(graphics, Widget.Bounds));                 // renders into the bitmap
                GraphicsHandler.EndDrawing();
                var bitmap = GraphicsHandler.Image;
                if (bitmap != null)
                {
                    var bitmapHandler   = bitmap.Handler as BitmapHandler;
                    var bitmapObject    = bitmapHandler.Control;
                    var size            = bitmapObject.Size;
                    var writeableBitmap = new WriteableBitmap(size.Width, size.Height);

                    // Get a pointer to the bitmap pixels
                    unsafe
                    {
                        byte *ptr = null;
                        ((IBufferByteAccess)writeableBitmap.PixelBuffer).Buffer(out ptr);
                        var len    = size.Width * size.Height;
                        var pixels = new SharpDX.ColorBGRA[len];
                        fixed(SharpDX.ColorBGRA *pixelsPtr = &pixels[0])
                        {
                            bitmapObject.CopyPixels(pixels);
                            CopyMemory((IntPtr)ptr, (IntPtr)pixelsPtr, (uint)len * 4);
                        }
                    }
                    Control.Source = writeableBitmap;
                }
                isRendering = false;
            }
        }