Exemplo n.º 1
0
		public GdiRenderingSurface(IntPtr windowId, int width, int height)
			: base(RenderingSurfaceType.Offscreen)
		{
			_imageBuffer = new BitmapBuffer();
			_finalBuffer = new BackBuffer();

			WindowID = windowId;
			ClientRectangle = new Rectangle(0, 0, width, height);
		}
Exemplo n.º 2
0
		/// <summary>
		/// Implementation of the <see cref="IDisposable"/> pattern
		/// </summary>
		/// <param name="disposing">True if this object is being disposed, false if it is being finalized</param>
		protected override void Dispose(bool disposing)
		{
			if (disposing)
			{
				if (_imageBuffer != null)
				{
					_imageBuffer.Dispose();
					_imageBuffer = null;
				}

				if (_finalBuffer != null)
				{
					_finalBuffer.Dispose();
					_finalBuffer = null;
				}
			}
		}
		public Win32VtkRenderingSurface(IntPtr windowId, bool offscreen)
		{
			_imageBuffer = new BitmapBuffer(PixelFormat.Format32bppRgb);
			_overlayBuffer = new BitmapBuffer(PixelFormat.Format32bppArgb);
			_finalBuffer = new BackBuffer();

			_vtkRenderer = new vtkRenderer();
			_vtkRenderer.SetBackground(0.0f, 0.0f, 0.0f);

			_vtkRenderWindow = new vtkWin32OpenGLRenderWindow();
			_vtkRenderWindow.OffScreenRenderingOn();
			_vtkRenderWindow.DoubleBufferOff();
			_vtkRenderWindow.EraseOn();
			_vtkRenderWindow.SwapBuffersOff();
			_vtkRenderWindow.SetDesiredUpdateRate(_dynamicFrameRate);
			_vtkRenderWindow.AddRenderer(_vtkRenderer);

			_dynamicRenderEventPublisher = !offscreen ? new DelayedEventPublisher((s, e) => Render(true, null)) : null;

			WindowID = windowId;
		}
Exemplo n.º 4
0
		/// <summary>
		/// Draws an image graphic to the specified destination buffer.
		/// </summary>
		/// <param name="buffer">The destination buffer.</param>
		/// <param name="imageGraphic">The image graphic to be drawn.</param>
		public static void DrawImageGraphic(BitmapBuffer buffer, ImageGraphic imageGraphic)
		{
			const int bytesPerPixel = 4;

			var bounds = ((IGdiBuffer) buffer).Bounds;
			var bitmapData = buffer.Bitmap.LockBits(bounds, ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
			try
			{
				ImageRenderer.Render(imageGraphic, bitmapData.Scan0, bitmapData.Width, bytesPerPixel, bounds);
			}
			finally
			{
				buffer.Bitmap.UnlockBits(bitmapData);
			}
		}
		protected virtual void Dispose(bool disposing)
		{
			if (disposing)
			{
				if (_dynamicRenderEventPublisher != null)
				{
					_dynamicRenderEventPublisher.Cancel();
					_dynamicRenderEventPublisher.Dispose();
					_dynamicRenderEventPublisher = null;
				}

				if (_vtkRenderWindow != null)
				{
					_vtkRenderWindow.Dispose();
					_vtkRenderWindow = null;
				}

				if (_vtkRenderer != null)
				{
					_vtkRenderer.Dispose();
					_vtkRenderer = null;
				}

				if (_sceneGraphRoot != null)
				{
					_sceneGraphRoot.Dispose();
					_sceneGraphRoot = null;
				}

				if (_imageBuffer != null)
				{
					_imageBuffer.Dispose();
					_imageBuffer = null;
				}

				if (_overlayBuffer != null)
				{
					_overlayBuffer.Dispose();
					_overlayBuffer = null;
				}

				if (_finalBuffer != null)
				{
					_finalBuffer.Dispose();
					_finalBuffer = null;
				}
			}
		}
Exemplo n.º 6
0
 /// <summary>
 /// Renders the given <see cref="BitmapBuffer"/> to the back buffer.
 /// </summary>
 /// <param name="imageBuffer"></param>
 public void RenderImage(BitmapBuffer imageBuffer)
 {
     RenderImage(imageBuffer.Bitmap);
 }
Exemplo n.º 7
0
		/// <summary>
		/// Renders the given <see cref="BitmapBuffer"/> to the back buffer.
		/// </summary>
		/// <param name="imageBuffer"></param>
		public void RenderImage(BitmapBuffer imageBuffer)
		{
			RenderImage(imageBuffer.Bitmap);
		}