473,388 Members | 1,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

zoom in zoomout in vb6.0

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 28075
sashi
1,754 Expert 1GB
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
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 Expert 8TB
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
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 Expert 8TB
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
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...

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.