Click here to Skip to main content
16,005,473 members
Home / Discussions / C#
   

C#

 
GeneralRe: Saving picture to SQL (PictureBox) GDI Error Pin
Jacob Dixon23-Mar-09 15:40
Jacob Dixon23-Mar-09 15:40 
GeneralRe: Saving picture to SQL (PictureBox) GDI Error Pin
Xmen Real 23-Mar-09 15:44
professional Xmen Real 23-Mar-09 15:44 
GeneralRe: Saving picture to SQL (PictureBox) GDI Error Pin
Jacob Dixon23-Mar-09 15:50
Jacob Dixon23-Mar-09 15:50 
GeneralRe: Saving picture to SQL (PictureBox) GDI Error Pin
Xmen Real 23-Mar-09 16:27
professional Xmen Real 23-Mar-09 16:27 
GeneralRe: Saving picture to SQL (PictureBox) GDI Error Pin
Jacob Dixon23-Mar-09 16:56
Jacob Dixon23-Mar-09 16:56 
GeneralRe: Saving picture to SQL (PictureBox) GDI Error Pin
Xmen Real 23-Mar-09 16:59
professional Xmen Real 23-Mar-09 16:59 
AnswerRe: Saving picture to SQL (PictureBox) GDI Error Pin
Luc Pattyn23-Mar-09 16:03
sitebuilderLuc Pattyn23-Mar-09 16:03 
GeneralRe: Saving picture to SQL (PictureBox) GDI Error Pin
Jacob Dixon23-Mar-09 16:14
Jacob Dixon23-Mar-09 16:14 
Well I use a OpenFileDialog to select a file and set the pictureBox.Image.

Then I use the above code when you click the Save button to get the bytes and insert it into a column in a database... but it never even gets to that. I tried this and it works (not very well for large images over VPN):

byte[] GetPicData()
{
    MemoryStream ms = new MemoryStream();
    Bitmap bmNew = new Bitmap(pictureBoxPicture.Width, pictureBoxPicture.Height, PixelFormat.Format24bppRgb);
    Graphics g = Graphics.FromImage(bmNew);
    g.DrawImage(pictureBoxPicture.Image, new Point(0, 0));
    g.Dispose();

    bmNew.Save(ms, ImageFormat.Png);

    byte[] invPic = ms.ToArray();
    ms.Close();
    return invPic;
}

GeneralRe: Saving picture to SQL (PictureBox) GDI Error Pin
Luc Pattyn23-Mar-09 16:30
sitebuilderLuc Pattyn23-Mar-09 16:30 
GeneralRe: Saving picture to SQL (PictureBox) GDI Error Pin
Jacob Dixon23-Mar-09 16:42
Jacob Dixon23-Mar-09 16:42 
GeneralRe: Saving picture to SQL (PictureBox) GDI Error Pin
Luc Pattyn23-Mar-09 17:36
sitebuilderLuc Pattyn23-Mar-09 17:36 
GeneralRe: Saving picture to SQL (PictureBox) GDI Error Pin
Xmen Real 23-Mar-09 17:03
professional Xmen Real 23-Mar-09 17:03 
GeneralRe: Saving picture to SQL (PictureBox) GDI Error Pin
Luc Pattyn23-Mar-09 17:35
sitebuilderLuc Pattyn23-Mar-09 17:35 
GeneralRe: Saving picture to SQL (PictureBox) GDI Error Pin
Xmen Real 23-Mar-09 17:44
professional Xmen Real 23-Mar-09 17:44 
GeneralRe: Saving picture to SQL (PictureBox) GDI Error Pin
Jacob Dixon23-Mar-09 17:51
Jacob Dixon23-Mar-09 17:51 
GeneralRe: Saving picture to SQL (PictureBox) GDI Error Pin
Luc Pattyn23-Mar-09 17:55
sitebuilderLuc Pattyn23-Mar-09 17:55 
GeneralRe: Saving picture to SQL (PictureBox) GDI Error Pin
Xmen Real 23-Mar-09 18:03
professional Xmen Real 23-Mar-09 18:03 
GeneralRe: Saving picture to SQL (PictureBox) GDI Error Pin
Jacob Dixon23-Mar-09 18:10
Jacob Dixon23-Mar-09 18:10 
GeneralRe: Saving picture to SQL (PictureBox) GDI Error Pin
Xmen Real 23-Mar-09 18:15
professional Xmen Real 23-Mar-09 18:15 
GeneralRe: Saving picture to SQL (PictureBox) GDI Error Pin
Luc Pattyn23-Mar-09 18:17
sitebuilderLuc Pattyn23-Mar-09 18:17 
GeneralRe: Saving picture to SQL (PictureBox) GDI Error Pin
Jacob Dixon23-Mar-09 18:26
Jacob Dixon23-Mar-09 18:26 
GeneralRe: Saving picture to SQL (PictureBox) GDI Error Pin
Luc Pattyn23-Mar-09 18:02
sitebuilderLuc Pattyn23-Mar-09 18:02 
GeneralRe: Saving picture to SQL (PictureBox) GDI Error Pin
Xmen Real 23-Mar-09 18:11
professional Xmen Real 23-Mar-09 18:11 
Questionhow to insert data grid view to table in MySQL database? Pin
rizchi23-Mar-09 12:23
rizchi23-Mar-09 12:23 
AnswerRe: how to insert data grid view to table in MySQL database? Pin
Mbah Dhaim23-Mar-09 23:12
Mbah Dhaim23-Mar-09 23:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.