Renderer.PixelToInkSpace 方法 (Graphics, array<Point[]%)
通过使用用于转换的 Graphics 对象,将像素空间坐标中的位置数组转换为墨迹空间 坐标中的位置数组。
命名空间: Microsoft.Ink
程序集: Microsoft.Ink(在 Microsoft.Ink.dll 中)
语法
声明
Public Sub PixelToInkSpace ( _
g As Graphics, _
ByRef pts As Point() _
)
用法
Dim instance As Renderer
Dim g As Graphics
Dim pts As Point()
instance.PixelToInkSpace(g, pts)
public void PixelToInkSpace(
Graphics g,
ref Point[] pts
)
public:
void PixelToInkSpace(
Graphics^ g,
array<Point>^% pts
)
public void PixelToInkSpace(
Graphics g,
/** @ref */Point[] pts
)
public function PixelToInkSpace(
g : Graphics,
pts : Point[]
)
参数
- g
类型:System.Drawing.Graphics
要用于转换的 Graphics 对象。该对象通常来自于事件参数或 System.Windows.Forms.Control.CreateGraphics 方法。
- pts
类型:array<System.Drawing.Point[]%
要转换为墨迹空间位置的点的数组。
备注
PixelToInkSpace 方法从像素空间转换到墨迹空间(其中一个 HIMETRIC 单位 = .01mm),并应用视图变换的倒转,然后应用对象变换。
示例
在此示例中,InkOverlay 中至少 50% 的点位于边界选择内的 Stroke 对象将更改为红色。边界选择点描述一个围绕墨迹控件中心旋转 45 度的矩形。通过使用选择点创建一个 Stroke 对象可使边界选择可见。
Const RadiusPixel As Integer = 120
' get the control. InkOverlay.AttachedControl must be set
Dim inkControl As Control = mInkOverlay.AttachedControl
' get the center of the ink control
Dim centerPt As Point = New Point(inkControl.Width / 2, inkControl.Height / 2)
' create the boundary points. These points describe a rectangle
' that is rotated around the center 45 degrees (a diamond)
Dim boundaryPts() As Point = _
{ _
New Point(centerPt.X, centerPt.Y - (RadiusPixel / 2)), _
New Point(centerPt.X + (RadiusPixel / 2), centerPt.Y), _
New Point(centerPt.X, centerPt.Y + (RadiusPixel / 2)), _
New Point(centerPt.X - (RadiusPixel / 2), centerPt.Y), _
New Point(centerPt.X, centerPt.Y - (RadiusPixel / 2)) _
}
Using g As Graphics = inkControl.CreateGraphics()
' convert boundary points to ink space coordinates
mInkOverlay.Renderer.PixelToInkSpace(g, boundaryPts)
End Using
' show the tilted rectangle (diamond) by creating a stroke
mInkOverlay.Ink.CreateStroke(boundaryPts)
' Find strokes that are at least 50% inside the boundary points
Dim hitStrokes As Strokes = mInkOverlay.Ink.HitTest(boundaryPts, 50.0F)
' change the strokes that fall inside the boundary points to red
hitStrokes.ModifyDrawingAttributes(New DrawingAttributes(Color.Red))
' invalidate the ink control
inkControl.Invalidate()
const int RadiusPixel = 120;
// get the control. InkOverlay.AttachedControl must be set
Control inkControl = mInkOverlay.AttachedControl;
// get the center of the ink control
Point centerPt = new Point(inkControl.Width / 2, inkControl.Height / 2);
// create the boundary points. These points describe a rectangle
// that is rotated around the center 45 degrees (a diamond)
Point[] boundaryPts = new Point[5]
{
new Point(centerPt.X, centerPt.Y - (RadiusPixel / 2)),
new Point(centerPt.X + (RadiusPixel / 2), centerPt.Y),
new Point(centerPt.X, centerPt.Y + (RadiusPixel / 2)),
new Point(centerPt.X - (RadiusPixel / 2), centerPt.Y),
new Point(centerPt.X, centerPt.Y - (RadiusPixel / 2))
};
using (Graphics g = inkControl.CreateGraphics())
{
// convert boundary points to ink space coordinates
mInkOverlay.Renderer.PixelToInkSpace(g, ref boundaryPts);
}
// show the tilted rectangle (diamond) by creating a stroke
mInkOverlay.Ink.CreateStroke(boundaryPts);
// Find strokes that are at least 50% inside the boundary points
Strokes hitStrokes = mInkOverlay.Ink.HitTest(boundaryPts, 50.0f);
// change the strokes that fall inside the boundary points to red
hitStrokes.ModifyDrawingAttributes(new DrawingAttributes(Color.Red));
// invalidate the ink control
inkControl.Invalidate();
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。
版本信息
.NET Framework
受以下版本支持:3.0