02-04-20, 12:40 PM
السـلام عليكم روحمة الله وبركاته
عندي كود عبـاره عن تغيير مقاسات الصوره وهذا هو الكـود طبعاً وضعت الكود بعد التأكد من أختيار الصوره أقوم بتحويلها للمقاس وأرجاعها إلىأدارة الصور وأحفظ ويعمل الكود بالمره الأولى بشكل جميل
لكن عند المحاوله مره أخرى دون أقفال البرنامج يعطيني خطأ
كود الحفظ
نص الخطأ
صورة الخطأ
[attachment=24309]
[attachment=24310]
عندي كود عبـاره عن تغيير مقاسات الصوره وهذا هو الكـود طبعاً وضعت الكود بعد التأكد من أختيار الصوره أقوم بتحويلها للمقاس وأرجاعها إلىأدارة الصور وأحفظ ويعمل الكود بالمره الأولى بشكل جميل
لكن عند المحاوله مره أخرى دون أقفال البرنامج يعطيني خطأ
كود :
Dim bm As New Bitmap(Prd_Photos.Image)
Dim x As Int32 = 70
Dim y As Int32 = 64
Dim width As Integer = Val(x)
Dim height As Integer = Val(y)
Dim thumb As New Bitmap(width, height)
Dim g As Graphics = Graphics.FromImage(thumb)
g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
g.DrawImage(bm, New Rectangle(0, 0, width, height), New Rectangle(0, 0, bm.Width, _
bm.Height), GraphicsUnit.Pixel)
g.Dispose()
If IO.Directory.Exists(Application.StartupPath & "\Pics") = True Then
thumb.Save(Application.StartupPath & "\Pices\" & Code_Prd.Text + ".PNG", _
System.Drawing.Imaging.ImageFormat.Png)
Prd_Photos.Load(Application.StartupPath & "\Pices\" & Code_Prd.Text + ".PNG")
g.Dispose()
bm.Dispose()
thumb.Dispose()
Else
IO.Directory.CreateDirectory(Application.StartupPath & "\Pics")
thumb.Save(Application.StartupPath & "\Pices\" & Code_Prd.Text + ".PNG", _
System.Drawing.Imaging.ImageFormat.Png)
Prd_Photos.Load(Application.StartupPath & "\Pices\" & Code_Prd.Text + ".PNG")
End If
bm.Dispose()
thumb.Dispose()
g.Dispose()
كود الحفظ
كود :
Dim MS As New MemoryStream
Prd_Photos.Image.Save(MS, Prd_Photos.Image.RawFormat)
Dim Pic() As Byte = MS.ToArray
Parma(8) = New SqlParameter("@Prd_Photos", SqlDbType.Image) With {.Value = Pic}
نص الخطأ
كود :
An unhandled exception of type 'System.Runtime.InteropServices.ExternalException' occurred in System.Drawing.dll
Additional information: حدث خطأ عام في +GDI.
صورة الخطأ
[attachment=24309]
[attachment=24310]