当前位置: 首页>>代码示例>>C#>>正文


C# IPresentationImage.DrawToBitmap方法代码示例

本文整理汇总了C#中IPresentationImage.DrawToBitmap方法的典型用法代码示例。如果您正苦于以下问题:C# IPresentationImage.DrawToBitmap方法的具体用法?C# IPresentationImage.DrawToBitmap怎么用?C# IPresentationImage.DrawToBitmap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPresentationImage的用法示例。


在下文中一共展示了IPresentationImage.DrawToBitmap方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ImageDrawToBitmap

		private static Bitmap ImageDrawToBitmap(IPresentationImage presentationImage, int width, int height, float dpi)
		{
			if (!(presentationImage is PresentationImage))
				return presentationImage.DrawToBitmap(width, height);

			var image = (PresentationImage) presentationImage;
			var bmp = new Bitmap(width, height);

			var graphics = System.Drawing.Graphics.FromImage(bmp);
			var contextId = graphics.GetHdc();
			try
			{
				using (var surface = image.ImageRenderer.CreateRenderingSurface(IntPtr.Zero, bmp.Width, bmp.Height, RenderingSurfaceType.Offscreen))
				{
					surface.ContextID = contextId;
					surface.ClipRectangle = new Rectangle(0, 0, bmp.Width, bmp.Height);

					var drawArgs = new DrawArgs(surface, null, DrawMode.Render) {Dpi = dpi, Tag = bmp};
					image.Draw(drawArgs);
                    drawArgs = new DrawArgs(surface, null, DrawMode.Refresh) { Dpi = dpi, Tag = bmp};
					image.Draw(drawArgs);
				}
			}
			finally
			{
				graphics.ReleaseHdc(contextId);
				graphics.Dispose();
			}
			return bmp;
		}
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:30,代码来源:ImageExporter.cs

示例2: DrawToBitmap

		protected static Bitmap DrawToBitmap(IPresentationImage presentationImage)
		{
			var imageGraphicProvider = (IImageGraphicProvider) presentationImage;
			var annotationLayoutProvider = presentationImage as IAnnotationLayoutProvider;
			var annotationLayoutVisible = true;

			if (annotationLayoutProvider != null)
			{
				annotationLayoutVisible = annotationLayoutProvider.AnnotationLayout.Visible;
				annotationLayoutProvider.AnnotationLayout.Visible = false;
			}

			try
			{
				return presentationImage.DrawToBitmap(imageGraphicProvider.ImageGraphic.Columns, imageGraphicProvider.ImageGraphic.Rows);
			}
			finally
			{
				if (annotationLayoutProvider != null)
				{
					annotationLayoutProvider.AnnotationLayout.Visible = annotationLayoutVisible;
				}
			}
		}
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:24,代码来源:FusionColorCompositingTest.cs

示例3: IdentifyPresentationImageFrames

		private static void IdentifyPresentationImageFrames(IPresentationImage image, out int imageFrameNumber, out int? overlayFrameNumber)
		{
			var overlayColor = Color.Red;
			var imageColor = Color.White;

			// force the overlays to show in our chosen colour
			PresentationState.DicomDefault.Deserialize(image);
			var dps = DicomGraphicsPlane.GetDicomGraphicsPlane((IDicomPresentationImage) image, true);
			foreach (var overlay in dps.ImageOverlays)
				overlay.Color = overlayColor;

			var sopProvider = (IImageSopProvider) image;
			using (var dump = image.DrawToBitmap(sopProvider.Frame.Columns, sopProvider.Frame.Rows))
			{
				// identify the frame number encoded in the image
				imageFrameNumber = 0;
				imageFrameNumber += AreEqual(Sample(dump, 95, 205, 8, 8), imageColor) ? 0x10 : 0;
				imageFrameNumber += AreEqual(Sample(dump, 113, 205, 8, 8), imageColor) ? 0x08 : 0;
				imageFrameNumber += AreEqual(Sample(dump, 130, 205, 8, 8), imageColor) ? 0x04 : 0;
				imageFrameNumber += AreEqual(Sample(dump, 148, 205, 8, 8), imageColor) ? 0x02 : 0;
				imageFrameNumber += AreEqual(Sample(dump, 166, 205, 8, 8), imageColor) ? 0x01 : 0;

				// check if overlay positioning blocks are in the right place
				if (!AreEqual(Sample(dump, 187, 73, 8, 8), overlayColor) || !AreEqual(Sample(dump, 74, 182, 8, 8), overlayColor))
				{
					overlayFrameNumber = null;
					return;
				}

				// identify the frame number encoded in the overlay
				overlayFrameNumber = 0;
				overlayFrameNumber += AreEqual(Sample(dump, 95, 182, 8, 8), overlayColor) ? 0x10 : 0;
				overlayFrameNumber += AreEqual(Sample(dump, 113, 182, 8, 8), overlayColor) ? 0x08 : 0;
				overlayFrameNumber += AreEqual(Sample(dump, 130, 182, 8, 8), overlayColor) ? 0x04 : 0;
				overlayFrameNumber += AreEqual(Sample(dump, 148, 182, 8, 8), overlayColor) ? 0x02 : 0;
				overlayFrameNumber += AreEqual(Sample(dump, 166, 182, 8, 8), overlayColor) ? 0x01 : 0;
			}
		}
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:38,代码来源:OverlayPlanePresentationTests.cs

示例4: DrawToIcon

		private static Bitmap DrawToIcon(IPresentationImage image, int width, int height)
		{
			//We just hide the text overlay and application graphics because it creates ugly icons.
			var textOverlayHider = new TextOverlayVisibilityHelper(image);
			var applicationGraphicsHider = GraphicsVisibilityHelper.CreateForApplicationGraphics(image);
			textOverlayHider.Hide();
			applicationGraphicsHider.HideAll();

			try
			{
				return image.DrawToBitmap(width, height);
			}
			catch (Exception ex)
			{
				// rendering the error text to a 100x100 icon is useless, so we'll just paint a placeholder error icon and log the icon error
				Platform.Log(LogLevel.Warn, ex, "Failed to render icon with dimensions {0}x{1}", width, height);
				var bitmap = new Bitmap(width, height);
				using (var graphics = System.Drawing.Graphics.FromImage(bitmap))
				{
					graphics.FillRectangle(Brushes.Black, 0, 0, width, height);
					graphics.DrawLine(Pens.WhiteSmoke, 0, 0, width, height);
					graphics.DrawLine(Pens.WhiteSmoke, 0, height, width, 0);
				}
				return bitmap;
			}
			finally
			{
				textOverlayHider.Restore();
				applicationGraphicsHider.RestoreAll();
			}
		}
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:31,代码来源:IconCreator.cs

示例5: CreateImageIcon

		public Bitmap CreateImageIcon(IPresentationImage image)
		{
			Platform.CheckForNullReference(image, "image");
			return GetImageIcon(delegate(int width, int height) { return image.DrawToBitmap(width, height); });
		}
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:5,代码来源:IconHelper.cs


注:本文中的IPresentationImage.DrawToBitmap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。