如何从图片框中获取图片? [英] How I can have a crop of picture from a picture box ?

查看:67
本文介绍了如何从图片框中获取图片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我想做一个软件来控制我的天文应用摄影的重点。

在我的表格中,我有两个图片框( strechimage)比较焦点之前和之后。我必须拍两张照片来比较一个明星的焦点。



所以,我想,当我点击这个图片框之一时(由strechimage减少) ),在另一个图片框中有一个1的细节。



你知道如何在图片框中捕捉鼠标的位置。详细信息?



谢谢(我希望我很清楚......)

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...)

推荐答案

First of所有,你不应该使用 PictureBox 。我过去的答案解释了原因和做法:

在图片框中附加图片 [ ^ ],

在C#中绘制一个矩形 [ ^ ],

如何从旧图纸中清除面板 [ ^ ],

什么样的俏皮方法是Paint? (DataGridViewImageCell.Paint(...)) [ ^ ],

在面板上捕获绘图 [ ^ ],

mdi子表单之间的绘制线 [ ^ ]。



现在,什么正在裁剪?鉴于上面讨论的考虑因素,您不必创建或修改位图。你有一个位图,但是你应该只渲染它的一部分,而不是重新采样原始图像。查看方法 System.Drawing.Graphics.DrawImage

http://msdn.microsoft.com/en-us/library/system.drawing.graphics.drawimage%28v=vs .110%29.aspx [ ^ ]。



首先,你可以控制一些较小的东西尺寸。如果您拍摄要复制的图像的负片原点,它将在顶部或左侧裁剪。此外,图像中超出控件客户区的部分将被裁剪。裁剪应该通过不同于整个客户区域的边界进行,您需要更多参数。具有一个矩形参数的方法将重新采样目标矩形的图像,因此您不应使用此方法。但是,具有两个矩形参数(源矩形和目标矩形)的方法可能会或可能不会重新采样图像。当两个矩形具有相同的确切大小时,它不会重新取样,因此您只能控制源图像上较小矩形的位置以及渲染它的位置。



-SA
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


这篇关于如何从图片框中获取图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆