Zoom in & out of an Image within a PictureBox - Page 2
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 26 of 26

Thread: Zoom in & out of an Image within a PictureBox

  1. #16
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Zoom in & out of an Image within a PictureBox

    Okay i've been playing a little with this code and i found something very interesting..

    the picturebox control's paintpicture method has just about what your looking for...
    Quote Originally Posted by VB Books Online
    Syntax
    object.PaintPicture picture, x1, y1, width1, height1, x2, y2, width2, height2, opcode

    The PaintPicture method syntax has these parts:
    Part Description

    object: Optional. An object expression that evaluates to an object in the Applies To list. If object is omitted, the Form object with the focus is assumed to be object.

    Picture: Required. The source of the graphic to be drawn onto object. Must be the Picture property of a Form or PictureBox.

    x1, y1: Required. Single-precision values indicating the destination coordinates (x-axis and y-axis) on object for picture to be drawn. The ScaleMode property of object determines the unit of measure used.

    Width1: Optional. Single-precision value indicating the destination width of picture. The ScaleMode property of object determines the unit of measure used. If the destination width is larger or smaller than the source width (width2), picture is stretched or compressed to fit. If omitted, the source width is used.

    Height1: Optional. Single-precision value indicating the destination height of picture. The ScaleMode property of object determines the unit of measure used. If the destination height is larger or smaller than the source height (height2), picture is stretched or compressed to fit. If omitted, the source height is used.
    After all this it might not take that much to add this funtionability to a picturebox...

    More when i'm done...

    Gremmy..
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  2. #17
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Zoom in & out of an Image within a PictureBox

    Okay here it is..

    I've used the Paintpicture method to do the Zoom on a Picturebox Control..

    The zoom worked better than i expected.. (but going higher than about 5* is not recomended, It's a bit ikky up there..)

    I have not completed adding in the code to make the Zoom work with the Crops.

    So if you crop then zoom, the picture snaps to the original uncropped pic..

    Will add this tomorrow, It's getting a bit late and i got a long work day ahead, so i need to get some sleep..

    Gremmy...

    ----- Edit -----

    Worked on it this morning and sorted it all out .. the zoom works with only picturebox's.. and is fully integrated with the crop application..

    i used a lot of variables and UDT's to enable this.. basically the original pic stays in the background, untouched.. a dummy pic shows the zoom, gets the selection for crop and apply's it to the original pic in the correct proportion..

    okay - enough of that...

    IT WORKS... try it...

    ----- REEDIT -----

    Newer file on later post...
    Last edited by GremlinSA; January 18th, 2007 at 02:45 PM.
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  3. #18
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Zoom in & out of an Image within a PictureBox

    Okay i worked a bit more on this (can you see i'm a little bored) ...

    Some issue's sorted:
    - Preview of crop is 1/2 Original and Not 1/2 Zoom anymore.
    - Image sliders reacts with zoom corectly.
    - Added a Selection box flasher routine (CPU stays at 0% while flashing )

    Slowcoder. All this app is missing now is the acctual editing code

    Gremmy//...
    Attached Files Attached Files
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  4. #19
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,092

    Re: Zoom in & out of an Image within a PictureBox

    Nice Work dude, nice!

  5. #20
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,722

    Re: Zoom in & out of an Image within a PictureBox

    Yeah, agreed. Big man in graphics programming, are ya?

  6. #21
    Join Date
    Apr 2004
    Posts
    4

    Thumbs up Re: Zoom in & out of an Image within a PictureBox

    man .... this is really GREAT work ....

    btw , i suggest converting it into VB.Net !
    maybe ...if you have some time

    that would be a more than great ...
    do u think it would be easier !

  7. #22
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,092

    Re: Zoom in & out of an Image within a PictureBox

    Quote Originally Posted by momoaal
    man .... this is really GREAT work ....

    btw , i suggest converting it into VB.Net !
    maybe ...if you have some time

    that would be a more than great ...
    do u think it would be easier !
    You could have a look at these articles I wrote ( in VB.NET ) for all types of graphics manipulation. The last part ( part IV ) deals with zooming, rotating and cropping. I hope you enjoy them

    Creating Your Own Drawing Application with Visual Basic .NET, Part 1
    http://www.codeguru.com/csharp/.net/...le.php/c13205/

    Creating Your Own Drawing Application with Visual Basic.NET, Part 2
    http://www.codeguru.com/csharp/.net/...le.php/c13207/

    Creating Your Own Drawing Application in Visual Basic.NET, Part 3
    http://www.codeguru.com/vb/gen/vb_gr...le.php/c13611/

    Creating Your Own Drawing Application in Visual Basic.NET, Part 4
    http://www.codeguru.com/vb/gen/vb_gr...cle.php/c14007

  8. #23
    Join Date
    Apr 2004
    Posts
    4

    Re: Zoom in & out of an Image within a PictureBox

    thanks ... i'll check it

  9. #24
    Join Date
    May 2008
    Posts
    1

    Re: Zoom in & out of an Image within a PictureBox

    Dear Sir,

    this is really a great example for me. Really you save me.
    Now i want to ask you a way to save that cropped image is there any way to save that Pic2's image ??

    Thanks
    Raghu

  10. #25
    Join Date
    Apr 2004
    Posts
    4

    Re: Zoom in & out of an Image within a PictureBox

    raghu_ktm ...

    try it .. it's very easy ....
    i tried it my self ... but i customed the save option according to my project ..
    and it works fine .........


    again ......... this is really .. really .... Masterpiece of work....
    thanks again .........

  11. #26
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Zoom in & out of an Image within a PictureBox

    You can simply add a button and add the SavePicture code into it..

    Look at this thread on how to use the SavePicture method..

    Gremmy...
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center