Home > Software engineering >  Visual Studio 2013 how to draw graphics zoom in Picturebox center
Visual Studio 2013 how to draw graphics zoom in Picturebox center

Time:10-01

My code is as follows:
 Private Sub mControl_TextChanged (ByVal sender As System. Object, ByVal e the As System. EventArgs) Handles TXTFW. The TextChanged, 
TXTFH. The TextChanged, TXTS. The TextChanged TXTDW. The TextChanged, TXTDH. The TextChanged, txtSD. The TextChanged, txtWT. The TextChanged, txtER. The TextChanged, txtSBD. The TextChanged
'the Show Picture C
Dim fw, fh d, dw, dh As Single
Fw=Val (TXTFW. Text)
Fh=Val (TXTFH. Text)
D=Val (TXTS. Text)
Dw=Val (TXTDW. Text)
Dh=Val (TXTDH. Text)
PicP. CreateGraphics. Clear (Color. White)
PicP. CreateGraphics. FillRectangle (Brushes. Blue, d, 0, dw, dh)
PicP. CreateGraphics. FillRectangle (Brushes. Gray, 0, dh, fw, dh)
End Sub

This has been a problem, if the value of the input is too small picture in the upper left corner as shown in figure 1,

Figure 1

CodePudding user response:

 Dim fw, fh d, dw, dh As Single 
Fw=Val (TXTFW. Text)
Fh=Val (TXTFH. Text)
D=Val (TXTS. Text)
Dw=Val (TXTDW. Text)
Dh=Val (TXTDH. Text)
Dim gw As Single=Math. Max (d + dw, fw) 'wide images'
Dim gh As Single=dh + fh 'high images'
As Single Dim r=Math. Min (picP. Width/gw, picP Height/gh) 'scale'
PicP. CreateGraphics. Clear (Color. White)
PicP. CreateGraphics. FillRectangle (Brushes. Blue, d * r, 0, dw * r, dh * r)
PicP. CreateGraphics. FillRectangle (Brushes. Gray, 0, dh * r, fw * r, dh * r)
  • Related