Last active
June 10, 2020 17:39
-
-
Save mdavalos1993/ce88b657fd9c4419c4b75adb3bc32659 to your computer and use it in GitHub Desktop.
Revisions
-
mdavalos1993 revised this gist
Jun 10, 2020 . No changes.There are no files selected for viewing
-
mdavalos1993 revised this gist
Jun 10, 2020 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,10 @@ package me.marcosdavalos.util import android.graphics.Bitmap import android.graphics.Canvas import android.graphics.Color import android.view.View val View.toBitmap: Bitmap get(){ val bitmap = Bitmap.createBitmap(this.width, this.height, Bitmap.Config.ARGB_8888) val canvas = Canvas(bitmap) -
mdavalos1993 created this gist
Jun 10, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ val View.toBitmap: Bitmap get(){ val bitmap = Bitmap.createBitmap(this.width, this.height, Bitmap.Config.ARGB_8888) val canvas = Canvas(bitmap) val bgDrawable = this.background if(bgDrawable != null){ bgDrawable.draw(canvas) }else{ canvas.drawColor(Color.BLACK) } this.draw(canvas) return bitmap }