服务热线
153 8323 9821
從指定的檔案建立 Image 物件。
命名空間: System.Drawing
 public static Image FromFile(
 string filename
 )
  
  private void DemonstratePropertyItem(PaintEventArgs e)
  {
  
      // Create two images.
      Image image1 = Image.FromFile("c:\\FakePhoto1.jpg");
      Image image2 = Image.FromFile("c:\\FakePhoto2.jpg");
  
      // Get a PropertyItem from image1.
      PropertyItem propItem = image1.GetPropertyItem(20624);
  
      // Change the ID of the PropertyItem.
      propItem.Id = 20625;
  
      // Set the PropertyItem for image2.
      image2.SetPropertyItem(propItem);
  
      // Draw the image.
      e.Graphics.DrawImage(image2, 20.0F, 20.0F);
  }
  
  System.Drawing.Image.FromFile(filename)的使用方法就是将图片文件的路径作为参数传进去,得到一个解码后的Image对象。
  public static System.Drawing.Image FromFile(string filename)
  具体用法:
  从指定的文件创建 System.Drawing.Image。参数:filename: 字符串,包含要从中创建 System.Drawing.Image 的文件的名称。 返回值:此方法创建的 System.Drawing.Image。
下一篇:Graphics 类