Renderer.InkSpaceToPixel 方法 (Graphics, Point%)

通过使用用于转换的 Graphics 对象,将墨迹空间 坐标中的位置转换成像素空间中的位置。

命名空间:  Microsoft.Ink
程序集:  Microsoft.Ink(在 Microsoft.Ink.dll 中)

语法

声明
Public Sub InkSpaceToPixel ( _
    g As Graphics, _
    ByRef pt As Point _
)
用法
Dim instance As Renderer
Dim g As Graphics
Dim pt As Point

instance.InkSpaceToPixel(g, pt)
public void InkSpaceToPixel(
    Graphics g,
    ref Point pt
)
public:
void InkSpaceToPixel(
    Graphics^ g, 
    Point% pt
)
public void InkSpaceToPixel(
    Graphics g,
    /** @ref */Point pt
)
public function InkSpaceToPixel(
    g : Graphics, 
    pt : Point
)

参数

备注

InkSpaceToPixel 方法应用 Renderer 对象的对象变换,再应用视图变换,然后从 HIMETRIC 转换到像素单位。

示例

此示例将获取 Ink 对象的边界框,并确定该边界框的中心。然后,将中心点转换到像素坐标,Graphics 对象使用该中心点绘制一个红色的小圆圈。

' get the ink bounds (ink space units)
Dim inkBounds As Rectangle = mInkOverlay.Ink.GetBoundingBox()
' create a Point in the center of the ink bounds (ink space units)
Dim centerPt As Point = _
       New Point(inkBounds.X + (inkBounds.Width / 2), _
                 inkBounds.Y + (inkBounds.Height / 2))

Using g As Graphics = mInkOverlay.AttachedControl.CreateGraphics()
    ' convert to pixel space
    mInkOverlay.Renderer.InkSpaceToPixel(g, centerPt)
    ' draw a small circle
    g.DrawEllipse(Pens.Red, centerPt.X - 5, centerPt.Y - 5, 10, 10)
End Using
// get the ink bounds (ink space units)
Rectangle inkBounds = mInkOverlay.Ink.GetBoundingBox();
// create a Point in the center of the ink bounds (ink space units)
Point centerPt = 
    new Point(inkBounds.X + (inkBounds.Width / 2), 
              inkBounds.Y + (inkBounds.Height / 2));

using (Graphics g = mInkOverlay.AttachedControl.CreateGraphics())
{
    // convert to pixel space
    mInkOverlay.Renderer.InkSpaceToPixel(g, ref centerPt);
    // draw a small circle
    g.DrawEllipse(Pens.Red, centerPt.X - 5, centerPt.Y - 5, 10, 10);
}

平台

Windows Vista

.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

Renderer 类

Renderer 成员

InkSpaceToPixel 重载

Microsoft.Ink 命名空间

Renderer.PixelToInkSpace