09-06-19, 05:17 PM (آخر تعديل لهذه المشاركة : 09-06-19, 05:31 PM {2} بواسطة سعود.)
لاحظت اخي الكريم انك عرفت متغير ولم تسند له اي قيمة
Public Img() As Byte = Nothing
اختر اي حدث لتعيين قيمة له اما بعد انشاء الرسم او قبل الحفظ
كود لم اجربه
PHP كود :
Dim ms As New MemoryStream PbChart_pic.Image.Save(ms, PbChart_pic.Image.RawFormat) Img = ms.ToArray
زر الحفظ بعد التعديل
كود :
Dim ms As New MemoryStream
PbChart_pic.Image.Save(ms, PbChart_pic.Image.RawFormat)
Img = ms.ToArray
InsertNewRowIn_Member_Tbl(TxtMember_ID.Text, TxtMember_name.Text, DtpMember_Date.Text, TxtMember_age.Text, TxtMember_Wieght.Text, TxtMember_hight.Text, TxtBrotin.Text, TxtKrpohidrat.Text, TxtDohon.Text, Img)
وقعت بخطا اخر!!!
ماهو نوع الصورة التي تم انشاءها؟؟؟
09-06-19, 05:52 PM (آخر تعديل لهذه المشاركة : 09-06-19, 05:54 PM {2} بواسطة سعود.)
لقيت الحل
PHP كود :
Dim Img0 As New Bitmap(PbChart_pic.Width, PbChart_pic.Height) Dim G As Graphics = Graphics.FromImage(Img0) Dim R As New Rectangle(0, 0, PbChart_pic.Width, PbChart_pic.Height) G.FillRectangle(Brushes.Yellow, R) G.DrawRectangle(Pens.Black, R) Dim ms As New MemoryStream Img0.Save(ms, Imaging.ImageFormat.Png) Img = ms.ToArray G.Dispose()
هذا يحول الصورة التي تم انشاءها لصورة عادية ثم يتم تحويلها الى بناري ثم تسند للمتغير img
بعد كود انشاء الرسم البياني اكتب هذا
PHP كود :
Dim Img0 As New Bitmap(PbChart_pic.Width, PbChart_pic.Height) Dim G As Graphics = graphics.FromImage(Img0) Dim R As New Rectangle(0, 0, PbChart_pic.Width, PbChart_pic.Height) G.FillRectangle(Brushes.Yellow, R) G.DrawRectangle(Pens.Black, R) Dim ms As New MemoryStream Img0.Save(ms, Imaging.ImageFormat.Png) Img = ms.ToArray G.Dispose()
09-06-19, 06:27 PM (آخر تعديل لهذه المشاركة : 09-06-19, 06:36 PM {2} بواسطة aljzazy.)
كل الشكر اخ سعود ساقوم بالتجربة واخبارك بالنتيجة
قمت بتجربة عملية الحفظ سريعا" وكانت النتيجة سليمة
ساقوم بتجربة استدعاء الصور من القاعدة لمعرفة اذا ما تمت عملية الحفظ بنجاح
مشكور على تعاونك وجزاك الله كل الخير
حياك الله اخ سعود
عملية الحفظ تتم لصورة صفراء بالكامل لاحظ الصورة
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim i1 As Decimal = TxtBrotin.Text Dim i2 As Decimal = TxtKrpohidrat.Text Dim i3 As Decimal = TxtDohon.Text Dim total As Decimal = i1 + i2 + i3 Dim deg1 As Decimal = (i1 / total) * 360 Dim deg2 As Decimal = (i2 / total) * 360 Dim deg3 As Decimal = (i3 / total) * 360 Dim pen As New Pen(Color.Black, 2)
Dim Img0 As New Bitmap(PbChart_pic.Width, PbChart_pic.Height) Dim graphics As Graphics = PbChart_pic.CreateGraphics()
Dim rect As New Rectangle(50, 25, 200, 200) Dim brush1 As New SolidBrush(Color.Green) Dim brush2 = New SolidBrush(Color.Yellow) Dim brush3 = New SolidBrush(Color.Red) Dim G As Graphics = graphics.FromImage(Img0) G.Clear(PbChart_pic.BackColor) G.FillPie(brush1, rect, 0, deg1) G.FillPie(brush2, rect, deg1, deg2) G.FillPie(brush3, rect, deg1 + deg2, deg3) Dim ms As New MemoryStream Img0.Save(ms, Imaging.ImageFormat.Png) Img = ms.ToArray PbChart_pic.Image = Image.FromStream(ms) G.Dispose() mytotal() End Sub
سبحان الله وبحمده سبحان الله العظيم و الحمد لله ولا اله الا الله والله اكبر
بارك الله بكم جميعا"
الحمدلله تم حل المشكلة بعد تعديل الكود كالتالي :
كود :
Dim i1 As Decimal = TxtBrotin.Text
Dim i2 As Decimal = TxtKrpohidrat.Text
Dim i3 As Decimal = TxtDohon.Text
Dim total As Decimal = i1 + i2 + i3
Dim deg1 As Decimal = (i1 / total) * 360
Dim deg2 As Decimal = (i2 / total) * 360
Dim deg3 As Decimal = (i3 / total) * 360
Dim Img0 As New Bitmap(PbChart_pic.Width, PbChart_pic.Height)
Dim pen As New Pen(Color.Black, 2)
Dim graphics As Graphics = graphics.FromImage(Img0)
Dim rect As New Rectangle(0, 0, PbChart_pic.Width, PbChart_pic.Height)
Dim brush1 As New SolidBrush(Color.Green)
Dim brush2 = New SolidBrush(Color.Yellow)
Dim brush3 = New SolidBrush(Color.Red)
graphics.Clear(PbChart_pic.BackColor)
graphics.FillPie(brush1, rect, 0, deg1)
graphics.FillPie(brush2, rect, deg1, deg2)
graphics.FillPie(brush3, rect, deg1 + deg2, deg3)
Dim ms As New MemoryStream
Img0.Save(ms, Imaging.ImageFormat.Png)
Img = ms.ToArray
graphics.Dispose()
PbChart_pic.Image = Img0