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 單位 = .01 公釐),反轉檢視轉換,然後套用物件轉換。
範例
在這個範例中,如果 InkOverlay 的任何 Stroke 物件有至少 50% 的點落在選取界限內,就會變更為紅色。選取界限點所形成的矩形,是以筆墨控制項的中心點旋轉 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