Pregunta

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 ?

¿Fue útil?

Solución

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.

Otros consejos

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top