Freigeben über


Renderer.InkSpaceToPixel Method

Renderer.InkSpaceToPixel Method

Converts a location in ink space coordinates to be a location in pixel space by using a Graphics Leave Site object for the conversion.

Definition

Visual Basic .NET Public Sub InkSpaceToPixel( _
ByVal g As Graphics, _
ByRef pt As Point _
)
C# public void InkSpaceToPixel(
Graphics g,
ref Point pt
);
Managed C++ public: void InkSpaceToPixel(
Graphics *g,
Point **pt
);

Parameters

g System.Drawing.Graphics. The Graphics Leave Site object to use for conversion. This generally comes from event arguments or from the System.Windows.Forms.Control.CreateGraphics Leave Site method.
pt System.Drawing.Point. The point to convert into a pixel location.

Remarks

The InkSpaceToPixel method applies the object transform of the Renderer object, applies the view transform, and then converts from HIMETRIC to pixel units.

Examples

[C#]

This C# example takes the Ink from an InkOverlay object, theInkOverlay, and returns the bounding box of its associated Strokes collection, in pixel space.

using System.Drawing.Drawing2D;
...
public Rectangle GetInkBoundsInPixels(InkOverlay theInkOverlay)
{
    // Copy the bounding rectangle in ink space dimensions
    Rectangle theBoundingRectangle = theInkOverlay.Ink.GetBoundingBox();

    // Get the top left and bottom right points
    Point topLeft = theBoundingRectangle.Location;
    Point bottomRight = topLeft + theBoundingRectangle.Size;

    Graphics g = CreateGraphics();

    // Convert from ink space to pixel space
    theInkOverlay.Renderer.InkSpaceToPixel(g, ref topLeft);
    theInkOverlay.Renderer.InkSpaceToPixel(g, ref bottomRight);

    g.Dispose();

    return new Rectangle(topLeft,
        new Size(bottomRight.X - topLeft.X, bottomRight.Y - topLeft.Y));
}
            

[VB.NET]

This Microsoft® Visual Basic® .NET example takes the Ink from an InkOverlay object, theInkOverlay, and returns the bounding box of its associated Strokes collection, in pixel space.

Imports System.Drawing.Drawing2D
...
Public Function GetInkBoundsInPixels(ByVal theInkOverlay As InkOverlay) As Rectangle
    'Copy the bounding rectangle in ink space dimensions
    Dim theBoundingRectangle As Rectangle = theInkOverlay.Ink.GetBoundingBox()

    'Get the top left and bottom right points
    Dim topLeft As Point = theBoundingRectangle.Location
    Dim bottomRight As Point = _
        New Point(theBoundingRectangle.Right, theBoundingRectangle.Bottom)

    Dim g As Graphics = CreateGraphics()

    'Convert from ink space to pixel space
    theInkOverlay.Renderer.InkSpaceToPixel(g, topLeft)
    theInkOverlay.Renderer.InkSpaceToPixel(g, bottomRight)

    g.Dispose()

    Return New Rectangle(topLeft, _
            New Size(bottomRight.X - topLeft.X, bottomRight.Y - topLeft.Y))
End Function
                

See Also