中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

C#圖片剪裁類

2018-07-20    來源:open-open

容器云強(qiáng)勢(shì)上線!快速搭建集群,上萬(wàn)Linux鏡像隨意使用
public class ImageCut
{
    /// <summary>
 
    /// 剪裁 -- 用GDI+
    /// </summary>
    /// <param name="b">原始Bitmap</param>
    /// <param name="StartX">開始坐標(biāo)X</param>
    /// <param name="StartY">開始坐標(biāo)Y</param>
 
    /// <param name="iWidth">寬度</param>
    /// <param name="iHeight">高度</param>
    /// <returns>剪裁后的Bitmap</returns>
 
    public Bitmap KiCut(Bitmap b)
    {
        if (b == null)
        {
            return null;
        }
  
        int w = b.Width;
        int h = b.Height;
  
        if (X >= w || Y >= h)
        {
            return null;
        }
  
        if (X + Width > w)
        {
            Width = w - X;
        }
  
        if (Y + Height > h)
        {
            Height = h - Y;
        }
  
        try
        {
            Bitmap bmpOut = new Bitmap(Width, Height, PixelFormat.Format24bppRgb);
  
            Graphics g = Graphics.FromImage(bmpOut);
            g.DrawImage(b, new Rectangle(0, 0, Width, Height), new Rectangle(X, Y, Width, Height), GraphicsUnit.Pixel);
            g.Dispose();
  
            return bmpOut;
        }
        catch
        {
            return null;
        }
    }
  
    public int X = 0;
    public int Y = 0;
    public int Width = 120;
    public int Height = 120;
    public ImageCut(int x, int y, int width, int heigth)
    {
        X = x;
        Y = y;
        Width = width;
        Height = heigth;
    }
}

標(biāo)簽: isp

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請(qǐng)聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請(qǐng)與原作者聯(lián)系。

上一篇:C#創(chuàng)建二叉搜索樹

下一篇: C#編寫的一個(gè)反向代理工具,可以緩存網(wǎng)頁(yè)到本地