Reputation: 12957
To reduce the size of some images I have, I'd like to remove the white padding that some 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?
Upvotes: 2
Views: 2223
Reputation: 12957
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
Upvotes: 3