Guest User

Untitled

a guest
Jul 22nd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. Bitmap bottomImage = BitmapFactory.decodeResource(getResources(),R.drawable.blink);
  2. Bitmap topImage = (Bitmap) data.getExtras().get("data");
  3.  
  4. // As described by Steve Pomeroy in a previous comment,
  5. // use the canvas to combine them.
  6. // Start with the first in the constructor..
  7. Canvas comboImage = new Canvas(bottomImage);
  8. // Then draw the second on top of that
  9. comboImage.drawBitmap(topImage, 0f, 0f, null);
  10.  
  11. // bottomImage is now a composite of the two.
  12.  
  13. // To write the file out to the SDCard:
  14. OutputStream os = null;
  15.  
  16. try {
  17. os = new FileOutputStream("/sdcard/DCIM/Camera/" + "myNewFileName.png");
  18. bottomImage.compress(CompressFormat.PNG, 50, os);
  19.  
  20. //Bitmap image.compress(CompressFormat.PNG, 50, os);
  21. } catch(IOException e) {
  22. Log.v("error saving","error saving");
  23. e.printStackTrace();
  24. }
  25.  
  26. int w = bottomImage.getWidth();
  27. int h = bottomImage.getHeight();
  28. Bitmap new_image = Bitmap.createBitmap(w, h ,bottomImage.getConfig());
Add Comment
Please, Sign In to add comment