2016-01-05 27 views
0

我的數據庫中有兩列(第1列:text,第2列:圖像)。現在我需要顯示的圖像,並且圖像我需要顯示COLUMN1的文本上,最後的結果應該是這樣的形象如何在GridView中使用c顯示column2圖像上的column1文本#

enter image description here

這裏健康的食物是我COLUMN1的文字和背景是COLUMN2的形象。

我正在使用C#和Winforms。

+0

你試過到目前爲止什麼後之後?你卡在哪裏? – Irshad

+0

無法在圖像@Irshad上顯示文本 –

回答

0

把你的數據從數據庫到數據表

byte[] fileContents = (byte[])dts.Rows[0]["image"]; 
    var memoryStream = new MemoryStream(fileContents); 
       var biId = new Bitmap(memoryStream); 
       Bitmap bitMapImage = new System.Drawing.Bitmap(biId); 
       Graphics graphicImage = Graphics.FromImage(bitMapImage); 
       graphicImage.SmoothingMode = SmoothingMode.HighQuality; 
       SolidBrush blueBrush = new SolidBrush(Color.Blue); 
       SolidBrush redBrush = new SolidBrush(Color.Red); 
       SolidBrush greenBrush = new SolidBrush(Color.Green);  
       RectangleF yourtextmessage= new RectangleF(285, 20, 250, 250); 


        graphicImage.DrawString(dts.Rows[0]["text1"].ToString() + " ,", new Font("Verdana", 12, FontStyle.Italic), Brushes.White, yourtextmessage); 


       context.Response.ContentType = "image/jpeg"; 
       bitMapImage.Save(context.Response.OutputStream, ImageFormat.Jpeg); 
       graphicImage.Dispose(); 
       bitMapImage.Dispose(); 
相關問題