I am begginer in programming languages so I wanted to start with something easy like Visual studio (Visual basic language). Currently trying to figure out why is it that using this kind of code, images inserted into my form via code is bigger then actually they should be…
My first project is to create analog clock that can be skinned via Photoshop, but this thing with image sizing is driving me crazy.
It would be very good if someone could explain me why is this happening…
Code and result below:
Public Class Form1
'25x25 white rectangle image
Dim rec As Image = Image.FromFile("c:\img\rectangle.png")
Private Sub pic_Paint(sender As Object, e As PaintEventArgs) Handles pic.Paint
'Declaring graphics
Dim g As Graphics = e.Graphics
'Drawing image into PictureBox called pic
g.DrawImage(rec, 200, 200)
End Sub
End Class

Thank you!
It’s possible you’re not running at 96dpi (your titlebar looks a bit big to me) or the 25×25 image you’re using has a DPI metadata field that tells GDI (the graphics system in Windows) to draw it with scaled dimensions.
I recommend using the
SetResolutionmethod of theBitmapclass or fiddling around with theDrawImageoverloads.