博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
paip.c#图片裁剪
阅读量:2078 次
发布时间:2019-04-29

本文共 907 字,大约阅读时间需要 3 分钟。

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);

}

 

转载地址:http://huhmf.baihongyu.com/

你可能感兴趣的文章
判断数据的JS代码
查看>>
js按键事件说明
查看>>
AJAX 设计制作 在公司弄的 非得要做出这个养的 真晕!
查看>>
Linux 查看文件大小
查看>>
Java并发编程:线程池的使用
查看>>
redis单机及其集群的搭建
查看>>
Java多线程学习
查看>>
检查Linux服务器性能
查看>>
Java 8新的时间日期库
查看>>
Chrome开发者工具
查看>>
【LEETCODE】102-Binary Tree Level Order Traversal
查看>>
【LEETCODE】106-Construct Binary Tree from Inorder and Postorder Traversal
查看>>
【LEETCODE】202-Happy Number
查看>>
和机器学习和计算机视觉相关的数学
查看>>
十个值得一试的开源深度学习框架
查看>>
【LEETCODE】240-Search a 2D Matrix II
查看>>
【LEETCODE】53-Maximum Subarray
查看>>
【LEETCODE】215-Kth Largest Element in an Array
查看>>
【LEETCODE】312-Burst Balloons
查看>>
【LEETCODE】232-Implement Queue using Stacks
查看>>