Reputation: 4559
I am attempting to split an image into pieces, lets say for example 16 chunks (4x4).Once i split the image how can i display these chunk image as a whole.
Should I use a bitmap or a drawable? Is there a method to split or will I have to make a custom method?
Upvotes: 6
Views: 2449
Reputation: 681
Use bitmap because it holds pixel of the image which will be good for you for future use, if you are willing to display that image.
for example ---->
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.icon);
ImageView iv = (ImageView) findViewById(R.id.imageView1);
iv.setImageBitmap(bm);
------------------------------------EDITED PART--------------------------------------------
if you want to send image from place to another(one device to another), you to convert it into byte array like this --->
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.icon);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bm.compress(Bitmap.Compress.JPEG, 100, baos);
byte[] b = baos.toByteArray();
and then send this to the other device.
Upvotes: 1
Reputation: 15089
You can make use of Canvas
, with drawing functionality, splitting it into chunks and set each to 4x4 ImageView
.
@note:
Bitmap
will give better performance than Drawable
.ImageView
.You can refer to my list of image processing article to get some idea about it. Practically, it's not so hard :)
Upvotes: 0