程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> C#入門知識 >> C# GDI畫圖改變圖像大小

C# GDI畫圖改變圖像大小

編輯:C#入門知識

  private void Create_Validate_Image()
    {
      


        System.Drawing.Bitmap validate_image = new System.Drawing.Bitmap(width, height);


        System.Drawing.Image image11 = System.Drawing.Image.FromFile(System.Web.HttpContext.Current.Request.MapPath("42.jpg"));


        var image112 = image11.GetThumbnailImage(image11.Width / 2, image11.Height / 2, () => { return false; }, IntPtr.Zero);


        Graphics g = Graphics.FromImage(validate_image);
    
        g.Clear(Color.White);
        g.DrawImage(image112, 0, 0);

 


      

           System.IO.MemoryStream ms = new System.IO.MemoryStream();


           validate_image.Save(ms, ImageFormat.Gif);
          Response.ClearContent();
           Response.ContentType = "image/GIF";


           Response.BinaryWrite(ms.ToArray());


    
           g.Dispose();
          validate_image.Dispose();
     
    }


//翻轉

imgPng.RotateFlip(RotateFlipType.Rotate180FlipX);


截取
 
Rectangle
 rect = new

Rectangle(0, 0, imgPng.Width / 2, imgPng.Height);

Bitmap
 clipPng = new

Bitmap(imgPng).Clone(rect, imgPng.PixelFormat);

 

 

摘自 Bychentufeiyang的專欄

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved