473,468 Members | 1,506 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

zoom in zoomout in vb6.0

19 New Member
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
Jul 7 '06 #1
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.. :)

Expand|Select|Wrap|Line Numbers
  1. There may be a way to this with a stretched image control, but this
  2. seems to work OK. New project, 2 picture boxes, 2 command buttons:
  3.  
  4. Option Explicit
  5. Private Const HALFTONE As Long = 4
  6. Private Declare Function StretchBlt Lib "gdi32" (ByVal hdc As Long, _
  7. ByVal x As Long, _
  8. ByVal y As Long, _
  9. ByVal nWidth As Long, _
  10. ByVal nHeight As Long, _
  11. ByVal hSrcDC As Long, _
  12. ByVal xSrc As Long, _
  13. ByVal ySrc As Long, _
  14. ByVal nSrcWidth As Long, _
  15. ByVal nSrcHeight As Long, _
  16. ByVal dwRop As Long) As Long
  17. Private Declare Function SetStretchBltMode Lib "gdi32" (ByVal hdc As Long, _
  18. ByVal nStretchMode As Long) As Long
  19. Private Sub Form_Load()
  20. With Picture2 'source
  21. .AutoRedraw = True
  22. .ScaleMode = vbPixels
  23. .Visible = False
  24. ' .AutoSize = True 'use if loading a graphic
  25. Picture2.Print "Some Picture Box Text"
  26. 'or .Picture = LoadPicture("c:\somefolder\somegraphic.bmp")
  27. End With
  28. With Picture1 'dest
  29. 'I've heard this improves quality
  30. SetStretchBltMode .hdc, HALFTONE
  31. .AutoRedraw = True
  32. .ScaleMode = vbPixels
  33. .Move 0, 0, Picture2.Width, Picture2.Height
  34. .Picture = Picture2.Picture
  35. End With
  36. Command1.Caption = "Zoom &In"
  37. Command2.Caption = "Zoom &Out"
  38. End Sub
  39. Private Sub Command1_Click()
  40. 'zoom in by 20%
  41. With Picture1
  42. .Move 0, 0, .Width * 1.2, .Height * 1.2
  43. .Cls
  44. StretchBlt .hdc, 0, 0, .ScaleWidth, .ScaleHeight, Picture2.hdc, 0, 0,
  45. Picture2.ScaleWidth, Picture2.ScaleHeight, vbSrcCopy
  46. End With 'Picture1
  47. End Sub
  48. Private Sub Command2_Click()
  49. 'zoom out by 20%
  50. With Picture1
  51. .Move 0, 0, .Width * 0.8, .Height * 0.8
  52. .Cls
  53. StretchBlt .hdc, 0, 0, .ScaleWidth, .ScaleHeight, Picture2.hdc, 0, 0,
  54. Picture2.ScaleWidth, Picture2.ScaleHeight, vbSrcCopy
  55. End With 'Picture1
  56. End Sub
  57.  
Jul 7 '06 #2
aworldwithoutsin
1 New Member
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.
Oct 23 '06 #3
Killer42
8,435 Recognized Expert Expert
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!
Oct 23 '06 #4
mruga
1 New Member
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.
Mar 24 '07 #5
Killer42
8,435 Recognized Expert Expert
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.
Mar 24 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
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...
0
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 ...
2
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 ...
1
by: muisjepiep | last post by:
hey this code works in IE but not in FF function ZoomFrames(obj) { if (isVisibleObject(document.getElementById("FRHEAD").style)) {...
4
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...
3
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...
0
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...
2
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
1
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...
0
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...
0
Oralloy
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,...
0
jinu1996
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...
1
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...
0
agi2029
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,...
1
isladogs
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...
0
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...
0
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 ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.