Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
GrakovNe committed Nov 21, 2024
1 parent cdfbbf9 commit 3a6ae1a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ fun Bitmap.clip(
val density = context.resources.displayMetrics.density
val cornerRadiusPx = cornerRadiusDp.value * density

val minDimension = minOf(this.width, this.height).toFloat()
val proportionalRadius = minDimension * (cornerRadiusPx / density) / 100f

val width = this.width
val height = this.height

Expand All @@ -31,7 +34,7 @@ fun Bitmap.clip(
}

val rect = RectF(0f, 0f, width.toFloat(), height.toFloat())
canvas.drawRoundRect(rect, cornerRadiusPx, cornerRadiusPx, paint)
canvas.drawRoundRect(rect, proportionalRadius, proportionalRadius, paint)

paint.xfermode = PorterDuffXfermode(PorterDuff.Mode.SRC_IN)
canvas.drawBitmap(this, 0f, 0f, paint)
Expand All @@ -41,6 +44,7 @@ fun Bitmap.clip(
this
}


fun String.fromBase64(): Bitmap? = try {
val bytes = Base64.decode(this, Base64.DEFAULT)
BitmapFactory.decodeByteArray(bytes, 0, bytes.size)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class PlayerWidget : GlanceAppWidget() {
?: decodeResource(context.resources, drawable.cover_fallback_png)

val coverImageProvider = cover
.clip(context, 16.dp)
.clip(context, 6.dp)
.let { ImageProvider(it) }

Image(
Expand Down

0 comments on commit 3a6ae1a

Please sign in to comment.