1.Image.GetThumbnailImageAbort的作用是什么?

2.Image.GetThumbnailImage与Image.GetThumbnailImageAbort的关系是什么?

3.Image.GetThumbnailImage函数怎么用?

4.Image.Save()方法怎么用?

首先回答第二个问题,.Image.GetThumbnailImage()方法是返回指定的Image的缩略图其参数意义如下:

(1).thumbWidth:生成的缩略图的宽度

(2).thumbHeight:生成的缩略图的高度

(3).Image.GetThumnailImagAbort委托。注意这个参数在GDI+ 1.0中不使用此委托,尽管如此,必须创建一个委托,并在传递该参数的引用。

(4).calllbackData:必须为Zero

所以第一个声明的委托就是为了给Image.GetThumbnailImage传递参数的。

用法如下:

 
  
  1. Image ResourceImage;   
  2. Image.GetThumbnailImageAbort callb = new Image.GetThumbnailImageAbort(ThumbnailCallback);  
  3. ImageWidth = Convert.ToInt32(ResourceImage.Width * Percent);  
  4.                 ImageHeight = Convert.ToInt32(ResourceImage.Height * Percent);  
  5.                 ReducedImage = ResourceImage.GetThumbnailImage(ImageWidth, ImageHeight, callb, IntPtr.Zero);  
  6. public bool ThumbnailCallback()  
  7.         {  
  8.             return false;  
  9.         } 

Bitmap.Save的用法:

 
  
  1. bt.Save(@targetFilePath, ImageFormat.Jpeg);// Image.Save 方法 (String, ImageFormat)方法 
 
  
  1. System.Diagnostics.Process.Start(filePath + pName); 

起到的作用是把路径指示的文件用Windows自带的工具打开。

2.对于路径

 
  
  1. filePath = folderBrowserDialog1.SelectedPath; 

对于文件寻找路径时注意如果文件是直接放到磁盘里,而不是放到磁盘上的文件夹里,则路径为filePath长度为 “F:\\”长度为3

如果不是直接在磁盘上放路径为则filePath为

“F:\\新建文件夹”所以要找到文件夹里的文件需要用如下代码:

 

 
  
  1. System.Diagnostics.Process.Start(filePath + "\\" + pName);// filePath + "\\" + pName为到达文件的路径 

 

 
  
  1. if (filePath.Length == 3)  
  2.                 {  
  3.                     System.Diagnostics.Process.Start(filePath + pName);  
  4.                     tsslPath.Text = "图片路径:" + filePath + pName;  
  5.                 }  
  6.                 else  
  7.                 {  
  8.                     System.Diagnostics.Process.Start(filePath + "\\" + pName);  
  9.                     tsslPath.Text = "图片路径:" + filePath + "\\" + pName;  
  10.                 }