다음을 통해 공유


Renderer.PixelToInkSpace 메서드 (Graphics, Point%)

업데이트: 2007년 11월

변환 시 Graphics 개체를 사용하여 픽셀 공간 좌표의 위치를 잉크 공간 좌표의 위치로 변환합니다.

네임스페이스:  Microsoft.Ink
어셈블리:  Microsoft.Ink(Microsoft.Ink.dll)

구문

‘선언
Public Sub PixelToInkSpace ( _
    g As Graphics, _
    ByRef pt As Point _
)
‘사용 방법
Dim instance As Renderer
Dim g As Graphics
Dim pt As Point

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

매개 변수

설명

PixelToInkSpace 메서드는 픽셀을 잉크 공간으로 변환합니다. 잉크 공간에서 HIMETRIC 단위 하나는 0.01mm입니다. 그런 다음 뷰 변환의 역을 적용하고 개체 변환을 적용합니다.

예제

이 예제에서는 LeftInPixels 매개 변수 왼쪽(픽셀 공간)에 Point가 들어 있는 전달된 InkOverlay 개체의 모든 Stroke 개체를 삭제하는 메서드를 보여 줍니다.

Private Sub DeleteStrokesByLeft(ByVal mInkOverlay As InkOverlay, ByVal LeftInPixels As Integer)
    ' Create a Point object based upon the Left parameter
    Dim ptLeft As Point = New Point(LeftInPixels, 0)

    ' Convert the point from pixel space to ink space dimensions
    ' InkOverlay.AttachedControl must be set
    Using g As Graphics = mInkOverlay.AttachedControl.CreateGraphics()
        mInkOverlay.Renderer.PixelToInkSpace(g, ptLeft)
    End Using

    ' Create a Strokes object to hold strokes to be deleted
    Dim strokesToDelete As Strokes = mInkOverlay.Ink.CreateStrokes()

    ' Access to the Strokes property returns a copy of the Strokes object.
    ' This copy must be implicitly (via using statement) or explicitly
    ' disposed of in order to avoid a memory leak.
    Using currentStrokes As Strokes = mInkOverlay.Ink.Strokes
        For Each S As Stroke In currentStrokes
            For Each strokePoint As Point In S.GetPoints()
                If (strokePoint.X < ptLeft.X) Then
                    ' Note: A particluar Stroke object might have several
                    ' points to the left of ptLeft.X - Therefore, the
                    ' following statement will be executed multiple times.
                    ' Even so, the Add method will not add the same stroke twice. 
                    strokesToDelete.Add(S)
                End If
            Next
        Next
    End Using
    If strokesToDelete.Count > 0 Then
        mInkOverlay.Ink.DeleteStrokes(strokesToDelete)
        mInkOverlay.AttachedControl.Invalidate()
    End If
    strokesToDelete.Dispose()
End Sub
private void DeleteStrokesByLeft(InkOverlay mInkOverlay, int LeftInPixels)
{
    // Create a Point object based upon the Left parameter
    Point ptLeft = new Point(LeftInPixels, 0);

    // Convert the point from pixel space to ink space dimensions
    // InkOverlay.AttachedControl must be set
    using (Graphics g = mInkOverlay.AttachedControl.CreateGraphics())
    {
        mInkOverlay.Renderer.PixelToInkSpace(g, ref ptLeft);
    }

    // Create a Strokes object to hold strokes to be deleted
    Strokes strokesToDelete = mInkOverlay.Ink.CreateStrokes();

    // Access to the Strokes property returns a copy of the Strokes object.
    // This copy must be implicitly (via using statement) or explicitly
    // disposed of in order to avoid a memory leak.
    using (Strokes currentStrokes = mInkOverlay.Ink.Strokes)
    {
        foreach (Stroke S in currentStrokes)
        {
            foreach (Point strokePoint in S.GetPoints())
            {
                if (strokePoint.X < ptLeft.X)
                {
                    // Note: A particluar Stroke object might have several
                    // points to the left of ptLeft.X - Therefore, the
                    // following statement will be executed multiple times.
                    // Even so, the Add method will not add the same stroke twice. 
                    strokesToDelete.Add(S);
                }
            }
        }
    }

    if (strokesToDelete.Count > 0)
    {
        mInkOverlay.Ink.DeleteStrokes(strokesToDelete);
        mInkOverlay.AttachedControl.Invalidate();
    }
    strokesToDelete.Dispose();
}

플랫폼

Windows Vista

.NET Framework 및 .NET Compact Framework에서 모든 플랫폼의 전체 버전을 지원하지는 않습니다. 지원되는 버전의 목록을 보려면 .NET Framework 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

3.0에서 지원

참고 항목

참조

Renderer 클래스

Renderer 멤버

PixelToInkSpace 오버로드

Microsoft.Ink 네임스페이스

Renderer.InkSpaceToPixel