预览多个图像 [英] Preview multiple images

查看:77
本文介绍了预览多个图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用打印预览和图片框预览多个图像..谢谢!



顺便说一下这是我的代码..



 私有  Sub  PrintDocument1_PrintPage( ByVal  sender  As  System。 Object  ByVal  e  As  System.Drawing.Printing.PrintPageEventArgs)句柄 PrintDocument1.PrintPage 
e.Graphics.DrawImage(IMG1.Image,e.MarginBounds.Left,e.MarginBounds.Top)
End < span class =code-keyword> Sub

私有 Sub Button1_Click( ByVal sender As System。 Obje ct ByVal e As System.EventArgs)句柄 Button1.Click
PrintPreviewDialog1.PrintPreviewControl.Zoom = 1
PrintPreviewDialog1.Document = PrintDocument1
PrintPreviewDialog1.ShowDialog ()
结束 Sub

解决方案

您没有显示表单的代码或打印预览。如果你想使用 PictureBox ,请使用它(这是很少见的情况)。我不明白为什么它可能是一个问题。



但是,如果你想要打印预览接近打印,使用你已经做的相同的事情在打印页面中,您应该覆盖虚拟方法 System.Windows.Forms.Control.OnPaint 或处理事件 System.Windows.Forms.Control。油漆 System.Drawing.Graphics 的实例将在事件参数中传递给您,您可以像以前一样绘制图像。



实际上,通过编写一个接受相同事件参数的单独方法,从媒体(屏幕,打印,位图)抽象渲染。然后你可以从不同的地方调用这个方法:打印页面渲染,绘制处理程序(在屏幕上),在位图上绘制等等。



-SA

How to preview multiple images using print preview and picturebox.. thanks!

by the way this is my code..

Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
        e.Graphics.DrawImage(IMG1.Image, e.MarginBounds.Left, e.MarginBounds.Top)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        PrintPreviewDialog1.PrintPreviewControl.Zoom = 1
        PrintPreviewDialog1.Document = PrintDocument1
        PrintPreviewDialog1.ShowDialog()
    End Sub

解决方案

You did not show the code of the form, or the print preview. If you want to use PictureBox, use it (this is the rare case when it would make full sense). I don't see why it could possibly be a problem.

However, if you want print preview close to the print, use the same thing as you already do in the print page, you should override the virtual method System.Windows.Forms.Control.OnPaint or handle the event System.Windows.Forms.Control.Paint. The instance of System.Drawing.Graphics will be passed to you in the event arguments, and you can draw the images, the same way you already do.

Practically, abstract the rendering from media (screen, print, bitmap) by writing a separate method which accepts the same event arguments. Then you can call this method from different places: print page rendering, paint handler (on screen), draw on a bitmap, etc.

—SA


这篇关于预览多个图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆