Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. try {
  2.  
  3.  
  4. String mPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/" +"imagen.jpg";
  5.  
  6.  
  7.  
  8.  
  9. View v1 = getWindow().getDecorView().getRootView();
  10. v1.setDrawingCacheEnabled(true);
  11.  
  12. Bitmap bitmap = Bitmap.createBitmap(v1.getDrawingCache());
  13. v1.setDrawingCacheEnabled(false);
  14.  
  15. File nuevo = new File(mPath);
  16.  
  17. FileOutputStream Salida = new FileOutputStream(nuevo);
  18. FileOutputStream Sa= new FileOutputStream(nuevo);
  19.  
  20. int quality = 100;
  21.  
  22. bitmap.compress(Bitmap.CompressFormat.JPEG, quality, Salida);
  23.  
  24. Salida.flush();
  25.  
  26. Toast.makeText(getApplicationContext(),"HECHO",Toast.LENGTH_SHORT).show();
  27.  
  28.  
  29.  
  30. } catch (Throwable e) {
  31. Toast mal= Toast.makeText(getApplicationContext(),"Que mal rollo",Toast.LENGTH_SHORT);
  32. mal.show();
  33. e.printStackTrace();
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement