2016-03-20 10 views
0

イムそれを入れて、任意のアイデアは、私はそのと思ういけない画像をトリミングし、スプライトシートから画像をトリミングし、そのが動作していないとのPictureBoxにそれを置くが、しようとしているピクチャボックスに

 private void Form1_Load(object sender, EventArgs e) 
    { 
     Image Result = Crop(@"C:\Users\William\Documents\Sprites\Player\Male\Default\Light.png", 40, 60, 367, 701); 
     pictureBox1.Image = Result; 
    } 

    public Image Crop(string img, int width, int height, int x, int y) 
    { 
     try 
     { 
      Image image = Image.FromFile(img); 
      Bitmap bmp = new Bitmap(width, height, PixelFormat.Format24bppRgb); 
      bmp.SetResolution(80, 60); 

      Graphics gfx = Graphics.FromImage(bmp); 
      gfx.SmoothingMode = SmoothingMode.AntiAlias; 
      gfx.InterpolationMode = InterpolationMode.HighQualityBicubic; 
      gfx.PixelOffsetMode = PixelOffsetMode.HighQuality; 
      gfx.DrawImage(image, new Rectangle(0, 0, width, height), x, y, width, height, GraphicsUnit.Pixel); 
      // Dispose to free up resources 
      image.Dispose(); 
      bmp.Dispose(); 
      gfx.Dispose(); 

      return bmp; 
     } 
     catch (Exception ex) 
     { 
      MessageBox.Show(ex.Message); 
      return null; 
     } 
    } 

歓迎されていますクロップ機能は、これはあなたがそれがすでに配置されているので、何のために使用することはできませんビットマップを返している

bmp.Dispose(); 
return bmp; 

かなり無意味です

答えて

0

わからない間違っているが、イムthatsの。

+0

oh yeh lol、それは今、ありがとう – Will

関連する問題