打印视口
C# wpf 3D Visual Studio 2010 net 4.5
您好,
我正在尝试打印我创建的 3D 图像,但无法正确打印。 打印的图像的尺寸会根据窗口的大小等而变化。 或者它被剪裁等。
我想要的是在打印机上打印视图端口, 将其拉伸到与纸张一样宽并保持长宽比。
PrintDialog dialog = new PrintDialog();
if (dialog.ShowDialog() != true)
{ return; }
StackPanel myPanel = new StackPanel();
myPanel.Margin = new Thickness(40);
Image myImage = new Image();
myImage.Width = dialog.PrintableAreaWidth - (2 * MYDPI);
myImage.Stretch = Stretch.Uniform;
RenderTargetBitmap bmp = new RenderTargetBitmap((int)dialog.PrintableAreaWidth, (int)dialog.PrintableAreaWidth, 96, 96, PixelFormats.Pbgra32);
bmp.Render(myViewPort);
myImage.Source = bmp;
myPanel.Children.Add(myImage);
myPanel.Measure(new Size(dialog.PrintableAreaWidth, dialog.PrintableAreaHeight));
myPanel.Arrange(new Rect(new Point(0, 0), myPanel.DesiredSize));
dialog.PrintVisual(myPanel, myName);
C# wpf 3D visual studio 2010 net 4.5
Hi
I am trying to print out the 3D image I have created but can not get it right.
The image that is printed is changing in size depending on how large the window is etc.
or it is clipped etc.
What I would like is to print the view port on the printer,
stretching it so wide as the paper is and keeping aspect ration.
PrintDialog dialog = new PrintDialog();
if (dialog.ShowDialog() != true)
{ return; }
StackPanel myPanel = new StackPanel();
myPanel.Margin = new Thickness(40);
Image myImage = new Image();
myImage.Width = dialog.PrintableAreaWidth - (2 * MYDPI);
myImage.Stretch = Stretch.Uniform;
RenderTargetBitmap bmp = new RenderTargetBitmap((int)dialog.PrintableAreaWidth, (int)dialog.PrintableAreaWidth, 96, 96, PixelFormats.Pbgra32);
bmp.Render(myViewPort);
myImage.Source = bmp;
myPanel.Children.Add(myImage);
myPanel.Measure(new Size(dialog.PrintableAreaWidth, dialog.PrintableAreaHeight));
myPanel.Arrange(new Rect(new Point(0, 0), myPanel.DesiredSize));
dialog.PrintVisual(myPanel, myName);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下工作有效,现在无论什么,图片都会缩放到纸张的大小
视口的大小
...
The following worked, now the picture get scaled to the size of the paper regardless of
the size of the viewport
...