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

See also  How to Create and Deploy QR Codes Online: A Comprehensive Guide

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist