图像质量在vb.net中不合适 [英] Image quality not coming proper in vb.net

查看:153
本文介绍了图像质量在vb.net中不合适的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在尝试从图片框中取出打印件,当我按下打印按钮后看到该图像的预览时,图像质量变得非常糟糕

我试过以下

picTrade 是图片框

Hi I am trying to take a print from the picture box when i see the preview of that image after pressing the print button it is not coming proper the quality of the image is coming very bad
I tried the following
picTrade is the picture box

Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
        Dim bm As New Bitmap(picTrade.ImageLocation)
        picTrade.DrawToBitmap(bm, New Rectangle(0, 0, bm.Width, bm.Height))
        e.Graphics.DrawImage(bm, 0, 0)
        e.Graphics.PageUnit = GraphicsUnit.Inch
End Sub

推荐答案

一个提示,但我会让你深入了解图形对象的选项!您需要设置一些选项以获得更好的图像质量,如下所示(仅作为示例)。并且,您可能应该从图像框的来源打印,例如通过将希望的高质量源加载到位图中。请记住,Windows上的屏幕元素仅绘制96dpi(默认)(可能仍为72dpi mac os!?)。因此,在纸上以300dpi打印它们将导致非常小的图片或(坏)调整大小并模糊图像。更进一步,你将不得不打扰模糊的结果esp。模糊字体,这可能涉及在关键字SnapsToDevicePixels下找到的问题(例如,在WPF UIElements上),因为像素可能具有设备特定尺寸。同样用于保存图像(参见编码器参数)。我写过自己的打印模块,我可以告诉你,打印并不容易。



just a hint, but I sugest you to dive into the options of the graphics object! you will need to set some options for better image quality like shown below (just an example). and, you should probably print from the source of your image box, e.g. by loading the hopefully "high quality" source into a bitmap. remember, screen elements on windows are drawn 96dpi (default) only (maybe still 72dpi mac os!?). so printing them at 300dpi on paper will result in either very small pictures or (bad) resized and blur images. further more you will have to bother with blurry results esp. blurry fonts, this may relate to an issue to be found under the keyword SnapsToDevicePixels (e.g. on WPF UIElements) because a pixel may have device specific dimensions. same for saving images (see encoder parameters). having written my own printing module I can tell you, printing is no easy job.

//use a graphics object to draw the resized image into the bitmap
using (Graphics graphics = Graphics.FromImage(result))
{
    //set the resize quality modes to high quality
    graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
    graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
    graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
    graphics.PixelOffsetMode = PixelOffsetMode.HighQuality
    //draw the image into the target bitmap
    graphics.DrawImage(image, 0, 0, result.Width, result.Height);
}





还有一件事,请不要使用像这样的原生单位进行英寸测试GraphicsUnit.Pixel (我认为这意味着snaptodevicepixel)参见 http://msdn.microsoft.com/de-de/library/system.drawing.graphicsunit(v = vs.110).aspx [ ^ ]



one more thing, don't draw in inch test with some native units like GraphicsUnit.Pixel (I think that implies snaptodevicepixel) see http://msdn.microsoft.com/de-de/library/system.drawing.graphicsunit(v=vs.110).aspx[^]


这篇关于图像质量在vb.net中不合适的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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