Click here to Skip to main content
11,496,146 members (677 online)
The site is currently in read-only mode for maintenance. Posting of new items will be available again shortly.
See more: C#3.0 Windows Forms
Hi Friends

i am saving some pictures(without background) in sql 2005 database. when i retrieve them in picturebox its have a white background. how i can get my pictures in original format(without background).

 PictureBox temp = new PictureBox();
            temp.Location = new System.Drawing.Point(100, 90 + (20 * NumberOfButton));
            temp.Name = "btn" + NumberOfButton;
            temp.Size = new System.Drawing.Size(((8 * tempWidth) / 100), ((10 * tempHeight) / 100));
            temp.Text = ButtonText;
            temp.Tag = ButtonText;            
            temp.Click += new EventHandler(OnButtonClick);
            String sql = "select Button_id, Button_logo from Button_mst where Button_id=" + NumberOfButton + "";
            DataTable dtLogo = new DataTable();
            _connector.FillTable(ref dtLogo, sql);
            byte[] data = (byte[])dtLogo.Rows[0][1];
            MemoryStream strm = new MemoryStream();
            strm.Write(data, 0, data.Length);
            strm.Position = 0;
            System.Drawing.Image img = System.Drawing.Image.FromStream(strm);
            temp.Image = img;            
Posted 26-Apr-12 3:07am
Edited 26-Apr-12 3:24am
(no name)10.2K
Mark Nischalke at 26-Apr-12 8:24am
Format code snippets when posting
Mark Nischalke at 26-Apr-12 8:26am
Are you sure it isn't the size of the picturebox being larger than the image? It should default to a white background.
Tiwari A K at 26-Apr-12 8:28am
yes i am sure it isn't the size of the picturebox being larger than the image
i want to remove default white background.
mmm3743 at 26-Apr-12 16:18pm
Try changing backcolor of the picturebox to transparent
Tiwari A K at 26-Apr-12 20:27pm
picture box back color is already transparent
Bernhard Hiller at 27-Apr-12 3:37am
Are you sure that your image has a transparent background? Save the contents of your memory stream to a file and open that with some programs for viewing images - is it really transparent?!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 RyanDev 230
1 Sergey Alexandrovich Kryukov 114
2 Richard Deeming 100
3 OriginalGriff 89
4 Mostafa Asaduzzaman 59
0 Sergey Alexandrovich Kryukov 10,401
1 OriginalGriff 8,910
2 Sascha Lefèvre 3,899
3 Maciej Los 3,422
4 Richard Deeming 2,600

Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 26 Apr 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100