Oppure

Loading
24/10/14 17:16
dnha
Sto creando una specie di "Screen Magnifier" ma ho notato che zoomando l'immagine (ricavata con la funzione GetMatrix()), la prima riga e la prima colonna di pixel vengono "tagliate" e così resta un bordo a destra e in basso...
Il problema è che non capisco cosa non vada nel codice :noway:

Allego Screenshot

Public Class frmMain
    Private Function GetMatrix() As Drawing.Image
        Dim bmp As Bitmap = New Bitmap(16, 16)
        Dim g As Graphics = Graphics.FromImage(bmp)
        g.CopyFromScreen(New Point(MousePosition.X - 8, MousePosition.Y - 8), New Point(0, 0), bmp.Size)
        Return bmp
    End Function
    Private Sub PictureBox1_Paint(sender As Object, e As PaintEventArgs) Handles PictureBox1.Paint
        e.Graphics.ScaleTransform(10, 10)
        e.Graphics.InterpolationMode = Drawing2D.InterpolationMode.NearestNeighbor
        e.Graphics.DrawImage(GetMatrix, 0, 0)
        'Linee solo per test
        e.Graphics.DrawLine(Pens.Black, New Point(8, 0), New Point(8, 5))
        e.Graphics.DrawLine(Pens.Black, New Point(8, 11), New Point(8, 16))
        e.Graphics.DrawLine(Pens.Black, New Point(0, 8), New Point(5, 8))
        e.Graphics.DrawLine(Pens.Black, New Point(11, 8), New Point(16, 8))
    End Sub
    Private Sub tmrMain_Tick(sender As Object, e As EventArgs) Handles tmrMain.Tick
        PictureBox1.Refresh()
    End Sub
End Class


P.S. Secondo voi è corretto ridisegnare il controllo ogni tick del timer o dovrei usare qualche altro metodo?
aaa