Skip to content

Instantly share code, notes, and snippets.

@gsrathoreniks
Forked from hi-manshu/File.kt
Created June 27, 2018 08:09
Show Gist options
  • Save gsrathoreniks/95208c9b836ac7ac2a9994f975975498 to your computer and use it in GitHub Desktop.
Save gsrathoreniks/95208c9b836ac7ac2a9994f975975498 to your computer and use it in GitHub Desktop.
open class BitmapUtils {
var _view: View? = null
var _context: Context? = null
constructor(context: Context, view: View) {
this._view = view
this._context = context
}
fun convertLayout(): Bitmap {
_view!!.isDrawingCacheEnabled = (true)
// _view!!.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
// View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED))
// _view!!.layout(0, 0, 1080, 1280)
_view!!.buildDrawingCache(true)
var _bitmap = Bitmap.createBitmap(_view!!.drawingCache)
return _bitmap
}
fun convertLayoutDiet(): Bitmap {
_view!!.isDrawingCacheEnabled = (true)
// _view!!.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
// View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED))
_view!!.buildDrawingCache(true)
var _bitmap = Bitmap.createBitmap(_view!!.drawingCache)
return _bitmap
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment