///
/// 剪切白边(上下左右)
///
///
///
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
.net c# 图片去白边
最新推荐文章于 2022-10-14 11:15:22 发布