Utilize bitmap KTX extensions
This commit is contained in:
parent
1c85dd0e32
commit
549aba88df
4 changed files with 20 additions and 20 deletions
|
@ -26,6 +26,8 @@ import android.graphics.drawable.BitmapDrawable
|
|||
import android.graphics.drawable.Drawable
|
||||
import android.widget.RemoteViews
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.graphics.applyCanvas
|
||||
import androidx.core.graphics.createBitmap
|
||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||
import code.name.monkey.retromusic.App
|
||||
import code.name.monkey.retromusic.R
|
||||
|
@ -170,15 +172,13 @@ abstract class BaseAppWidget : AppWidgetProvider() {
|
|||
}
|
||||
|
||||
fun createBitmap(drawable: Drawable, sizeMultiplier: Float): Bitmap {
|
||||
val bitmap = Bitmap.createBitmap(
|
||||
return createBitmap(
|
||||
(drawable.intrinsicWidth * sizeMultiplier).toInt(),
|
||||
(drawable.intrinsicHeight * sizeMultiplier).toInt(),
|
||||
Bitmap.Config.ARGB_8888
|
||||
)
|
||||
val c = Canvas(bitmap)
|
||||
drawable.setBounds(0, 0, c.width, c.height)
|
||||
drawable.draw(c)
|
||||
return bitmap
|
||||
).applyCanvas {
|
||||
drawable.setBounds(0, 0, this.width, this.height)
|
||||
drawable.draw(this)
|
||||
}
|
||||
}
|
||||
|
||||
protected fun composeRoundedRectPath(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue