首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网络技术 > 网络基础 >

paip.c#图片剪裁

2012-09-16 
paip.c#图片裁剪paip.c#图片裁剪pictureBox1.ImagePTImage.CutForCustomx(@d:\img.jpg,100,300)pictur

paip.c#图片裁剪

paip.c#图片裁剪

   pictureBox1.Image=PTImage.CutForCustomx(@"d:\img.jpg",100,300);
            pictureBox1.Image.Save(@"d:\img2.jpg");

 

 

        public static Image CutForCustomx(string imgPath, int top,int height)
        {


            FileStream fs = new FileStream(imgPath, FileMode.Open, FileAccess.Read);
            //从文件获取原始图片,并使用流中嵌入的颜色管理信息
            System.Drawing.Image initImage = System.Drawing.Image.FromStream(fs, true);

            Bitmap b = new Bitmap(initImage);

            Bitmap img = b.Clone(new Rectangle(0, top, initImage.Width, height), System.Drawing.Imaging.PixelFormat.DontCare);
            return (Image)(img);


        }

 

 

public static Image CutForCustomx(string imgPath, Rectangle rec)
{

FileStream fs = new FileStream(imgPath, FileMode.Open, FileAccess.Read);
//从文件获取原始图片,并使用流中嵌入的颜色管理信息
System.Drawing.Image initImage = System.Drawing.Image.FromStream(fs, true);

Bitmap b = new Bitmap(initImage);

Bitmap img = b.Clone(rec, System.Drawing.Imaging.PixelFormat.DontCare);
return (Image)(img);

}

 

热点排行