Click here to Skip to main content
15,888,301 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,
I want to do a software to control the focus of a photography for my astronomy application.
In my form, I've two pictures box (strechimage) to compare before and after the focus. I have to take two pictures to compare the focus on a star.

So, I would like, when I click on one of this picture box (reduced by the strechimage), have a detail in a scale of 1 in a other picture box.

Do you know how to capture the position of the mouse in the picture box toshow after the detail ?

Thank you (I hope i'm clear...)
Posted
Comments
Nelek 15-Nov-14 16:04pm    
Which technology, programming language? A bit more information would not harm, and even make faster to receive the help.

If you need to add or change content to your question or a previous solution, please use the "improve question / solution".
Sergey Alexandrovich Kryukov 15-Nov-14 19:39pm    
Do you mean VB.NET and .NET? You need to specify the language and platform. (The word "Basic" does not specify any certain language.)
—SA

1 solution

First of all, you should not use PictureBox. My past answers explain why and what to do instead:
Append a picture within picturebox[^],
draw a rectangle in C#[^],
How do I clear a panel from old drawing[^],
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[^],
capture the drawing on a panel[^],
Drawing Lines between mdi child forms[^].

Now, what is cropping? In view of the consideration discussed above, you don't have to create or modify a bitmap. You have a bitmap, but you should render only a part of it, but not resample the original image. Look at the methods System.Drawing.Graphics.DrawImage:
http://msdn.microsoft.com/en-us/library/system.drawing.graphics.drawimage%28v=vs.110%29.aspx[^].

First of all, you can have some control where you render of some smaller size. If you take negative origin of the image to be copied, it will be cropped on top or on left. Also, the part of the image beyond the control's client area will be cropped. It the cropping should occurs by the boundaries different from the whole client area, you need more parameters. The methods with one rectangle parameter will resample the image the the destination rectangle, so you should not use this method. However, the methods with two rectangle parameter (source and destination rectangles) may or may not resample the image. It won't resample it, apparently, when both rectangles are of the same exact size, so you only control the location of the smaller rectangle on the source image, and the place where you render it.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900