使用vb.net 2008图形裁剪(System.Drawing.Drawing2D) [英] cropping using vb.net 2008 graphics (System.Drawing.Drawing2D)

查看:223
本文介绍了使用vb.net 2008图形裁剪(System.Drawing.Drawing2D)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个自动滚动设置的面板中有一个picturebox(origBox)。

在origBox上绘制了许多行。稍后,在origBox上绘制图形路径。现在我正在尝试裁剪并将origBox图片框内容(位图)的一部分放大到另一个图片框(cropBox)。裁剪和放大工作,但有一个问题:

我使用矩形来选择origBox的一部分。矩形覆盖直接在origBox上绘制的线条图像和在origBox上绘制的图形路径的一部分。但是,在cropBox上,仅显示选定的行;缺少选定的图形路径部分。



请有人解释为什么会这样吗?图形路径是不是通过复制图片框的一部分(例如origBox)位图来挑选的透明图层吗?



谢谢。

I have a picturebox (origBox) within a panel with auto scroll set on.
A number of lines are drawn on the origBox. Later on a graphics path is drawn on the origBox. Now I am trying to crop and magnify a part of the origBox picturebox contents (bitmap) to another picturebox (cropBox). The cropping and magnification work, but there is a problem:
I use a rectangle to select a part of the origBox. The rectangle covers image of the lines drawn directly on the origBox and part of the graphics path drawn on the origBox. However, on the cropBox, only the selected lines are displayed; the part of graphics path that was selected is missing.

Could anyone, please, explain why this happens? Is graphics path a transparent layer that is not picked by copying a part of a picturebox (eg. origBox) bitmap?

Thanks.

推荐答案

首先,你试图滥用 PictureBox ,因为太多了。这种控制完全没用,除非你想以非常简单的方式做一些非常简单的事情。在所有其他情况下,它只会引起麻烦,不给予任何回报。我会告诉你该怎么做。



请查看我过去的答案:

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

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

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



参见:

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

捕获面板上的图纸 [ ^ ],

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

如何加速我的vb.net应用程序? [ ^ ]。



放大由 System.Drawing.Graphics.Transform http://msdn.microsoft.com/en- us / library / system.drawing.graphics.transform.aspx [ ^ ]。



至于裁剪,根本不需要它(如果你是不是你唱 PictureBox 这只会搞砸它:-))。对于渲染(见上文),使用一些所需大小的控件,所有渲染都将被其边界裁剪。就这么简单。



-SA
First of all, you try to abuse PictureBox, as too many do. This control is totally useless, unless you want to do something very simple, in a very simplified way. In all other cases, it presents just hassled giving nothing in return. I''ll tell you what to do instead.

Please see my past answers:
How do I clear a panel from old drawing[^],
draw a rectangle in C#[^],
Append a picture within picturebox[^].

See also:
Drawing Lines between mdi child forms[^],
capture the drawing on a panel[^],
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[^],
How to speed up my vb.net application?[^].

And magnification is done by System.Drawing.Graphics.Transform: http://msdn.microsoft.com/en-us/library/system.drawing.graphics.transform.aspx[^].

As to cropping, it''s not needed at all (if you are not using PictureBox which will only screw up it :-)). For rendering (see above), use some control of required size, all rendering will be cropped by its bounds. As simple as that.

—SA


这篇关于使用vb.net 2008图形裁剪(System.Drawing.Drawing2D)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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