Save Bitmap Image Into JPG Format
public void saveJpeg(string path, Bitmap img, long quality)
{
try
{
// Encoder parameter for image quality
EncoderParameter qualityParam = new EncoderParameter(Encoder.Quality, quality);
// Jpeg image codec
ImageCodecInfo jpegCodec = this.getEncoderInfo("image/jpeg");
if (jpegCodec == null)
return;
EncoderParameters encoderParams = new EncoderParameters(1);
encoderParams.Param[0] = qualityParam;
img.Save(path, jpegCodec, encoderParams);
encoderParams.Dispose();
qualityParam.Dispose();
}
catch (Exception)
{
}
}
private ImageCodecInfo getEncoderInfo(string mimeType)
{
// Get image codecs for all image formats
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();
// Find the correct image codec
for (int i = 0; i <>
if (codecs[i].MimeType == mimeType)
return codecs[i];
return null;
}
tag:Save Bitmap Image Into Jpeg Format
Articles
- Articles(C#.NET) (3)
- ASP.NET (6)
- Asp.Net(Email) (1)
- Asp.net(Image) (2)
- Asp.Net(Web.Config) (2)
- C#.NET (5)
- C#.NET Threading (3)
- C#.NET(ASP.NET) (4)
- Comments in PHP (1)
- Encryption In PHP (1)
- iPhone (Articles) (1)
- JavaScript (1)
- Json with PHP (1)
- LINQ (1)
- PHP (2)
- PHP Constant (1)
- PHP Operators (1)
- PHP Print Command (1)
- PHP Tutorial (2)
- Strings In PHP (1)
- Variable Declaration In PHP (1)
- WPF (1)
- XAML (2)
About Me
Help Link
Followers
How can send the Email in the Asp.net?
try
{
string strPassword = string.Empty;
string strMailFrom = string.Empty;
string smtpServer = "ServerName";
SmtpClient smtp = new SmtpClient();
strMailFrom = "Email Id";
strPassword = "Password";
smtp.Host = smtpServer;
smtp.Port = 25;
//smtp.EnableSsl = true;
//check the Authentication
If(true)
{
smtp.UseDefaultCredentials = true;
smtp.Credentials = new System.Net.NetworkCredential(strMailFrom, strPassword);
}
MailMessage mail = new MailMessage();
mail.From = new MailAddress(strMailFrom);
mail.To.Add("EmailId");
mail.Bcc.Add("EmailId");
mail.Subject = m_strEmailSubject.ToString();
mail.Body = m_strEmailMessage.ToString();
smtp.Send(mail);
}
catch (Exception objException)
{
throw new Exception(objException.Message.ToString());
}
tag-:How can send the Email in the Asp.net?
Smtp,Email,SmtpClient
Upload and Resize Image in the Asp.net Using C#.Net .
const int IMAGE_WIDTH = 550;
const int IMAGE_HEIGHT = 176;
(We can change the Width and Height)
public void UploadImageAd()
{
try
{
string strFolderName = "Banner_Images";
string strFolderPath = Server.MapPath(strFolderName);
//string strSavePath = "~/" + strFolderName + "/";
string strFileName = string.Empty;
string strSaveFilePath=strFolderPath;
if (!Directory.Exists(strFolderPath))
{
Directory.CreateDirectory(strFolderPath);
}
if (FileUploadImage.HasFile)
{
strFileName = FileUploadImage.FileName;
strSaveFilePath += "/" + strFileName;
string strRealImagePath = Server.MapPath("RealImage");
strRealImagePath += "/" + strFileName;
FileUploadImage.SaveAs(strRealImagePath);
//Resize and Save Image
string strImageUrl = strRealImagePath;
ResizeImage(strImageUrl,strSaveFilePath);
//RealImage
//
m_strImagePath = "~/" + strFolderName + "/" + strFileName;
}
}
catch (Exception objException)
{
throw new Exception(objException.Message.ToString());
}
}
public void ResizeImage(string strImageUrl,string strSaveFilePath)
{
try
{
System.Drawing.Image fullSizeImg = System.Drawing.Image.FromFile(strImageUrl);
System.Drawing.Image.GetThumbnailImageAbort dummyCallBack = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);
System.Drawing.Image thumbNailImg = fullSizeImg.GetThumbnailImage(IMAGE_WIDTH, IMAGE_HEIGHT, dummyCallBack, IntPtr.Zero);
//Save the thumbnail in Png format. You may change it to a diff format with the ImageFormat property
thumbNailImg.Save(strSaveFilePath, ImageFormat.Png);
thumbNailImg.Dispose();
}
catch (Exception ObjException)
{
throw new Exception(ObjException.Message.ToString());
}
}
tag-Upload and Resize Image in the Asp.net Using C#.Net .
Resize image ,Upload Image in VS 2005
How to get Appsettings Value From the Web.Config File ?
try
{
string strAlertThreshold = ConfigurationManager.AppSettings["AlertThreshold"].ToString();
m_iAlertThreshold = Convert.ToInt32(strAlertThreshold);
return true;
}
catch (Exception objException)
{
m_iAlertThreshold = 0;
throw new Exception(objException.Message.ToString());
}
return false;
tag-:How to get Appsettings Value From the Web.Config File
How can update Web.config File in the Asp.NET ?
Update AppSettings in the web.Config File (Asp.net)
public bool ChangeAppSettings(string strKey, string strValue)
{
XmlDocument doc = new XmlDocument();
bool bChange = false;
string configFile = Server.MapPath("web.config"); //Path.Combine(strSiteFolder, "web.config");
doc.Load(configFile);
XmlElement Root = doc.DocumentElement;
Dictionary
//appSettings.Add("AlertThreshold", "15");
appSettings.Add(strKey, strValue);
XmlNode appNode = Root["appSettings"];
foreach (XmlNode node in appNode.ChildNodes)
{
if (node.Attributes != null)
{
try
{
string key = node.Attributes.GetNamedItem("key").Value;
string value = node.Attributes.GetNamedItem("value").Value;
if (appSettings.ContainsKey(key) && value != appSettings[key].ToString())
{
node.Attributes.GetNamedItem("value").Value = appSettings[key].ToString();
bChange = true;
}
}
catch (Exception)
{
throw new Exception("While reading the web.config, this line had no key/value attributes modify: " + node.InnerText);
}
}
}
if (bChange) //Update web.config only if changes are made to web.config file
{
try
{
doc.Save(configFile);
return true;
}
catch (IOException objException)
{
throw new Exception(objException.Message.ToString());
}
}
else
{
return false;
}
}
protected void btnSetThreshold_Click(object sender, EventArgs e)
{
try
{
const string KEY_THRESHOLD = "AlertThreshold";
string strValue = this.txtWebThreshold.Text.Trim();
if (ChangeAppSettings(KEY_THRESHOLD, strValue))
{
this.lblStatus.Text = "Web Threshold Updated Succefully";
}
}
catch (Exception objException)
{
throw new Exception(objException.Message.ToString());
}
}
#endregion
tag:How can update Web.config File in the Asp.NET
Update Web.Config File
Update AppSettings in the web.Config File (Asp.net)