تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
كيفية ادارة صورة 360 درجة
#1
كاتب الموضوع : Friendassist

لادارة صورة بأي زاوية تحددها استخدم هذه الدالة :
كود :
[color=#000000][COLOR=#0000bb]  [/color][color=#007700]Private [/color][color=#0000bb]Sub rotate[/color][COLOR=#007700]()
        Try
            [/COLOR][COLOR=#dd0000]' Copy the output bitmap from the source image.
            Dim bm_in As New Bitmap(My.Resources.car)

            ' [/COLOR][color=#0000bb]Make an [/color][color=#007700]array [/color][COLOR=#0000bb]of points defining the
            [/COLOR][color=#dd0000]' image'[/color][color=#0000bb]s corners[/color][COLOR=#007700].
            [/COLOR][color=#0000bb]Dim wid [/color][color=#007700]As [/color][color=#0000bb]Single [/color][color=#007700]= [/color][color=#0000bb]bm_in[/color][color=#007700].[/color][COLOR=#0000bb]Width
            Dim hgt [/COLOR][color=#007700]As [/color][color=#0000bb]Single [/color][color=#007700]= [/color][color=#0000bb]bm_in[/color][color=#007700].[/color][COLOR=#0000bb]Height
            Dim corners [/COLOR][color=#007700]As [/color][color=#0000bb]Point[/color][color=#007700]() = { [/color][COLOR=#0000bb]_
                [/COLOR][color=#007700]New [/color][color=#0000bb]Point[/color][color=#007700]([/color][color=#0000bb]0[/color][color=#007700], [/color][color=#0000bb]0[/color][color=#007700]), [/color][COLOR=#0000bb]_
                [/COLOR][color=#007700]New [/color][color=#0000bb]Point[/color][color=#007700]([/color][color=#0000bb]wid[/color][color=#007700], [/color][color=#0000bb]0[/color][color=#007700]), [/color][COLOR=#0000bb]_
                [/COLOR][color=#007700]New [/color][color=#0000bb]Point[/color][color=#007700]([/color][color=#0000bb]0[/color][color=#007700], [/color][color=#0000bb]hgt[/color][color=#007700]), [/color][COLOR=#0000bb]_
                [/COLOR][color=#007700]New [/color][color=#0000bb]Point[/color][color=#007700]([/color][color=#0000bb]wid[/color][color=#007700], [/color][color=#0000bb]hgt[/color][COLOR=#007700])}

            [/COLOR][COLOR=#dd0000]' Translate to center the bounding box at the origin.
            Dim cx As Single = wid / 2
            Dim cy As Single = hgt / 2
            Dim i As Long
            For i = 0 To 3
                corners(i).X -= cx
                corners(i).Y -= cy
            Next i

            ' [/COLOR][color=#0000bb]Rotate[/color][COLOR=#007700].
            [/COLOR][color=#0000bb]Dim theta [/color][color=#007700]As [/color][color=#0000bb]Single [/color][color=#007700]= [/color][color=#0000bb]Single[/color][color=#007700].[/color][color=#0000bb]Parse[/color][color=#007700]([/color][color=#0000bb]txtAngle[/color][color=#007700].[/color][color=#0000bb]Text[/color][color=#007700]) * [/color][color=#0000bb]PI [/color][color=#007700]/ [/color][COLOR=#0000bb]180.0
            Dim sin_theta [/COLOR][color=#007700]As [/color][color=#0000bb]Single [/color][color=#007700]= [/color][color=#0000bb]Sin[/color][color=#007700]([/color][color=#0000bb]theta[/color][COLOR=#007700])
            [/COLOR][color=#0000bb]Dim cos_theta [/color][color=#007700]As [/color][color=#0000bb]Single [/color][color=#007700]= [/color][color=#0000bb]Cos[/color][color=#007700]([/color][color=#0000bb]theta[/color][COLOR=#007700])
            [/COLOR][color=#0000bb]Dim X [/color][color=#007700]As [/color][COLOR=#0000bb]Single
            Dim Y [/COLOR][color=#007700]As [/color][COLOR=#0000bb]Single
            [/COLOR][color=#007700]For [/color][color=#0000bb]i [/color][color=#007700]= [/color][COLOR=#0000bb]0 To 3
                X [/COLOR][color=#007700]= [/color][color=#0000bb]corners[/color][color=#007700]([/color][color=#0000bb]i[/color][color=#007700]).[/color][COLOR=#0000bb]X
                Y [/COLOR][color=#007700]= [/color][color=#0000bb]corners[/color][color=#007700]([/color][color=#0000bb]i[/color][color=#007700]).[/color][COLOR=#0000bb]Y
                corners[/COLOR][color=#007700]([/color][color=#0000bb]i[/color][color=#007700]).[/color][color=#0000bb]X [/color][color=#007700]= [/color][color=#0000bb]X [/color][color=#007700]* [/color][color=#0000bb]cos_theta [/color][color=#007700]+ [/color][color=#0000bb]Y [/color][color=#007700]* [/color][COLOR=#0000bb]sin_theta
                corners[/COLOR][color=#007700]([/color][color=#0000bb]i[/color][color=#007700]).[/color][color=#0000bb]Y [/color][color=#007700]= -[/color][color=#0000bb]X [/color][color=#007700]* [/color][color=#0000bb]sin_theta [/color][color=#007700]+ [/color][color=#0000bb]Y [/color][color=#007700]* [/color][COLOR=#0000bb]cos_theta
            Next i

            [/COLOR][COLOR=#dd0000]' Translate so X >= 0 and Y >=0 for all corners.
            Dim xmin As Single = corners(0).X
            Dim ymin As Single = corners(0).Y
            For i = 1 To 3
                If xmin > corners(i).X Then xmin = corners(i).X
                If ymin > corners(i).Y Then ymin = corners(i).Y
            Next i
            For i = 0 To 3
                corners(i).X -= xmin
                corners(i).Y -= ymin
            Next i

            ' [/COLOR][color=#0000bb]Create an output Bitmap [/color][color=#007700]and [/color][color=#0000bb]Graphics object[/color][COLOR=#007700].
            [/COLOR][color=#0000bb]Dim bm_out [/color][color=#007700]As New [/color][color=#0000bb]Bitmap[/color][color=#007700]([/color][color=#0000bb]CInt[/color][color=#007700](-[/color][color=#0000bb]2 [/color][color=#007700]* [/color][color=#0000bb]xmin[/color][color=#007700]), [/color][color=#0000bb]CInt[/color][color=#007700](-[/color][color=#0000bb]2 [/color][color=#007700]* [/color][color=#0000bb]ymin[/color][COLOR=#007700]))
            [/COLOR][color=#0000bb]Dim gr_out [/color][color=#007700]As [/color][color=#0000bb]Graphics [/color][color=#007700]= [/color][color=#0000bb]Graphics[/color][color=#007700].[/color][color=#0000bb]FromImage[/color][color=#007700]([/color][color=#0000bb]bm_out[/color][COLOR=#007700])

            [/COLOR][COLOR=#dd0000]' Drop the last corner lest we confuse DrawImage,  
            ' [/COLOR][color=#0000bb]which expects an [/color][color=#007700]array [/color][color=#0000bb]of three corners[/color][COLOR=#007700].
            [/COLOR][color=#0000bb]ReDim Preserve corners[/color][color=#007700]([/color][color=#0000bb]2[/color][COLOR=#007700])

            [/COLOR][COLOR=#dd0000]' Draw the result onto the output Bitmap.
            gr_out.DrawImage(bm_in, corners)

            ' [/COLOR][color=#0000bb]Display the result[/color][COLOR=#007700].
            [/COLOR][color=#0000bb]picDest[/color][color=#007700].[/color][color=#0000bb]Image [/color][color=#007700]= [/color][COLOR=#0000bb]bm_out
        [/COLOR][color=#007700]Catch [/color][color=#0000bb]ex [/color][color=#007700]As [/color][COLOR=#0000bb]Exception
            [/COLOR][COLOR=#007700]Return
        [/COLOR][color=#0000bb]End [/color][COLOR=#007700]Try
    [/COLOR][COLOR=#0000bb]End Sub  
[/COLOR][/COLOR]


و استعن بهذه المكتبات :
كود :
[color=#000000][COLOR=#0000bb]Imports System[/color][color=#007700].[/color][color=#0000bb]Drawing[/color][color=#007700].[/color][COLOR=#0000bb]Imaging
Imports System[/COLOR][color=#007700].[/color][color=#0000bb]Drawing[/color][color=#007700].[/color][COLOR=#0000bb]Drawing2D
Imports System[/COLOR][color=#007700].[/color][COLOR=#0000bb]Math  
[/COLOR][/COLOR]


و للاستعانة بالدالة قم بوضع اداة ليبل باسم txtAngle و اجعل قيمته الاولية بصفر ثم استخدم هذا الكود في اداة تايمر :
كود :
[color=#000000][COLOR=#0000bb] [/color][COLOR=#007700]Try
            [/COLOR][color=#0000bb]txtAngle[/color][color=#007700].[/color][color=#0000bb]Text [/color][color=#007700]+= [/color][COLOR=#0000bb]5
            rotate[/COLOR][COLOR=#007700]()
        Catch [/COLOR][color=#0000bb]ex [/color][color=#007700]As [/color][COLOR=#0000bb]Exception
        End [/COLOR][COLOR=#007700]Try  
[/COLOR][color=#0000bb][/color][/COLOR]


كود مماثل ولكنه غير قابل للاستمرار أي يعمل علي مره واحدة :
كود :
[color=#000000][COLOR=#0000bb] Dim img [/color][color=#007700]As [/color][color=#0000bb]Bitmap [/color][color=#007700]= New [/color][color=#0000bb]Bitmap[/color][color=#007700]([/color][color=#0000bb]My[/color][color=#007700].[/color][color=#0000bb]Resources[/color][color=#007700].[/color][color=#0000bb]car[/color][COLOR=#007700])
    Public Function [/COLOR][color=#0000bb]RotateImg[/color][color=#007700]([/color][color=#0000bb]ByVal bmpimage [/color][color=#007700]As [/color][color=#0000bb]Bitmap[/color][color=#007700], [/color][color=#0000bb]ByVal angle [/color][color=#007700]As [/color][color=#0000bb]Single[/color][color=#007700]) As [/color][COLOR=#0000bb]Bitmap
        Dim w [/COLOR][color=#007700]As [/color][color=#0000bb]Integer [/color][color=#007700]= [/color][color=#0000bb]bmpimage[/color][color=#007700].[/color][COLOR=#0000bb]Width
        Dim h [/COLOR][color=#007700]As [/color][color=#0000bb]Integer [/color][color=#007700]= [/color][color=#0000bb]bmpimage[/color][color=#007700].[/color][COLOR=#0000bb]Height
        Dim pf [/COLOR][color=#007700]As [/color][color=#0000bb]PixelFormat [/color][color=#007700]= [/color][COLOR=#0000bb]Nothing
        pf [/COLOR][color=#007700]= [/color][color=#0000bb]bmpimage[/color][color=#007700].[/color][COLOR=#0000bb]PixelFormat
        Dim tempImg [/COLOR][color=#007700]As New [/color][color=#0000bb]Bitmap[/color][color=#007700]([/color][color=#0000bb]w[/color][color=#007700], [/color][color=#0000bb]h[/color][color=#007700], [/color][color=#0000bb]pf[/color][COLOR=#007700])
        [/COLOR][color=#0000bb]Dim g [/color][color=#007700]As [/color][color=#0000bb]Graphics [/color][color=#007700]= [/color][color=#0000bb]Graphics[/color][color=#007700].[/color][color=#0000bb]FromImage[/color][color=#007700]([/color][color=#0000bb]tempImg[/color][COLOR=#007700])
        [/COLOR][color=#0000bb]g[/color][color=#007700].[/color][color=#0000bb]DrawImageUnscaled[/color][color=#007700]([/color][color=#0000bb]bmpimage[/color][color=#007700], [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]1[/color][COLOR=#007700])
        [/COLOR][color=#0000bb]g[/color][color=#007700].[/color][color=#0000bb]Dispose[/color][COLOR=#007700]()
        [/COLOR][color=#0000bb]Dim path [/color][color=#007700]As New [/color][color=#0000bb]GraphicsPath[/color][COLOR=#007700]()
        [/COLOR][color=#0000bb]path[/color][color=#007700].[/color][color=#0000bb]AddRectangle[/color][color=#007700](New [/color][color=#0000bb]RectangleF[/color][color=#007700]([/color][color=#0000bb]0.0F[/color][color=#007700], [/color][color=#0000bb]0.0F[/color][color=#007700], [/color][color=#0000bb]w[/color][color=#007700], [/color][color=#0000bb]h[/color][COLOR=#007700]))
        [/COLOR][color=#0000bb]Dim mtrx [/color][color=#007700]As New [/color][color=#0000bb]Matrix[/color][COLOR=#007700]()
        [/COLOR][color=#0000bb]Using System[/color][color=#007700].[/color][color=#0000bb]Drawing[/color][color=#007700].[/color][color=#0000bb]Drawing2D[/color][color=#007700].[/color][color=#0000bb]Matrix [/color][COLOR=#007700]class

        [/COLOR][color=#0000bb]mtrx[/color][color=#007700].[/color][color=#0000bb]Rotate[/color][color=#007700]([/color][color=#0000bb]angle[/color][COLOR=#007700])
        [/COLOR][color=#0000bb]Dim rct [/color][color=#007700]As [/color][color=#0000bb]RectangleF [/color][color=#007700]= [/color][color=#0000bb]path[/color][color=#007700].[/color][color=#0000bb]GetBounds[/color][color=#007700]([/color][color=#0000bb]mtrx[/color][COLOR=#007700])
        [/COLOR][color=#0000bb]Dim newImg [/color][color=#007700]As New [/color][color=#0000bb]Bitmap[/color][color=#007700]([/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToInt32[/color][color=#007700]([/color][color=#0000bb]rct[/color][color=#007700].[/color][color=#0000bb]Width[/color][color=#007700]), [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToInt32[/color][color=#007700]([/color][color=#0000bb]rct[/color][color=#007700].[/color][color=#0000bb]Height[/color][color=#007700]), [/color][color=#0000bb]pf[/color][COLOR=#007700])
        [/COLOR][color=#0000bb]g [/color][color=#007700]= [/color][color=#0000bb]Graphics[/color][color=#007700].[/color][color=#0000bb]FromImage[/color][color=#007700]([/color][color=#0000bb]newImg[/color][COLOR=#007700])
        [/COLOR][color=#0000bb]g[/color][color=#007700].[/color][color=#0000bb]TranslateTransform[/color][color=#007700](-[/color][color=#0000bb]rct[/color][color=#007700].[/color][color=#0000bb]X[/color][color=#007700], -[/color][color=#0000bb]rct[/color][color=#007700].[/color][color=#0000bb]Y[/color][COLOR=#007700])
        [/COLOR][color=#0000bb]g[/color][color=#007700].[/color][color=#0000bb]RotateTransform[/color][color=#007700]([/color][color=#0000bb]angle[/color][COLOR=#007700])
        [/COLOR][color=#0000bb]g[/color][color=#007700].[/color][color=#0000bb]InterpolationMode [/color][color=#007700]= [/color][color=#0000bb]InterpolationMode[/color][color=#007700].[/color][COLOR=#0000bb]HighQualityBilinear
        g[/COLOR][color=#007700].[/color][color=#0000bb]DrawImageUnscaled[/color][color=#007700]([/color][color=#0000bb]tempImg[/color][color=#007700], [/color][color=#0000bb]0[/color][color=#007700], [/color][color=#0000bb]0[/color][COLOR=#007700])
        [/COLOR][color=#0000bb]g[/color][color=#007700].[/color][color=#0000bb]Dispose[/color][COLOR=#007700]()
        [/COLOR][color=#0000bb]tempImg[/color][color=#007700].[/color][color=#0000bb]Dispose[/color][COLOR=#007700]()
        Return [/COLOR][COLOR=#0000bb]newImg
    End [/COLOR][COLOR=#007700]Function  
[/COLOR][color=#0000bb][/color][/COLOR]


للاستخدام :
كود :
[color=#000000][COLOR=#0000bb] picDest[/color][color=#007700].[/color][color=#0000bb]Image [/color][color=#007700]= [/color][color=#0000bb]RotateImg[/color][color=#007700]([/color][color=#0000bb]img[/color][color=#007700], [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToUInt64[/color][color=#007700]([/color][color=#0000bb]90[/color][COLOR=#007700]))  
[/COLOR][color=#0000bb][/color][/COLOR]

}}}}
تم الشكر بواسطة:


المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  البرنامج بعد وضعه في صورة exe لا يتعامل مع قاعدة البيانات محمد خلف زكي 0 94 04-08-16, 05:10 AM
آخر رد: محمد خلف زكي
  شرح كيفية صنع محرر html واستخدامه كـ dll سعود 6 1,595 26-08-13, 09:21 PM
آخر رد: Sajad
  شرح كيفية برمجة( مثال نسخ الملفات من مكان انت تحدده الى مكان انت تحدده بامتداد انت تحدده) سعود 1 1,025 16-08-13, 04:09 PM
آخر رد: ali.alfoly
  دالة الجذر (تأتي بالجذر من أية درجة و لأي رقم) Aly El-Haddad 0 666 07-12-12, 03:53 PM
آخر رد: Aly El-Haddad
  كيفية عمل صورة - مدورة - Rouded PictureBox ! RaggiTech 0 736 17-10-12, 09:55 PM
آخر رد: RaggiTech
  كيفية عمل String عشوائي ! RaggiTech 0 525 17-10-12, 09:54 PM
آخر رد: RaggiTech
  تدوير صورة حول مركزها باستخدام gdi+ RaggiTech 0 632 17-10-12, 09:30 PM
آخر رد: RaggiTech
  فائدة - كيفية عمل Ping RaggiTech 0 1,140 17-10-12, 09:00 PM
آخر رد: RaggiTech
  نسخ صورة النافذه المفتوحه Screen capture RaggiTech 0 361 17-10-12, 08:27 PM
آخر رد: RaggiTech
  تعلم كيف تفتح صورة من رابط داخل ال Picture box RaggiTech 0 474 17-10-12, 08:21 PM
آخر رد: RaggiTech

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم