加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

在VB.Net中从头开始创建位图图像时,质量很糟糕吗?

发布时间:2020-12-17 00:32:39 所属栏目:大数据 来源:网络整理
导读:Vb.Net应用程序从头开始创建一个位图,并转换为tiff或将其发送到打印机.在这两种情况下,图像的质量(在这种情况下是字体)都不是很好.下面列出的示例代码创建了我用来写入图像的图形对象. Dim gr2 As Graphics = Graphics.FromImage(New Bitmap(800,1000),Imagi
Vb.Net应用程序从头开始创建一个位图,并转换为tiff或将其发送到打印机.在这两种情况下,图像的质量(在这种情况下是字体)都不是很好.下面列出的示例代码创建了我用来写入图像的图形对象.
Dim gr2 As Graphics = Graphics.FromImage(New Bitmap(800,1000),Imaging.PixelFormat.Format32bppPArgb))
除了@durilai说你可能想要提出解决方案,如果你打算打印. .Net使用的系统分辨率通常为96 DPI,但打印机可以使用300 DPI或更高的文件.
'Create a new bitmap
    Using Bmp As New Bitmap(800,1000,Imaging.PixelFormat.Format32bppPArgb)
        'Set the resolution to 300 DPI
        Bmp.SetResolution(300,300)
        'Create a graphics object from the bitmap
        Using G = Graphics.FromImage(Bmp)
            'Paint the canvas white
            G.Clear(Color.White)
            'Set various modes to higher quality
            G.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
            G.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
            G.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias

            'Create a font
            Using F As New Font("Arial",12)
                'Create a brush
                Using B As New SolidBrush(Color.Black)
                    'Draw some text
                    G.DrawString("Hello world",F,B,20,20)
                End Using
            End Using
        End Using

        'Save the file as a TIFF
        Bmp.Save("c:test.tiff",Imaging.ImageFormat.Tiff)
    End Using

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读