Update parsers
This commit is contained in:
@@ -14,8 +14,8 @@ android {
|
|||||||
applicationId 'org.koitharu.kotatsu'
|
applicationId 'org.koitharu.kotatsu'
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 32
|
targetSdkVersion 32
|
||||||
versionCode 420
|
versionCode 421
|
||||||
versionName '3.4.8'
|
versionName '3.4.9'
|
||||||
generatedDensities = []
|
generatedDensities = []
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ afterEvaluate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation('com.github.KotatsuApp:kotatsu-parsers:e2308214a7') {
|
implementation('com.github.KotatsuApp:kotatsu-parsers:8709c3dd0c') {
|
||||||
exclude group: 'org.json', module: 'json'
|
exclude group: 'org.json', module: 'json'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
package org.koitharu.kotatsu.utils.image
|
package org.koitharu.kotatsu.utils.image
|
||||||
|
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import androidx.core.graphics.get
|
import androidx.annotation.ColorInt
|
||||||
|
import androidx.core.graphics.*
|
||||||
import coil.size.Size
|
import coil.size.Size
|
||||||
import coil.transform.Transformation
|
import coil.transform.Transformation
|
||||||
|
import kotlin.math.abs
|
||||||
|
|
||||||
class TrimTransformation : Transformation {
|
class TrimTransformation(
|
||||||
|
private val tolerance: Int = 20,
|
||||||
|
) : Transformation {
|
||||||
|
|
||||||
override val cacheKey: String = javaClass.name
|
override val cacheKey: String = javaClass.name
|
||||||
|
|
||||||
@@ -20,7 +24,7 @@ class TrimTransformation : Transformation {
|
|||||||
var isColBlank = true
|
var isColBlank = true
|
||||||
val prevColor = input[x, 0]
|
val prevColor = input[x, 0]
|
||||||
for (y in 1 until input.height) {
|
for (y in 1 until input.height) {
|
||||||
if (input[x, y] != prevColor) {
|
if (!isColorTheSame(input[x, y], prevColor)) {
|
||||||
isColBlank = false
|
isColBlank = false
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -39,7 +43,7 @@ class TrimTransformation : Transformation {
|
|||||||
var isColBlank = true
|
var isColBlank = true
|
||||||
val prevColor = input[x, 0]
|
val prevColor = input[x, 0]
|
||||||
for (y in 1 until input.height) {
|
for (y in 1 until input.height) {
|
||||||
if (input[x, y] != prevColor) {
|
if (!isColorTheSame(input[x, y], prevColor)) {
|
||||||
isColBlank = false
|
isColBlank = false
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -55,7 +59,7 @@ class TrimTransformation : Transformation {
|
|||||||
var isRowBlank = true
|
var isRowBlank = true
|
||||||
val prevColor = input[0, y]
|
val prevColor = input[0, y]
|
||||||
for (x in 1 until input.width) {
|
for (x in 1 until input.width) {
|
||||||
if (input[x, y] != prevColor) {
|
if (!isColorTheSame(input[x, y], prevColor)) {
|
||||||
isRowBlank = false
|
isRowBlank = false
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -71,7 +75,7 @@ class TrimTransformation : Transformation {
|
|||||||
var isRowBlank = true
|
var isRowBlank = true
|
||||||
val prevColor = input[0, y]
|
val prevColor = input[0, y]
|
||||||
for (x in 1 until input.width) {
|
for (x in 1 until input.width) {
|
||||||
if (input[x, y] != prevColor) {
|
if (!isColorTheSame(input[x, y], prevColor)) {
|
||||||
isRowBlank = false
|
isRowBlank = false
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -93,4 +97,11 @@ class TrimTransformation : Transformation {
|
|||||||
override fun equals(other: Any?) = other is TrimTransformation
|
override fun equals(other: Any?) = other is TrimTransformation
|
||||||
|
|
||||||
override fun hashCode() = javaClass.hashCode()
|
override fun hashCode() = javaClass.hashCode()
|
||||||
|
|
||||||
|
private fun isColorTheSame(@ColorInt a: Int, @ColorInt b: Int): Boolean {
|
||||||
|
return abs(a.red - b.red) <= tolerance &&
|
||||||
|
abs(a.green - b.green) <= tolerance &&
|
||||||
|
abs(a.blue - b.blue) <= tolerance &&
|
||||||
|
abs(a.alpha - b.alpha) <= tolerance
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user