Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7865811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:11:58+00:00 2026-06-03T00:11:58+00:00

I have a image that is larger than the PictureEdit box issue is when

  • 0

I have a image that is larger than the PictureEdit box issue is when the Rectangle is created with the mouse the correct points on the image are not selected. It seems that it is selecting points in the PictureEdit not the image it self. I’m trying to crop the image and place the cropped image in a new Pictureedit. Example code below.

private void originalPictureEdit_MouseDown(object sender, MouseEventArgs e)
{
    //Point TextStartLocation = e.Location;
    Cursor = Cursors.IBeam;

    if (_drawStarted == false)
    {
        _drawStarted = true;

        if (e.Button == System.Windows.Forms.MouseButtons.Left)
        {
            Cursor = Cursors.Cross;

            _cropX = e.X;
            _cropY = e.Y;
            _selection = new Rectangle(new Point(e.X, e.Y), new Size());
            _cropPen = new Pen(Color.Black, 1);
            _cropPen.DashStyle = DashStyle.DashDotDot;
        }
    }

    originalPictureEdit.Refresh();
}

private void originalPictureEdit_MouseMove(object sender, MouseEventArgs e)
{

    if (originalPictureEdit.Image == null)
        return;

    if (e.Button == System.Windows.Forms.MouseButtons.Left)
    {
        originalPictureEdit.Refresh();
        _selection.Width = e.X - _selection.X;
        _selection.Height = e.Y - _selection.Y;
        originalPictureEdit.CreateGraphics().DrawRectangle(_cropPen, _cropX, _cropY, _selection.Width, _selection.Height);

    }          
}

private void originalPictureEdit_MouseUp(object sender, MouseEventArgs e)
{
     if (e.Button == MouseButtons.Left && _drawStarted && _selection.Size != new Size())
     {
         _croppedImage = (_displayedImage as Bitmap).Clone(_selection, _displayedImage.PixelFormat);

         modifiedPictureEdit.Image = _croppedImage;
         modifiedPictureEdit.Width = _croppedImage.Width;
         modifiedPictureEdit.Height = _croppedImage.Height;   
     }

     Cursor = Cursors.Default;

     _drawStarted = false;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T00:11:59+00:00Added an answer on June 3, 2026 at 12:11 am

    I needed to find the positions of the scrollbars. Here is the working code for MouseUp:

    private void pictureEdit1_MouseUp(object sender, MouseEventArgs e)
    {
           if (e.Button == MouseButtons.Left && _drawStarted && _selection.Size != new Size())
           {
                PictureEditViewInfo viewInfo = originalPictureEdit.GetViewInfo() as PictureEditViewInfo;
                PropertyInfo pr = viewInfo.GetType().GetProperty("HScrollBarPosition", BindingFlags.Instance | BindingFlags.NonPublic);
                int fHScrollBarPosition = (int)pr.GetValue(viewInfo, null);
                pr = viewInfo.GetType().GetProperty("VScrollBarPosition", BindingFlags.Instance | BindingFlags.NonPublic);
                int fVScrollBarPosition = (int)pr.GetValue(viewInfo, null);
                _selection.X += fHScrollBarPosition;
                _selection.Y += fVScrollBarPosition;
    
                Crop();
            }
    
            Cursor = Cursors.Default;
    
            _drawStarted = false;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UIImageView showing a image that is larger than it's frame. It's
I have an image in a that is larger than the . So I
I have this method that changes an larger image source on click. I need
I have a picture box set to AutoSize so that the image forces it
i want a background image that is larger than the content, which will remain
I have a textbox that may contain strings larger than the textbox size. When
I'm trying to show image files (jpg, png, gif) that can be larger than
I have a very large image that I would like to show a 200x200px
I have managed objects that have image properties. Since storing large blobs in CoreData
I have an interface that has large numbers of controls, see image below. Interface

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.