storing image in db
I want to store the image in the database,when it is display i want to decrease the size of it ! is that possiblity doing like that?otherwise how i decrease the image size?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Suthish NairPosted Mar 10, 2011, 2:11 PM
Jaganathan BantheswaranPosted Mar 9, 2011, 10:01 AM
Try like this.
FileStream FS1 = new FileStream("image.jpg", FileMode.Create);
foreach (DataRow dataRow in dataTable.Rows)
{
if (dataRow[0].ToString() == comboBox1.SelectedItem.ToString())
{
byte[] blob = (byte[])dataRow[1];
FS1.Write(blob, 0, blob.Length);
FS1.Close();
FS1 = null;
pictureBox2.Image = Image.FromFile("image.jpg");
pictureBox2.SizeMode = PictureBoxSizeMode.StretchImage;
pictureBox2.Refresh();
}
}
Just have a look at;
Nice article here on c sharpcorner
Mahesh ChandPosted Mar 9, 2011, 9:47 AM
You can decrease the size of any image by using CreateThumbnail method of Image and specify a size. IF you want to keep the original file and just want to display in a different size, you can also use its Height and Width properties.
Cheers!