.net c# 图片去白边

///
/// 剪切白边(上下左右)
///
///
///
public static Bitmap Crop(Bitmap b)
{
int x, y;//for use of X,Y Coordinates of pixels
Color c = new Color(); //pixel color for use of identifying if background
int intLeft = 0;//furthest left X coordinate
int intRight = 0;//furthest right X coordinate
int intBottom = 0;//furthest to the bottom Y coordinate
int intTop = 0;
y = 0;
while (y < b.Height)
{
x = 0;
while (x < b.Width) //loop through pixels on X axis until end of image width
{
c = b.GetPixel(x, y); //Get the color of the pixel
if (c.R != 255 && c.R != 0 && c.G != 255 && c.G != 0 && c.B != 255 && c.B != 0)
{
if (c.R < 240 || c.G < 240 || c.B < 240)
{
//Determine if pixel is further left than the value we already have

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值