Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. private static Bitmap getBitmapFromView(View view,int width,int height) {
  2. int widthSpec = View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY);
  3. int heightSpec = View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.EXACTLY);
  4. view.measure(widthSpec, heightSpec);
  5. view.layout(0, 0, width, height);
  6. Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
  7. Canvas canvas = new Canvas(bitmap);
  8. view.draw(canvas);
  9.  
  10. return bitmap;
  11. }
  12.  
  13.  
  14. private static Bitmap flipBitmap(Bitmap src)
  15. {
  16. Matrix matrix = new Matrix();
  17. matrix.preScale(-1, 1);
  18. Bitmap dst = Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, false);
  19. dst.setDensity(DisplayMetrics.DENSITY_DEFAULT);
  20. return dst;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement