• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# 操作TIF

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

ASP.net 1.1 smtp发邮件

Sent email by System.Web.Mail.MailMessage in c#
[email protected]
-----------------------------------------------------
public void SendMail(string recp, string title, string msg)
{
//define Mail message

System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage();

mail.To = recp;
mail.From = System.Configuration.ConfigurationSettings.AppSettings["MailSender"];
mail.Subject = title;
mail.Body = msg;

mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername","username"); //your smtp username
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword","password"); //your smtp password

System.Web.Mail.SmtpMail.SmtpServer = "smtp.mail"; //your smtp server address
System.Web.Mail.SmtpMail.Send(mail);
}

ASP.net 2.0 smtp发邮件:

Date:2006-11-08, Title:(DotNet) How to sent email from C#2.0


(DotNet) How to sent email from C#2.0 

[email protected]

-------------------
static public void SendMail(string recp, string title, string msg)
{
//sender
string strFrom = System.Configuration.ConfigurationManager.AppSettings["MailSender"];

//smtp server password
string strPass = System.Configuration.ConfigurationManager.AppSettings["MailPassword"];

//mail object
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(strFrom,recp);
mail.Subject = title;
mail.Body = msg;
mail.IsBodyHtml = true;
mail.BodyEncoding = System.Text.Encoding.UTF8;

System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient();

//smtp serveraddress
smtpClient.Host = System.Configuration.ConfigurationManager.AppSettings["MailSmtp"];
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = new System.Net.NetworkCredential(strFrom, strPass);
//smtpClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtpClient.Send(mail);
}

合并/分割 TIF 图片:

Title:Generate multipage TIF and split multipage TIF in C#


Generate multipage TIF and split multipage TIF in C#

MSN: [email protected]
Email: [email protected]
----------------
Using the TifPrint.dll
(download at: http://www.diaries.cn/myworks/MSDotNet/Class/TifPrint/BIN/tifprint.zip)

//split the multiple page TIF file into single file
SplitTif(strFilename, strTargetFolder)

//Combine the Files(can be jpg, bmp, tif, png, gif) into one multipage Tif file
CombineTif(string[] InputFilenames, string OutputFilename)


----------------
/// <summary>
/// Combine some file into 1 tif multipage file
/// if black and write image, we use CCITT4 compression
/// else we use the LZW compression
/// </summary>
/// <param name="InputFilenames">the files to be combined, canbe (bmp, jpg, gif, png, tif)</param>
/// <param name="OutputFilename">the output filename</param>
public static void CombineTif(string[] InputFilenames, string OutputFilename)
{
//get ImageCodecInfo, generate tif format
ImageCodecInfo info = null;
foreach (ImageCodecInfo ice in ImageCodecInfo.GetImageEncoders())
{
if (ice.MimeType == "image/tiff")
{
info = ice;
break;
}
}

/*
* define the encoderparameter,
* when the 1st page, will be EncoderValue.MultiFrame.
* when the other pages, will be EncoderValue.FrameDimensionPage.
* when all pages saved, will be the EncoderValue.Flush.
*/

EncoderParameters ep = new EncoderParameters(2);

/*
* when the 1st file, 1st frame, will be true.
* from the 1st file, 2nd frame, will be false.
*/
bool b11 = true;

Image img =null;

//create a image instance from the 1st image
for (int nLoopfile = 0; nLoopfile < InputFilenames.Length; nLoopfile ++)
{
//get image from src file
Image img_src = Image.FromFile(InputFilenames[nLoopfile]);

Guid guid = img_src.FrameDimensionsList[0];
System.Drawing.Imaging.FrameDimension dimension = new
System.Drawing.Imaging.FrameDimension(guid);

//get the frames from src file
for (int nLoopFrame =0; nLoopFrame < img_src.GetFrameCount(dimension); nLoopFrame ++)
{
img_src.SelectActiveFrame(dimension, nLoopFrame);

/*
* if black and write image, we use CCITT4 compression
* else we use the LZW compression
*/
if (img_src.PixelFormat == PixelFormat.Format1bppIndexed)
{
ep.Param[0] = new EncoderParameter(Encoder.Compression, Convert.ToInt32(EncoderValue.CompressionCCITT4));
}
else
{
ep.Param[0] = new EncoderParameter(Encoder.Compression, Convert.ToInt32(EncoderValue.CompressionLZW));
}

if (b11)
{
//1st file, 1st frame, create the master image
img = img_src;

ep.Param[1] = new EncoderParameter(Encoder.SaveFlag, Convert.ToInt32(EncoderValue.MultiFrame));
img.Save(OutputFilename, info, ep);

b11 = false;
continue;
}

ep.Param[1] = new EncoderParameter(Encoder.SaveFlag, Convert.ToInt32(EncoderValue.FrameDimensionPage));
img.SaveAdd(img_src, ep);
}
}
ep.Param[1] = new EncoderParameter(Encoder.SaveFlag, Convert.ToInt32(EncoderValue.Flush));
img.SaveAdd(ep);
}


====================

Title:(DotNet) How to split multiple page TIF to single file in c#


(DotNet) How to split multiple page TIF to single file in c#

[email protected]
---------------------------------------------------------
//This function will split a TIF file into sigle file, and put them
//into strTargerFolder.
public static void SplitTIF(string strFilename, string strTargetFolder)
{
Image img = Image.FromFile(strFilename);
Guid guid = img.FrameDimensionsList[0];
System.Drawing.Imaging.FrameDimension dimension = new
System.Drawing.Imaging.FrameDimension(guid);
int nTotFrame = img.GetFrameCount(dimension);

//save all frame
int nLoop =0;
for (nLoop = 0; nLoop<nTotFrame; nLoop++)
{
img.SelectActiveFrame(dimension, nLoop);
img.Save(strTargetFolder + "\\"+nLoop.ToString() + ".tif",
System.Drawing.Imaging.ImageFormat.Tiff);
}
}
打印 TIF 图片:
Title:4 steps to Print Tif in c# 

4 steps to Print Tif in c#

[email protected]
----------------
Using the TifPrint.dll
(download at: http://www.diaries.cn/myworks/MSDotNet/Class/TifPrint/BIN/TifPrint.dll)

//1. create instance of TifPrint
TifPrint tp = new TifPrint();

//2. add tif files to printing list:
tp.AddFile(@"c:\1.tif");
tp.AddFile(@"c:\2.tif");
...

//3. show printing dialog or not
tp.ShowDialog = true;

//4. Print
tp.Print();

Other functions:
ClearFile() - remove all files from printing list
GetPageCount() - return the total page number of printing list
SplitTif(strFilename, strTargetFolder) - split the multiple page TIF file into single file
 
C#将网页保存为mht 文件
            

1. 增加 COM Reference
Microsoft CDO for Windows 2000 Library (C:\WINDOWS\System32\cdosys.dll)

2. 程序:

            CDO.Message msg = new CDO.MessageClass();
            CDO.Configuration cfg = new CDO.ConfigurationClass();
           
            msg.Configuration = cfg;
            msg.CreateMHTMLBody("http://www.sina.com.cn", CDO.CdoMHTMLFlags.cdoSuppressAll, "", "");

            msg.GetStream().SaveToFile("c:\\a.mht", ADODB.SaveOptionsEnum.adSaveCreateOverWrite);


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C#/VB.NET 自定义PPT动画路径发布时间:2022-07-10
下一篇:
使用C#向记事本窗口发送消息发布时间:2022-07-10
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap