Sdílet prostřednictvím


Renderer.PixelToInkSpace Method (Graphics, array<Point[]%)

Converts an array of locations in pixel space coordinates to be an array of locations in ink space coordinates by using a Graphics object for the conversion.

Namespace:  Microsoft.Ink
Assembly:  Microsoft.Ink (in Microsoft.Ink.dll)

Syntax

'Declaration
Public Sub PixelToInkSpace ( _
    g As Graphics, _
    ByRef pts As Point() _
)
'Usage
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 function PixelToInkSpace(
    g : Graphics, 
    pts : Point[]
)

Parameters

Remarks

The PixelToInkSpace method converts from pixel to ink space—where one HIMETRIC unit = .01mm, applies the inverse of the view transform, and then applies the object transform.

Examples

In this example, any Stroke objects of an InkOverlay that have at least 50% of their points inside a boundary selection are changed to red. The boundary selection points describe a rectangle that is rotated 45 degrees around the center of the ink control. The boundary selection is made visible by using the selection points to create a Stroke object.

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();

Platforms

Windows 7, Windows Vista, Windows Server 2008 R2, Windows Server 2008

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Version Information

.NET Framework

Supported in: 3.0

See Also

Reference

Renderer Class

Renderer Members

PixelToInkSpace Overload

Microsoft.Ink Namespace

Renderer.InkSpaceToPixel