Re: Crop/Zoom Image in Container

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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





"DMCD" <DMCD@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:57AE9250-4908-4550-B091-2DA7256A1DBA@xxxxxxxxxxxxxxxx
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!





.



Relevant Pages

  • Re: Scale/Crop Image
    ... Open a jpg inside of a panel control ... (PictureBox control inside Panel control ... ... Zoom in and out on the jpg ...
    (microsoft.public.vb.winapi.graphics)
  • Sizing controls
    ... the PictureBox and the .jpg image as having ... This works perfectly on my development machine and on my Laptop, ... which run at fairly high screen resolutions. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: PictureBox Control Help
    ... if the jpg has a size of 1600 x 1200 pixels and your PictureBox has a size of 600 x 450 pixels then you will see just the top left corner of the picture. ... One other point to bear in mind is that the displayed jpg will have an aspect ratio which depends on the actual size of the clienmt area of the PictureBox, and this might not be the same as the aspect ratio of the original picture. ...
    (microsoft.public.vb.general.discussion)
  • Re: PictureBox Troubles Update
    ... into the autosized picturebox and is visible. ... As far as the StretchBlt function itself is concerned the ScaleMode of the PictureBoxes is not important, because the parameters you pass to the StretchBlt function are always interpreted by StretchBlt as pixel values. ... Then paste the following code into the Form and change the hard coded picture path "c:\temp\3638x2724.jpg" to the path/file name of your own large 3638x2724 pixel jpg. ...
    (microsoft.public.vb.general.discussion)
  • Re: PictureBox Control Help
    ... if the jpg has a size of 1600 x 1200 pixels and your PictureBox has a size of 600 x 450 pixels then you will see just the top left corner of the picture. ... One other point to bear in mind is that the displayed jpg will have an aspect ratio which depends on the actual size of the clienmt area of the PictureBox, and this might not be the same as the aspect ratio of the original picture. ...
    (microsoft.public.vb.general.discussion)