private static Bitmap DrawWysiwygImageToBitmap(IPresentationImage image, Rectangle displayRectangle, float scale, float dpi) { IImageSpatialTransform transform = (IImageSpatialTransform)((ISpatialTransformProvider)image).SpatialTransform; object restoreMemento = transform.CreateMemento(); try { int width = (int)(displayRectangle.Width * scale); int height = (int)(displayRectangle.Height * scale); transform.Scale *= scale; return(ImageDrawToBitmap(image, width, height, dpi)); } finally { transform.SetMemento(restoreMemento); } }
private static Bitmap DrawCompleteImageToBitmap(IPresentationImage image, float scale, float dpi) { IImageSpatialTransform transform = (IImageSpatialTransform)((ISpatialTransformProvider)image).SpatialTransform; object restoreMemento = transform.CreateMemento(); try { Rectangle imageRectangle = new Rectangle(new Point(0, 0), image.SceneSize); transform.Initialize(); transform.ScaleToFit = false; transform.Scale = scale; RectangleF displayRectangle = transform.ConvertToDestination(imageRectangle); int width = (int)Math.Round(displayRectangle.Width); int height = (int)Math.Round(displayRectangle.Height); transform.ScaleToFit = true; return(ImageDrawToBitmap(image, width, height, dpi)); } finally { transform.SetMemento(restoreMemento); } }