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
精彩评论