i am using a picturebox in my application when i will scan a image it will comes to pictuebox. my poblem is how to zoom in zoom out that image or picturebox
5 28095 sashi 1,754
Recognized Expert Top Contributor
Hi Kumar,
below is a sample code on howto zoom-in and zoom-out.. hope it's useful to you.. good luck my fren.. :) -
There may be a way to this with a stretched image control, but this
-
seems to work OK. New project, 2 picture boxes, 2 command buttons:
-
-
Option Explicit
-
Private Const HALFTONE As Long = 4
-
Private Declare Function StretchBlt Lib "gdi32" (ByVal hdc As Long, _
-
ByVal x As Long, _
-
ByVal y As Long, _
-
ByVal nWidth As Long, _
-
ByVal nHeight As Long, _
-
ByVal hSrcDC As Long, _
-
ByVal xSrc As Long, _
-
ByVal ySrc As Long, _
-
ByVal nSrcWidth As Long, _
-
ByVal nSrcHeight As Long, _
-
ByVal dwRop As Long) As Long
-
Private Declare Function SetStretchBltMode Lib "gdi32" (ByVal hdc As Long, _
-
ByVal nStretchMode As Long) As Long
-
Private Sub Form_Load()
-
With Picture2 'source
-
.AutoRedraw = True
-
.ScaleMode = vbPixels
-
.Visible = False
-
' .AutoSize = True 'use if loading a graphic
-
Picture2.Print "Some Picture Box Text"
-
'or .Picture = LoadPicture("c:\somefolder\somegraphic.bmp")
-
End With
-
With Picture1 'dest
-
'I've heard this improves quality
-
SetStretchBltMode .hdc, HALFTONE
-
.AutoRedraw = True
-
.ScaleMode = vbPixels
-
.Move 0, 0, Picture2.Width, Picture2.Height
-
.Picture = Picture2.Picture
-
End With
-
Command1.Caption = "Zoom &In"
-
Command2.Caption = "Zoom &Out"
-
End Sub
-
Private Sub Command1_Click()
-
'zoom in by 20%
-
With Picture1
-
.Move 0, 0, .Width * 1.2, .Height * 1.2
-
.Cls
-
StretchBlt .hdc, 0, 0, .ScaleWidth, .ScaleHeight, Picture2.hdc, 0, 0,
-
Picture2.ScaleWidth, Picture2.ScaleHeight, vbSrcCopy
-
End With 'Picture1
-
End Sub
-
Private Sub Command2_Click()
-
'zoom out by 20%
-
With Picture1
-
.Move 0, 0, .Width * 0.8, .Height * 0.8
-
.Cls
-
StretchBlt .hdc, 0, 0, .ScaleWidth, .ScaleHeight, Picture2.hdc, 0, 0,
-
Picture2.ScaleWidth, Picture2.ScaleHeight, vbSrcCopy
-
End With 'Picture1
-
End Sub
-
Hi, I am new to this site and am having the same problem. i want to zoom in to my mandelbrot image but am having trouble on what the heck to do. I have one button to load the madelbrot and was hoping to click on the picturebox to zoom. please help.
Hi, I am new to this site and am having the same problem. i want to zoom in to my mandelbrot image but am having trouble on what the heck to do. I have one button to load the madelbrot and was hoping to click on the picturebox to zoom. please help.
One fairly simple technique is to place an Image control inside a picturebox control. Set the Stretch property of the Image control to True. Then load your picture into it, and just change the size of the Image control.
You can set up scroll bars and based on their values, MOVE the Image control around (remember you can move to locations lower than zero) to scroll, as well as zoom.
Have fun!
Hi, I am new to this site and am having the same problem. i want to zoom in to my mandelbrot image but am having trouble on what the heck to do. I have one button to load the madelbrot and was hoping to click on the picturebox to zoom. please help.
hi, i want to modify this code a bit and get the picture zoom within picture box please help me out.
hi, i want to modify this code a bit and get the picture zoom within picture box please help me out.
I believe you can do that by simply changing the size of the imagebox control which is displaying the image. As long as the Stretch property is True, the image will change size with it.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Francis Parsons |
last post by:
Hi! I'm doubtful there's a workaround for this problem, but it's
worth a shot. I'm using IE's (css) "zoom" property to zoom the body
of a document (in conjunction with persistance so the...
|
by: davide rocchelli |
last post by:
I have found a probable bug when you draw with GDI.
Look this simple code
Private Sub Form1_Paint(ByVal sender As Object, ByVal e
As System.Windows.Forms.PaintEventArgs) Handles
MyBase.Paint
...
|
by: Mo Ade via .NET 247 |
last post by:
How do I write code to include a zoom feature in my project so that when my Vb Form loads an image I can click in my main menu zoom in or zoom out?
--------------------------------
From: Mo Ade
...
|
by: muisjepiep |
last post by:
hey
this code works in IE but not in FF
function ZoomFrames(obj)
{
if (isVisibleObject(document.getElementById("FRHEAD").style))
{...
|
by: Yoshitha |
last post by:
I'm developing windows application using c#.net (vs 2003), i've placed
several images (picture boxes) in panel control and i want to zoom the
panel control so that the images and text which...
|
by: jnag |
last post by:
I am trying to implement font changer, where I have links on the
banner of the site and when the user clicks on the links, the font
size of the page has to change. I tried...
|
by: murry19830507 |
last post by:
i want creat an web application(c#.net),which contains an image and one radiobutton list with 3 radiobuttons(zoom in ,zoom out ,zoom window)
when user checked on zoom in
imge has to be zoom
inthe...
|
by: sarika |
last post by:
Hi
I urgently need a script in php and ajax to pan and zoomin and zoomout
an image
plz help
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |