.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

How to make thumbnail of one image in C# + windows aplication.....

Posted By: susant     Posted Date: January 09, 2009    Points:2   Category :C#
Hi all

How to create a thumbnail of one image, and show it on Picture box, stored in database and retrive from databse....

Note: I am using C# + Windows Application....

some code here for show and save in databse
------------------------------------------------

To show image and show in PictureBox
---------------------------------------
public void show_image()
{
OpenFileDialog OF = new OpenFileDialog();
OF.Filter = "All Pictures|*.bmp;*.gif;*.jpg|Bitmaps|*.bmp|GIFs|*.gif|JPEGs|*.jpg";
if (OF.ShowDialog() == DialogResult.OK)
{

string imagename = OF.FileName;
Bitmap newimg = new Bitmap(imagename);
pictureBox1.Refresh();

pictureBox1.Image = (Image)newimg;
textBox1.Text = OF.FileName.Substring(OF.FileName.LastIndexOf("\\") + 1);

}
}
-------------------------------------
Method for save in databse
---------------------------------------

public void image_save()
{
if (pictureBox1.Image!=null)
{
OpenFileDialog OF = new OpenFileDialog();

//string imagename = OF.FileName.Substring(OF.FileName.LastIndexOf("\\") + 1);
string imagename = textBox1.Text.Substring(textBox1.Text.LastIndexOf("\\") + 1);
MemoryStream ms = new MemoryStream();
pictureBox1.Image.Save(ms, pictureBox1.Image.RawFormat);
byte[] arrimg = ms.GetBuffer();

string str = "insert into mstImg(ImgName,Img) values('" + imagename + "','" + arrimg + "')";
QE.Insert(str);
MessageBox.Show("Image Saved...!!");
}
else
{
MessageBox.Show("No Image To Saved...!!");
}
}


---------------------------------
Requirement
-----------------------------------

1: Retrive Image from datbase
2: create Thumbnial of Image and save that thumbnail image in databse...
3: How to show image in Picture Box while retriving from databse..
----------------------------------------------


susant

Responses
Author: Praveen             
Posted Date: January 11, 2009     Points: 5   

Hi,
you can refer this code to create thumbnail image this example in asp.net but you can use the function in windows application.

http://www.dotnetspark.com/kb/243-thumbnail-image-upload-asp-net.aspx

Author: longwest             
Posted Date: March 26, 2015     Points: 20   

Here's the answer I found on stackoverflow:
http://stackoverflow.com/questions/7376596/how-do-i-create-a-thumbnail-from-an-image-using-c-sharp-win-mobile-6-5-compact-f

Best regards.
http://www.keepdynamic.com/



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend