开发者

Trim images (Crop to remove all blank areas)

To reduce the size of some images I have, I'd like to remove the white padding that s开发者_如何学Come have. The idea would be that if one has large white areas on the borders, then those can be cropped to save some space.

Any idea?


I got the cropping borders using

    Dim MinX As Integer = W : Dim MaxX As Integer = 0
    Dim MinY As Integer = H : Dim MaxY As Integer = 0

    Dim White As Integer = Color.White.ToArgb()
    For x As Integer = 0 To W - 1
        For y As Integer = 0 To H - 1
            If Not Output.GetPixel(x, y).ToArgb() = White Then
                MinX = Math.Min(MinX, x)
                MaxX = Math.Max(MaxX, x)
                MinY = Math.Min(MinY, y)
                MaxY = Math.Max(MaxY, y)
            End If
        Next
    Next
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜