Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-keepclassmembers class * implements android.os.Parcelable {
static ** CREATOR;
}

-keep class com.google.android.material.** { *; }
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import java.util.Queue
class VectorFloodFiller(image: Bitmap) {
val path = MyPath()

private var width = 0
private var height = 0
private var pixels: IntArray? = null
private val width: Int
private val height: Int
private val pixels: IntArray

private lateinit var pixelsChecked: BooleanArray
private lateinit var ranges: Queue<FloodFillRange>
Expand All @@ -29,12 +29,12 @@ class VectorFloodFiller(image: Bitmap) {
width = image.width
height = image.height
pixels = IntArray(width * height)
image.getPixels(pixels!!, 0, width, 0, 0, width, height)
image.getPixels(pixels, 0, width, 0, 0, width, height)
}

private fun prepare() {
// Called before starting flood-fill
pixelsChecked = BooleanArray(pixels!!.size)
pixelsChecked = BooleanArray(pixels.size)
ranges = LinkedList()
}

Expand All @@ -45,7 +45,7 @@ class VectorFloodFiller(image: Bitmap) {
prepare()

// Get starting color.
val startPixel = pixels!!.getOrNull(width * y + x) ?: return
val startPixel = pixels.getOrNull(width * y + x) ?: return
if (startPixel == fillColor) {
// No-op.
return
Expand Down Expand Up @@ -137,9 +137,9 @@ class VectorFloodFiller(image: Bitmap) {

// Sees if a pixel is within the color tolerance range.
private fun isPixelColorWithinTolerance(px: Int): Boolean {
val red = pixels!![px] ushr 16 and 0xff
val green = pixels!![px] ushr 8 and 0xff
val blue = pixels!![px] and 0xff
val red = pixels[px] ushr 16 and 0xff
val green = pixels[px] ushr 8 and 0xff
val blue = pixels[px] and 0xff
return red >= startColorRed - tolerance && red <= startColorRed + tolerance && green >= startColorGreen - tolerance && green <= startColorGreen + tolerance && blue >= startColorBlue - tolerance && blue <= startColorBlue + tolerance
}

Expand Down