|
-
Jul 30th, 2005, 02:02 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] picturebox1 image to disk
hi,
how to save picture box image to disk?
popskie
-
Jul 30th, 2005, 02:08 AM
#2
Sleep mode
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.
-
Jul 30th, 2005, 02:29 AM
#3
Thread Starter
Fanatic Member
Re: picturebox1 image to disk
ok thanks a lot. also have another question Pirate Picturebox image convert to byte?
-
Jul 31st, 2005, 08:36 PM
#4
-
Jul 31st, 2005, 08:47 PM
#5
Thread Starter
Fanatic Member
Re: picturebox1 image to disk
hi,
Iwant my picturebox image save to sql server.
-
Jul 31st, 2005, 11:44 PM
#6
Re: picturebox1 image to disk
 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!!
-
Aug 1st, 2005, 02:33 AM
#7
Thread Starter
Fanatic Member
Re: picturebox1 image to disk
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|