프로그래밍언어/VB.NET

화면위에 이미지그리기

부산딸랑이 2013. 9. 2. 16:06



Public Class Form1

    Declare Function GetDC Lib "user32.dll" ( _

  ByVal hwnd As Int32) As Int32


    Declare Function ReleaseDC Lib "user32.dll" ( _

      ByVal hwnd As Int32, _

      ByVal hdc As Int32) As Int32

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click



        Dim bmp As Bitmap = My.Resources.image_1

        Dim hdc As Int32 = GetDC(0)

        Dim g As Graphics = Graphics.FromHdc(New IntPtr(hdc))

        g.DrawImage(bmp, 10, 10)

        ReleaseDC(0, hdc)

        g.Dispose()

        bmp.Dispose()


    End Sub

End Class