Home All Groups Group Topic Archive Search About

Crop/Zoom Image in Container

Author
22 Mar 2006 9:14 PM
DMCD
I want to allow my program users to:
1.   Open a jpg inside of a panel control
      (PictureBox control inside Panel control ... PictureBox picture set to
       user's jpg file selection);
2.   Zoom in and out on the jpg
      (change the picturebox size mode to zoom and scale the photo);
3.   Move the jpg up, down, left right within a container control
      (using the MouseDown and MouseMove events, I change the location
       of the jpg);
4.   Save the visible portion, at its zoom level, as a new jpg.
      (THIS IS MY PROBLEM)

I understand the DrawImage function and how it may be used to get a portion
of one image and "draw" it elsewhere. My problem is the coordinate system (I
think).

How do I specify the portion of the picture that is visible in the panel
(i.e., the source rectangle). My difficulty is compounded by the fact that
the image has been scaled.

Any help would be appreciated.

Thanks!

Author
23 Mar 2006 1:13 AM
james
Here is a link to a sample that will get you going. It's written with VB.Net
2002. But, should work.
james


http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=2D473451-21AA-4A0B-9060-E3D1CA40C74A





Show quoteHide quote
"DMCD" <D***@discussions.microsoft.com> wrote in message
news:57AE9250-4908-4550-B091-2DA7256A1DBA@microsoft.com...
>I want to allow my program users to:
> 1.   Open a jpg inside of a panel control
>      (PictureBox control inside Panel control ... PictureBox picture set
> to
>       user's jpg file selection);
> 2.   Zoom in and out on the jpg
>      (change the picturebox size mode to zoom and scale the photo);
> 3.   Move the jpg up, down, left right within a container control
>      (using the MouseDown and MouseMove events, I change the location
>       of the jpg);
> 4.   Save the visible portion, at its zoom level, as a new jpg.
>      (THIS IS MY PROBLEM)
>
> I understand the DrawImage function and how it may be used to get a
> portion
> of one image and "draw" it elsewhere. My problem is the coordinate system
> (I
> think).
>
> How do I specify the portion of the picture that is visible in the panel
> (i.e., the source rectangle). My difficulty is compounded by the fact that
> the image has been scaled.
>
> Any help would be appreciated.
>
> Thanks!
>
>
>