i'm using visual basic 6...
i build these procedure:
i don't know what isn't right with these procedure...Code:Option Explicit Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long Public Sub RotateImage(PicDestiny As PictureBox, PicSource As PictureBox, Angle As Long, Optional PosX As Long = 0, Optional PosY As Long = 0) Dim X1 As Long Dim Y1 As Long Dim X2 As Long Dim Y2 As Long Dim X As Long Dim Y As Long Dim result As Long Const PI = 3.14 'Clear the picture destiny PicDestiny.Cls Angle = Angle * (PI / 180) For X1 = 0 To PicSource.Width For Y1 = 0 To PicSource.Height result = GetPixel(PicSource.hdc, X1, Y1) If result <> -1 Then 'Calculate the position in a circule by using the center X, Y X = X1 - (PicSource.Width / 2) Y = Y1 - (PicSource.Height / 2) 'Calculate the new position X2 = (X * Cos(Angle) - Y * Sin(Angle)) + (PicSource.Height / 2) Y2 = (X * Sin(Angle) + Y * Cos(Angle)) + (PicSource.Width / 2) 'After changed, put the pixel in new position in picDestiny SetPixel PicDestiny.hdc, X2, Y2, GetPixel(PicSource.hdc, X1, Y1) End If Next Y1 Next X1 End Sub
you can see the error in an output picturebox, in bottom image...
i don't know why i can see transparent pixels...
can anyone help me fix these bug?
thanks





Reply With Quote