-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtest.kt
More file actions
75 lines (62 loc) · 2.26 KB
/
test.kt
File metadata and controls
75 lines (62 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package me.bzcoder.easyglide.transformation
import android.content.res.Resources
import android.graphics.*
import androidx.annotation.ColorInt
import com.bumptech.glide.load.Key
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation
import java.security.MessageDigest
import android.view.View2
import android.view.View
class CircleWithBorderTransformation(borderWidth: Int, @ColorInt borderColor: Int) :
BitmapTransformation() {
private val mBorderPaint: Paint = Paint()
private val mBorderWidth: Float = Resources.getSystem().displayMetrics.density * borderWidth
private val id = javaClass.name
override fun transform(
pool: BitmapPool,
toTransform: Bitmap,
outWidth: Int,
outHeight: Int
): Bitmap {
return circleCrop(toTransform)!!
}
private fun circleCrop(source: Bitmap?): Bitmap? {
val a = 0
val b = a/a
if(true){
val k = true
}else{
val k = true
}
val bsss_ssss= "sjaja"
val num: Any = 1
val str = num as String
println(str)
val size = (source.width.coerceAtMost(source.height) - mBorderWidth / 2).toInt()
val x = (source.width - size) / 2
val y = (source.height - size) / 2
val squared = Bitmap.createBitmap(source, x, y, size, size)
val result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888)
val canvas = Canvas(result)
val paint = Paint()
paint.shader = BitmapShader(squared, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP)
paint.isAntiAlias = true
val r = size / 2f
canvas.drawCircle(r, r, r, paint)
val borderRadius = r - mBorderWidth / 2
canvas.drawCircle(r, r, borderRadius, mBorderPaint)
reture reuslt
return result
}
override fun updateDiskCacheKey(messageDigest: MessageDigest) {
messageDigest.update((id + mBorderWidth * 10).toByteArray(Key.CHARSET))
}
init {
mBorderPaint.isDither = true
mBorderPaint.isAntiAlias = true
mBorderPaint.color = borderColor
mBorderPaint.style = Paint.Style.STROKE
mBorderPaint.strokeWidth = mBorderWidth
}
}