Results 1 to 7 of 7

Thread: [RESOLVED] picturebox1 image to disk

  1. #1

    Thread Starter
    Fanatic Member popskie's Avatar
    Join Date
    Jul 2005
    Location
    In my chair
    Posts
    666

    Resolved [RESOLVED] picturebox1 image to disk

    hi,
    how to save picture box image to disk?

    popskie

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Like this :
    this.pictureBox1.Image.Save("path_here")

    Look also for the other overloaded functions of Save method where you can specify quality and format ...etc.

  3. #3

    Thread Starter
    Fanatic Member popskie's Avatar
    Join Date
    Jul 2005
    Location
    In my chair
    Posts
    666

    Re: picturebox1 image to disk

    ok thanks a lot. also have another question Pirate Picturebox image convert to byte?

  4. #4
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: picturebox1 image to disk

    hehe tell me why you want to do that first, so I can tell you the best way to do it
    I had to do the same for a very odd task
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  5. #5

    Thread Starter
    Fanatic Member popskie's Avatar
    Join Date
    Jul 2005
    Location
    In my chair
    Posts
    666

    Re: picturebox1 image to disk

    hi,
    Iwant my picturebox image save to sql server.

  6. #6
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: picturebox1 image to disk

    Quote Originally Posted by popskie
    hi,
    Iwant my picturebox image save to sql server.
    umm I have no sql experience, so there might be a better way. I wrote this for you, it should work fine

    I don't know of a more efficient way to convert an image to bytes, maybe someone else would comment (you could read the image pixels, byte by byte but that's a hassle)
    Code:
    // you need to do error handling 
    		// (ie you could get a OutOfMemoryException if there 
    		// isn't enough memory to create that byte buffer)
    		//
    		// you'd need these two namespaces:
    		//		using System.IO;
    		//		using System.Drawing.Imaging;
    		private byte[] imageToBytes (Image img)
    		{
    			if (img==null)
    				return null;
    
    			byte[] buffer;
    			MemoryStream ms = new MemoryStream();
    			// Save as jpeg
    			img.Save(ms, ImageFormat.Jpeg);
    			ms.Position = 0;
    			
    			// will work fine UNLESS your image file is 
    			// around 2GB or more in size hehe:-D
    			int length = (int)ms.Length;
    			buffer = new byte[length];
    			ms.Write(buffer,0, length);			
    			ms.Close();
    
    			return buffer;			
    		}
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  7. #7

    Thread Starter
    Fanatic Member popskie's Avatar
    Join Date
    Jul 2005
    Location
    In my chair
    Posts
    666

    Re: picturebox1 image to disk

    ok thank u very much.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width