Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Intermediate
May 21, 2001

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 Explicit

Dim LastX As Single
Dim LastY As Single

Public 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, vbSrcCopy
End Sub

Private Sub Picture1_MouseMove(Button As Integer, 
Shift As Integer, X As 
Single, Y As Single)
    ZoomPicture Picture1.Image, X, Y, Picture2
    LastX = X
    LastY = Y
End Sub

Private Sub Picture2_Paint()
    ZoomPicture Picture1.Image, LastX, LastY, Picture2
End Sub
Andreas Hillqvist
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap