C# 操作TIF
| ASP.net 1.1 smtp發郵件 Sent email by System.Web.Mail.MailMessage in c# 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 handiz@hotmail.com ------------------- 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: handiz@hotmail.com Email: handiz@gmail.com ---------------- 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# handiz@hotmail.com --------------------------------------------------------- //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 圖片: 4 steps to Print Tif in c# handiz@hotmail.com ---------------- 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 2. 程序: ??????????? CDO.Message msg = new CDO.MessageClass(); ??????????? msg.GetStream().SaveToFile("c:\\a.mht", ADODB.SaveOptionsEnum.adSaveCreateOverWrite); |
轉載于:https://www.cnblogs.com/vcool/archive/2008/05/14/1197089.html
總結
- 上一篇: 如何恢复Windows默认共享
- 下一篇: 爬取四大名著