@@ -93,17 +93,19 @@ data class Component(
93
93
94
94
val width = bitmap.width
95
95
val height = bitmap.height
96
- val pixels = IntArray (width * height)
97
- bitmap.getPixels(pixels, 0 , width, 0 , 0 , width, height)
96
+
97
+ val newBitmap = bitmap.config?.let { Bitmap .createBitmap(width, height, it) }
98
+ newBitmap ? : return bitmap
98
99
99
100
var minX = width
100
101
var minY = height
101
102
var maxX = - 1
102
103
var maxY = - 1
103
104
104
- val newBitmap = bitmap.config?. let { Bitmap .createBitmap (width, height, it) }
105
- var pixel : Int
105
+ val pixels = IntArray (width * height)
106
+ bitmap.getPixels(pixels, 0 , width, 0 , 0 , width, height)
106
107
108
+ var pixel: Int
107
109
for (y in 0 until height) {
108
110
for (x in 0 until width) {
109
111
val index = y * width + x
@@ -120,8 +122,8 @@ data class Component(
120
122
}
121
123
}
122
124
123
- newBitmap? .setPixels(pixels, 0 , width, 0 , 0 , width, height)
124
- return newBitmap?. let { Bitmap .createBitmap(it , minX, minY, maxX - minX + 1 , maxY - minY + 1 ) } ? : bitmap
125
+ newBitmap.setPixels(pixels, 0 , width, 0 , 0 , width, height)
126
+ return Bitmap .createBitmap(newBitmap , minX, minY, maxX - minX + 1 , maxY - minY + 1 )
125
127
}
126
128
}
127
129
}
0 commit comments