2016-10-06 2 views
-4

C# Windows Forms에서 Bitmap 개체가 있습니다. 이 Bitmap 객체의 원점 (축 시작 위치)은 왼쪽 상단 구석에 있습니다. 일반적인 그래프처럼 원점을 왼쪽 하단으로 어떻게 바꿀 수 있습니까? 고맙습니다!Windows Forms Bitmap에서 원점을 변경하는 방법은 무엇입니까?

+0

은 그게 가능하다고 생각하지 않습니다. 원하는 원점을 사용하는 클래스를 정의 할 수 있으며, 'Bitmap'의 데이터를 사용자 정의 객체로 복사하고이를 사용하여 작업 할 수 있습니다. 그러나'Bitmap'이 제공하는 많은 기능을 잃게됩니다. – adv12

+0

먼저 무엇을하려고 했습니까? –

+1

이것은 Windows가 작동하는 방식입니다 ... 완전히 정직하기 위해서는 그렇게 사용하는 것이 그리 어렵지 않습니다. 장기간에 걸쳐 이런 식으로 익숙해지면 훨씬 나아질 것입니다. 모든 컨트롤이 작동하는 방식이기 때문입니다. –

답변

1

다음 대답의 코드를 사용하여 그림 상자에서 Y 좌표를 뒤집을 수 있습니다.

flip coordinates when drawing to control

private void ScaleTransformFloat(PaintEventArgs e) 
{ 
    // Begin graphics container 
    GraphicsContainer containerState = e.Graphics.BeginContainer(); 

    // Flip the Y-Axis 
    e.Graphics.ScaleTransform(1.0F, -1.0F); 

    // Translate the drawing area accordingly 
    e.Graphics.TranslateTransform(0.0F, -(float)Height); 

    // Whatever you draw now (using this graphics context) will appear as 
    // though (0,0) were at the bottom left corner 
    e.Graphics.DrawRectangle(new Pen(Color.Blue, 3), 50, 0, 100, 40); 

    // End graphics container 
    e.Graphics.EndContainer(containerState); 

    // Other drawing actions here... 
} 
관련 문제