CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2010
    Posts
    23

    How to crop an image that is zoomed(zoomed in/out)

    How to crop an image that is zoomed(zoomed in/out). Cropping works fine when the image is normal, that is not zoomed. I have used a panel whose AutoScroll property is true and a picturebox inside the panel whose sizemode property is AutoSize and BackgroundImageLayout is Tile.

    Load image:
    Image img = Image.FromFile("filepath");
    picBoxImageProcessing.Image = img;

    zoom in:

    zoomFactor += 1;
    picBoxImageProcessing.Size = new Size((img.Width * zoomFactor), (img.Height * zoomFactor));
    picBoxImageProcessing.SizeMode = PictureBoxSizeMode.StretchImage;

    cropping:
    Draw a rectangular shape on the image and then crop.
    Crop(Image img, Rectangle r)
    {
    //
    }

    In this way when i zoom in first and then select a specific region drawing a rectangle on the zoomed image and then crop then another region is cropped rather than i have selected.
    I have got many application for image processing but I couldn't solve my problem.

    thanks in advance.

  2. #2
    Join Date
    Oct 2010
    Posts
    23

    How to crop an image that is zoomed(zoomed in/out)

    How to crop an image that is zoomed(zoomed in/out). Cropping works fine when the image is normal, that is not zoomed. I have used a panel whose AutoScroll property is true and a picturebox inside the panel whose sizemode property is AutoSize and BackgroundImageLayout is Tile.

    Load image:
    Image img = Image.FromFile("filepath");
    picBoxImageProcessing.Image = img;

    zoom in:

    zoomFactor += 1;
    picBoxImageProcessing.Size = new Size((img.Width * zoomFactor), (img.Height * zoomFactor));
    picBoxImageProcessing.SizeMode = PictureBoxSizeMode.StretchImage;

    cropping:
    Draw a rectangular shape on the image and then crop.
    Crop(Image img, Rectangle r)
    {
    //
    }

    In this way when i zoom in first and then select a specific region drawing a rectangle on the zoomed image and then crop then another region is cropped rather than i have selected.
    I have got many application for image processing but I couldn't solve my problem.

    thanks in advance.

  3. #3
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: How to crop an image that is zoomed(zoomed in/out)

    Off the top of my head I would think you are not setting the right locations. If part of the picture is no longer visible then you may need to do some math to get the proper location accounting for the - top and/or left position of the image.
    Always use [code][/code] tags when posting code.

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

    Re: How to crop an image that is zoomed(zoomed in/out)

    [ Merged ]

    Please create only one thread per question

Tags for this Thread

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured