変換用の 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 メソッドは、ピクセル空間からインク空間に変換し (1 HIMETRIC 単位 = 0.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