Вопрос

I have this in 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

The problem is that "wheel.png" shows bigger in the PictureBox1 than it's original resolution and is like scaled and blurred. How can I fix this ?

Это было полезно?

Решение

Change the line :

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

by :

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

A rectangle specify the size, so You will not worry about the weird scaling. You could even have you image in a variable object, and accessing this object .Height and .Width to fix the DrawImage issue.

Другие советы

Check your image, the resolution and the image properties of the image of your PictureBox And if you want draw at picture.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top