السلام عليكم اخوتي الأعزاء انا استخدم هذا الفنكشن لجلب الصوره في بيتشر بوكس هل يمكن التعديل عليه ليجلب أكثر من صيغه
كود :
Public Function GetImage2(path As String) As Image
Dim bmp As Image
Dim fs As New IO.FileStream("Data\" & path & ".jpg|.png", IO.FileMode.Open, IO.FileAccess.Read)
bmp = Image.FromStream(fs)
fs.Close()
fs = Nothing
Return bmp
End Function
(24-06-20, 06:17 PM)alshandodi كتب : [ -> ]السلام عليكم اخوتي الأعزاء انا استخدم هذا الفنكشن لجلب الصوره في بيتشر بوكس هل يمكن التعديل عليه ليجلب أكثر من صيغه
كود :
Public Function GetImage2(path As String) As Image
Dim bmp As Image
Dim fs As New IO.FileStream("Data\" & path & ".jpg|.png", IO.FileMode.Open, IO.FileAccess.Read)
bmp = Image.FromStream(fs)
fs.Close()
fs = Nothing
Return bmp
End Function
Public Sub Loadpicture(ByVal PictureBox1 As PictureBox)
Dim ofd As New OpenFileDialog()
ofd.Title = "Browse Picture"
ofd.Filter = "Image Files(*.BMP; *.JPG;*.GIF;*.PNG)|*.BMP; *.JPG;*.GIF;*.PNG"
If ofd.ShowDialog() = Windows.Forms.DialogResult.OK Then
PictureBox1.Image = Image.FromFile(ofd.FileName)
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
End If
End Sub
اخي العزيز هذا اذا كنت اجلب الصوره من مجلد معين هذا الكود لم ينفع شكرا جزيلا
وعليك السلام ورحمة الله وبركاته
يا اخي كودك يجلب اكثر من صيغة ، لاحظ انه يعطيك امكانية جلب صورة من نوع jpg او png
فقط كل ماعليك هو ان تضيف النوع الذي تريده بشرط ان تفصل بينه وبين الانواع الاخرى بالفاصل |
يعني كودك يجلب النوعين السابق ذكرهم
".jpg|.png" انت فقط اضف ".jpg|.png|.bmp"
كود :
Public Function GetImage2(path As String) As Image
Dim bmp As Image
Dim fs As New IO.FileStream("Data\" & path & ".jpg|.png|.gif| .bmp", IO.FileMode.Open, IO.FileAccess.Read)
bmp = Image.FromStream(fs)
fs.Close()
fs = Nothing
Return bmp
End Function
اشكرك جزيل الشكر اخي معاند فأنا لم انتبه انني قمت بتغير الكود ولكن لم اجربه بارك الله فيك ورزقك علما نافعا