Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2014
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. // You are using RGBA that's why Config is ARGB.8888
  2. bitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
  3. // vector is your int[] of ARGB
  4. bitmap.copyPixelsFromBuffer(IntBuffer.wrap(vector));
  5.  
  6. //OR , you can generate IntBuffer from following native method
  7. /*private IntBuffer makeBuffer(int[] src, int n) {
  8. IntBuffer dst = IntBuffer.allocate(n*n);
  9. for (int i = 0; i < n; i++) {
  10. dst.put(src);
  11. }
  12. dst.rewind();
  13. return dst;
  14. }*/
  15.  
  16. int[] array = your array of pixels here...
  17. int width = width of "array"...
  18. int height = height of "array"...
  19.  
  20. // Create bitmap
  21. Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
  22.  
  23. // Set the pixels
  24. bitmap.setPixels(array, 0, width, 0, 0, width, height);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement