[RESOLVED] Handling pictureboxes and zooming
Hi,
I have created a picture box(picture1) which will load an image. Within this picture box i have another smaller one (picture2) which is set to be background as transparent (still figuring out how to do this one from the other posts) and would like to move this small picbox with my mouse arnd and within the larger one. When click,that area within the small picbox would displayed like a zoom version enlarged in a new display(picture3).I understand theres many threads on this but Im not still not quite sure how to go about this. Ive never used APIs and strechblt as well. So if anyone could give me some pointers that would be great
thanks
Re: Handling pictureboxes and zooming
Are you asking for something like a BitBlt Tutorial?
Re: Handling pictureboxes and zooming
Hi hack,
Have looked at the link, I kinda understand what it does but i dont really know where to put the code or how to use it. Ive created a test project containing a module with the bitblt declarations. But what do I put in the form, or in the pictureboxes to invoke this properly? Would it be possible to give me a working example? That would help heaps..
Re: Handling pictureboxes and zooming
How about you upload your project and we can take a look at it for you?
1 Attachment(s)
Re: Handling pictureboxes and zooming
Hi,
Have uploaded the file, this is however just a test file to figure out how to do it. Ive manage to find an example on this forums for the transparent picturebox but would like the small picture box(Picture2) to display on a new picturebox when mousedown. And if Picture2 is clicked again it will zoom - say x2,x4,x8, and would display the selected area in Picture3. So each time it is click whatevers in the small picture box is displayed on the picture3.
If you can edit it and show me how it works that would be of great help.
Re: Handling pictureboxes and zooming
I have questions
when you display the picture in picturebox2 has the size been reduced?
has the picture been loaded from a file?
I ask this because it doesn't make sense to zoom in on a picture that is already displayed at its maximum resolution.
Re: Handling pictureboxes and zooming
I have posted this sample numerous times and some people did find it helpfull so here we go again:
VB Code:
Public Sub ZoomPicture(pct As PictureBox, zoom As Double)
With pct
.Width = .Width * zoom
.Height = .Height * zoom
.PaintPicture .Picture, 0, 0, .ScaleWidth, .ScaleHeight
End With
End Sub
'usage:
'control array of Command button (at least two instances) is needed to run this sample
Private Sub Command1_Click(index As Integer)
If index = 0 Then
ZoomPicture Picture1, 1.1
Else
ZoomPicture Picture1, 0.9
End If
End Sub
Re: Handling pictureboxes and zooming
The picture is loaded from a file and is not resized. I guess what Im trying to do is first enlarge the selection in Picture1 into the size of Picture3. Then when clicked, it will display the selection in a scale of 2x. For example if the selection(pic1) displays 30 grids, when clicked it will scale to 15grids of that area and display that 15grids in the size of pic3. I hope that explanation was right.
Hrrm as for the code above, Im not quite sure how to use that code within the test module. Is the ZoomPicture function with pct, pct being the picturebox that u click to zoom? like if that small picbox is clicked it will call the ZoomPicture function?
Sorry if its simple code and im not quite getting it.
Re: Handling pictureboxes and zooming
Could someone help me input rhinos code into the attachment please. I keep getting errors, maybe Im not putting the code correctly.
Re: Handling pictureboxes and zooming
Personally, I don't realy understand you potato, sorry man.
If you can provide some steps (or perhaps some sketch) maybe I can do something for you. :confused:
Re: Handling pictureboxes and zooming
Let's see if I understand the potato.
little picturebox is dragged around inside a bigger picturebox.
when the user relases the little picturebox, is grabs the potion of the big picture that is right under it.
Next the small portion is painted into a 3rd picture box which is bigger hence the zoom.
Re: Handling pictureboxes and zooming
Yup someting like that, basically when u move the small pic box watever that is in it will be displayed in picture 3. Similar to what moeur said. But the portion thats in the small box should fit the whole of picture3 and not be the same size as the small box.
1 Attachment(s)
Re: Handling pictureboxes and zooming
Re: Handling pictureboxes and zooming
Thanks heaps just what I needed
Re: [RESOLVED] Handling pictureboxes and zooming
I've just remembered that you don't have to use any API for this.
replace
VB Code:
StretchBlt Picture3.hdc, 0, 0, Picture3.Width, Picture3.Height, _
Picture1.hdc, Image1.Left, Image1.Top, Image1.Width, Image1.Height, vbSrcCopy
with
VB Code:
Picture3.PaintPicture Picture1.Picture, 0, 0, Picture3.Width, Picture3.Height, _
Image1.Left, Image1.Top, Image1.Width, Image1.Height
Re: [RESOLVED] Handling pictureboxes and zooming
I want to do something similar, but working with a land map.
The idea is to have two boxes, one, small, showing the entire map. The other one at full screen size with a detailed part of the same land map.
The user has to click somewhere in the small box to see the detailed area around the click point in the full screen picture.
Any working examples around?
Thanks, Nexus7