منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب
[سؤال] اظهار ضوء علي صورة - نسخة قابلة للطباعة

+- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb)
+-- قسم : قسم لغة الفيجوال بيسك VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=182)
+--- قسم : قسم اسئلة VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=183)
+--- الموضوع : [سؤال] اظهار ضوء علي صورة (/showthread.php?tid=2668)



اظهار ضوء علي صورة - ali.alfoly - 25-04-14

السلام عليكم ورحمة الله
عندي صورة داخل PictureBox الصورة لون واحد فقط مثال

اريد مثلا شئ من الجماليات
عند مرور الموس علي الصورة يظهر ضوء علي الصورة بلون معين احمر اصفر اخضر ازرق انا احدد اللون

وجزاكم الله خيرا


RE: اظهار ضوء علي صورة - vbnet - 25-04-14

(25-04-14, 03:39 PM)ali.alfoly كتب : السلام عليكم ورحمة الله
عندي صورة داخل PictureBox الصورة لون واحد فقط مثال

اريد مثلا شئ من الجماليات
عند مرور الموس علي الصورة يظهر ضوء علي الصورة بلون معين احمر اصفر اخضر ازرق انا احدد اللون

وجزاكم الله خيرا

مثال على السريع باستغلال PictureBox مع وضع الصور التي في المرفقات في Resources

(مع ملاحظة أن الصورة لا يكون لها هوامش فارغة - لذا قمت بتعديل الصورة التي منك إلى صورة بدون هوامش)

أضف أداة PictureBox
الإعدادت الهامة:
أضف الصورة main.png في BackgroundImage
عدل مقاس الأداء PictureBox إلى نفس مقاس الصورة mail.png وهنا المقاس Size: 48; 34
عدل الخاصية SizeMode إلى StretchImage

كود :
Public Class Form1

    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        ' حدث النقر
    End Sub

#Region "CustomButton"
    Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
        Me.PictureBox1.Image = My.Resources.black
    End Sub
    Private Sub PictureBox1_MouseEnterMouseUp(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseEnter, PictureBox1.MouseUp
        Me.PictureBox1.Image = My.Resources.white
    End Sub
    Private Sub PictureBox1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseLeave
        Me.PictureBox1.Image = Nothing
    End Sub
#End Region

End Class



RE: اظهار ضوء علي صورة - Aly El-Haddad - 25-04-14

img الصورة
col لون الضوء
opacity النسبة المئوية لمدى شفافية الضوء (رقم من 1 إلى 100)

كود :
Public Shared Function Light(ByVal img As System.Drawing.Image, ByVal col As System.Drawing.Color, ByVal opacity As Single) As System.Drawing.Image
        Dim rectangle As Rectangle
        Dim image As New Bitmap(img.Width, img.Height)
        Using graphics As Graphics = graphics.FromImage(image)
            rectangle = New Rectangle(0, 0, img.Width, img.Height)
            graphics.FillRectangle(New SolidBrush(col), rectangle)
        End Using
        Using graphics2 As Graphics = Graphics.FromImage(img)
            Dim imageAttr As New Imaging.ImageAttributes
            Dim newColorMatrix As Single()() = New Single()() {New Single() {2.0!, 0.0!, 0.0!, 0.0!, 0.0!}, New Single() {0.0!, 1.0!, 0.0!, 0.0!, 0.0!}, New Single() {0.0!, 0.0!, 1.0!, 0.0!, 0.0!}, New Single() {0.0!, 0.0!, 0.0!, opacity / 100, 0.0!}, New Single() {0.2!, 0.2!, 0.2!, 0.0!, 1.0!}}
            Dim matrix As New Imaging.ColorMatrix(newColorMatrix)
            imageAttr.SetColorMatrix(matrix, Imaging.ColorMatrixFlag.Default, Imaging.ColorAdjustType.Bitmap)
            rectangle = New Rectangle(0, 0, img.Width, img.Height)
            graphics2.DrawImage(image, rectangle, 0, 0, img.Width, img.Height, GraphicsUnit.Pixel, imageAttr)
        End Using
        Return img
    End Function



RE: اظهار ضوء علي صورة - ali.alfoly - 25-04-14

جزاكم الله خيرا اخواني
انا اقصد مثل هذا الموضوع
لاكني مش عارف انفذ الفكرة
http://helpdotnetvision.nevron.com/Presentation_Graphics_AppearanceStyles_ImageFiltersStyle_Lighting_Image_Filter.html


RE: اظهار ضوء علي صورة - Aly El-Haddad - 25-04-14

(25-04-14, 08:58 PM)ali.alfoly كتب : جزاكم الله خيرا اخواني
انا اقصد مثل هذا الموضوع
لاكني مش عارف انفذ الفكرة
http://helpdotnetvision.nevron.com/Presentation_Graphics_AppearanceStyles_ImageFiltersStyle_Lighting_Image_Filter.html

الرابط فيه مشكلة
عامتاً الفكرة إنك في الحدث MouseMove تغير الصورة بالصورة المضائة و في MouseLeave ترجع الصورة الطبيعية


RE: اظهار ضوء علي صورة - الشاكي لله - 25-04-14

في WPF ماتاخذ معاك ثانية وحدة


RE: اظهار ضوء علي صورة - ali.alfoly - 26-04-14

نعم اخي انا فهمت الدالة الي حدرتك طرحتها وهي ممتازة
لاكن طلب الضوء يكون من جهة معينة
وده الرابط اسف علي الرابط القديم
كود :
http://helpdotnetvision.nevron.com/Presentation_Graphics_AppearanceStyles_ImageFiltersStyle_Lighting_Image_Filter.html
اخي محمد الله يسامحك هههه
انا نفسي انتقل للـ WPF لاكن مشروعي انتهي ومستحيل اعدل مشروعي بالكامل


RE: اظهار ضوء علي صورة - Aly El-Haddad - 26-04-14

(26-04-14, 04:14 PM)ali.alfoly كتب : نعم اخي انا فهمت الدالة الي حدرتك طرحتها وهي ممتازة
لاكن طلب الضوء يكون من جهة معينة

كود :
Public Shared Function Light(ByVal img As System.Drawing.Image, ByVal col As System.Drawing.Color, ByVal opacity As Single, Optional ByVal direction As Drawing2D.LinearGradientMode = Drawing2D.LinearGradientMode.ForwardDiagonal) As System.Drawing.Image
        Dim rectangle As Rectangle
        Dim image As New Bitmap(img.Width, img.Height)
        Using graphics As Graphics = graphics.FromImage(image)
            rectangle = New Rectangle(0, 0, img.Width, img.Height)
            Dim brush As New Drawing2D.LinearGradientBrush(rectangle, col, Color.Transparent, direction)
            graphics.FillRectangle(brush, rectangle)
        End Using
        Using graphics2 As Graphics = Graphics.FromImage(img)
            Dim imageAttr As New Imaging.ImageAttributes
            Dim newColorMatrix As Single()() = New Single()() {New Single() {2.0!, 0.0!, 0.0!, 0.0!, 0.0!}, New Single() {0.0!, 1.0!, 0.0!, 0.0!, 0.0!}, New Single() {0.0!, 0.0!, 1.0!, 0.0!, 0.0!}, New Single() {0.0!, 0.0!, 0.0!, opacity / 100, 0.0!}, New Single() {0.2!, 0.2!, 0.2!, 0.0!, 1.0!}}
            Dim matrix As New Imaging.ColorMatrix(newColorMatrix)
            imageAttr.SetColorMatrix(matrix, Imaging.ColorMatrixFlag.Default, Imaging.ColorAdjustType.Bitmap)
            rectangle = New Rectangle(0, 0, img.Width, img.Height)
            graphics2.DrawImage(image, rectangle, 0, 0, img.Width, img.Height, GraphicsUnit.Pixel, imageAttr)
        End Using
        Return img
    End Function



RE: اظهار ضوء علي صورة - ali.alfoly - 27-04-14

تمام 100 100 جزاك الله خيرا
كتير علينا ده واللهHeartHeart