hi,
how to save picture box image to disk?
popskie
Printable View
hi,
how to save picture box image to disk?
popskie
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.
ok thanks a lot. also have another question Pirate Picturebox image convert to byte?
hehe tell me why you want to do that first, so I can tell you the best way to do it:D
I had to do the same for a very odd task;)
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 fineQuote:
Originally Posted by popskie
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;
}
ok thank u very much.