dcsimg
LinkedIn
Google+
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

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


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

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


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
Thanks for your registration, follow us on our social networks to keep up-to-date