C# asp.net 圖片微略圖及圖片裁剪處理

來源:互聯網
上載者:User

標籤:style   blog   class   code   java   c   

 try                        {                            //取得圖片大小                             System.Drawing.Size size = new System.Drawing.Size(Convert.ToInt32(w), Convert.ToInt32(h));                            //建立一個bmp圖片                             System.Drawing.Image bmp = new System.Drawing.Bitmap(size.Width, size.Height);                            //建立一個畫板                             g = System.Drawing.Graphics.FromImage(bmp);                            //設定高品質插值法                             g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear;                            //設定高品質,低速度呈現平滑程度                             g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;                            //清空一下畫布                             g.Clear(System.Drawing.Color.Transparent);                            //在指定位置畫圖                             g.DrawImage(img, new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height), new System.Drawing.Rectangle(cwidth / 2, cheigh_h / 2, img.Width - cwidth, img.Height - cheigh_h), System.Drawing.GraphicsUnit.Pixel);//cwidth要裁剪尺寸                            //儲存高清晰度的縮圖                            bmp.Save(newMapPath, System.Drawing.Imaging.ImageFormat.Jpeg);                        }                        finally                        {                            g.Dispose();                        }
相關參數:SmoothingMode { 對直線、曲線和已填充地區的邊緣採用鋸齒消除功能, 它不能控制路徑漸層筆刷 }Invalid     // 一個無效模式  Default     // 不消除鋸齒, 等效於 HighSpeed、NoneHighSpeed   // 不消除鋸齒  HighQuality // 消除鋸齒, 等效於 AntiAliasNone        // 不消除鋸齒  AntiAlias   // 消除鋸齒InterpolationMode { 插補模式確定如何計算兩個像素點之間的中間值 }Invalid             // 等效於 QualityMode 枚舉的 Invalid 元素.Default             // 預設模式.Low                 // 低品質插值法.High                // 高品質插值法.Bilinear            // 雙線性插值法; 不進行預篩選; 將映像收縮為原始大小的 50% 以下時此模式不適用. Bicubic             // 雙立方插值法; 不進行預篩選; 將映像收縮為原始大小的 25% 以下時此模式不適用.NearestNeighbor     // 最臨近插值法.HighQualityBilinear // 高品質的雙線性插值法; 執行預篩選以確保高品質的收縮. HighQualityBicubic  // 高品質的雙立方插值法; 執行預篩選以確保高品質的收縮; 可產生品質最高的轉換映像.CompositingMode { 顏色合成模式 }SourceOver  // 與背景色混合; 該混合由透明度確定SourceCopy  // 改寫背景色 CompositingQuality { 映像合成時, 源像素與目標像素和合成方式 }Invalid        // 無效品質 Default        // 預設品質 HighSpeed      // 高速度、低品質 HighQuality    // 高品質、低速度複合 GammaCorrected // 使用灰階校正 AssumeLinear   // 假定線性值PixelOffsetMode { 像素位移模式 }Invalid     // 無效模式.Default     // 預設模式.HighSpeed   // 高速度、低品質呈現.HighQuality // 高品質、低速度呈現.None        // 沒有任何像素位移.Half        // 像素在水平和垂直距離上均位移 -0.5 個單位, 以進行高速鋸齒消除.

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.