Using the PaintPicture Method

Using the PaintPicture Method

It is possible to use the PaintPicture Method of the PictureBox or Form by entering different dimensions for source height/width and destination dimensions.
Here is a sample:
1) Create a new Standard EXE Project.
2) Add two PictureBoxes to Form1.
3) Make Picture1 Larger then Picture2.
4) Add any picture to the Picture1 control.
5) Past the following lines of code into Form1:

 Option ExplicitDim LastX As SingleDim LastY As SinglePublic Sub ZoomPicture(Picture As StdPicture, X As Single, Y As Single, ZoomWindow As PictureBox, Optional Factor As Byte = 2)    ZoomWindow.PaintPicture Picture, 0, 0, ZoomWindow.ScaleWidth, ZoomWindow.ScaleHeight, X, Y, ZoomWindow.ScaleWidth / Factor, ZoomWindow.ScaleHeight / Factor, vbSrcCopyEnd SubPrivate Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)    ZoomPicture Picture1.Image, X, Y, Picture2    LastX = X    LastY = YEnd SubPrivate Sub Picture2_Paint()    ZoomPicture Picture1.Image, LastX, LastY, Picture2End Sub



Share the Post: