Cut transparent parts image

后端 未结 1 1719
故里飘歌
故里飘歌 2021-01-25 22:07

The updated image:

thanks you very much man but i wanted to do somthing little different, to cut each rectangle here as a sperate image.Lets try first to find the blue b

1条回答
  •  隐瞒了意图╮
    2021-01-25 22:41

    I'll write this in pseudo-ish-code since you should be able then to apply it to any type of image or language...

    var minX = 10000
    var maxX = -10000
    var minY = 10000
    var maxY = -10000
    
    for (var y = 0 to height)
    {
        for (var x = 0 to width)
        {
            if (pixel(x,y).Color != transparent)
            {
                if (x < minX) minX = x
                if (y < minY) minY = y
                if (x > maxX) maxX = x
                if (y > maxY) maxY = y
            }
        }
    }
    
    var cropRectangle = (minX, minY, maxX, maxY)
    

    You can now use standard functions on the bitmap to get that area, which should be the area bounded by the non-transparent pixels.

    0 讨论(0)
提交回复
热议问题