Skip to content

Commit 5607615

Browse files
update ScreenColorDetector
1 parent 8b0e648 commit 5607615

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed
-834 KB
Loading

colorpicker/src/main/java/com/smarttoolfactory/colorpicker/widget/ScreenColorDetector.kt

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -213,20 +213,13 @@ private fun ImageThumbWithColor(
213213
drawImage(
214214
image = bitmap,
215215
srcOffset = IntOffset(
216-
(offset.x.toInt() - imageThumbSize / 2).coerceIn(
217-
0,
218-
(canvasWidth - imageThumbSize).toInt()
219-
),
220-
(offset.y.toInt() - imageThumbSize / 2).coerceIn(
221-
0,
222-
(canvasHeight - imageThumbSize).toInt()
223-
)
224-
),
225-
srcSize = IntSize(imageThumbSize, imageThumbSize),
226-
dstOffset = IntOffset(
227-
x = topLeftImageThumbX,
228-
y = 0
216+
(offset.x.toInt() - imageThumbSize / 4)
217+
.coerceIn(0, (canvasWidth - imageThumbSize).toInt()),
218+
(offset.y.toInt() - imageThumbSize / 4)
219+
.coerceIn(0, (canvasHeight - imageThumbSize).toInt())
229220
),
221+
srcSize = IntSize(imageThumbSize / 2, imageThumbSize / 2),
222+
dstOffset = IntOffset(x = topLeftImageThumbX, y = 0),
230223
dstSize = IntSize(imageThumbSize, imageThumbSize)
231224
)
232225

0 commit comments

Comments
 (0)