【问题标题】:VB graphics from image file shows bigger than it's original size图像文件中的 VB 图形显示大于原始大小
【发布时间】:2013-10-13 10:16:43
【问题描述】:

我在 vb.net 中有这个:

Public Class Form1
    Dim output As New Bitmap(300, 300)
    Dim gfx As Graphics = Graphics.FromImage(output)
    Sub refreshScreen() Handles Timer1.Tick
        gfx.DrawImage(Image.FromFile("wheel.png"), New Point(50, 50))
        gfx.FillRectangle(Brushes.Blue, 100, 100, 25, 25) 'Some other drawings on top
        PictureBox1.Image = output
    End Sub
End Class

问题是“wheel.png”在 PictureBox1 中的显示比原始分辨率大,并且像缩放和模糊一样。我该如何解决这个问题?

【问题讨论】:

    标签: vb.net image graphics fromfile


    【解决方案1】:

    换行:

    gfx.DrawImage(Image.FromFile("wheel.png"), New Point(50, 50))
    

    作者:

    gfx.DrawImage(Image.FromFile("wheel.png"), New Rectangle(0, 0, 225, 70))
    

    一个矩形指定大小,所以你不会担心奇怪的缩放。您甚至可以将图像放在变量对象中,并访问此对象 .Height 和 .Width 来修复 DrawImage 问题。

    【讨论】:

      【解决方案2】:

      检查您的图片、PictureBox 图像的分辨率和图像属性 如果你想在图片上画画。

      【讨论】:

        猜你喜欢
        • 2017-06-06
        • 2010-11-28
        • 1970-01-01
        • 2017-06-10
        • 1970-01-01
        • 1970-01-01
        • 2013-01-16
        • 1970-01-01
        • 2011-12-13
        相关资源
        最近更新 更多