SPLITTING/DIVIDING AN IMAGE INTO SMALLER CHUNKS/PIECES IN ANDROID
Where We Need This?
In a device like SmartPhone, we know that memory management is a serious issue. So in these kind of platforms, if we want to send images to network, we may need to divide the source image into number of small chunks and then send them one by one. This concept also helps us developing a puzzle like application.
How To Achieve This?
Well there are many ways to achieve this, but I prefer Bitmap API the most to achieve this. You can get more information about bitmaps from here.
Source Code:
The below code snippet shows how to split/divide an image into number of smaller chunks/pieces.
The above class has splitImage method which takes two arguments:
- ImageView: The source image to split.
- int: The number of smaller chunks to be formed from the source image.
Reference:
You can find the complete source of this application from My Google Drive Account.
If you want the same in Java using ImageIO, then you can see this
If you want the same in Java using ImageIO, then you can see this


good job..chandra sekhar
ReplyDeleteThanks for the appreciation Girish. My first blog's first comment will be remembered to me for ever.
DeleteHi sir. I am beginner of Android. Your explaination is very good. please try to include programs on other concepts like Bluetooth, Graphics & Animations, Google maps etc. Thank you sir.
ReplyDeleteWhere is ChunkedImage Activity class.....!
ReplyDeleteWell Anshul please read the 4-line comment before the Intent creation code. there I have written the place where you can download the source code of this activity.
DeleteIn the Reference section, there is a link to my Google Drive Account. You can click that link to go there and then go to File->Download to download the complete source code of this application.
thanx ,Can you plz give tuto of how to set static wallpaper
DeleteNice dude.
ReplyDeleteits really awesome chandu..
ReplyDeleteI have a doubt in android... The doubt is in my project the requirement is i copied some images in raw folder.. In the userinterface user gives the image name like(mahesh) in the editbox when the user press the button we get the text like (mahesh) from the editbox and set that mahesh image to the image view... it is working in case from sdcard but i want to get the image from the raw folder.. The code snippet is this to get from sdcard...
public void getMeaning(View v)
{
AutoCompleteTextView tv=(AutoCompleteTextView)findViewById(R.id.act1);
String word=tv.getText().toString();
ImageView b2=(ImageView)findViewById(R.id.b2);
b2.setImageDrawable(Drawable.createFromPath("/mnt/sdcard/dic/"+word+".gif"));
}
Mahesh, I think this can solve this using the Uri of your raw folder. Use this
DeleteString imageName = tv.getText().toString();
Uri uri = Uri.parse("android.resource://your_package_name/drawable/"+imageName);
ImageView b2 = (ImageView)findVi........
b2.setImageURI(uri);
Caution: the imageName should be only the name of the image file. I mean mahesh is the right one but mahesh.jpg is wrong.
Hope this helps you.
Thanks chadu u r great.. it is working.. thanks a lot...
Deleteits really awesome demo chandra Sekhar.
ReplyDeleteHi ,
ReplyDeletewhen i run the application i got this problem !!! FAILED BINDER TRANSACTION !!! .
Hi Lokesh,
DeleteSorry for late reply. The issue is because of limited buffer size. You can find many articles on this issue. In my next blog post ( http://androidattop.blogspot.in/2012/06/merge-multiple-images-into-one-image-in.html ), I have discussed about it(but very less). If still it doesn't helps you, then reply me back. So that I can help you.
Hai Chandra shekhar at last after a lot of search i got the code for what i wanted every thing seems good but i have a problem when i click on split image and select any of the three options i am getting a blank black screen for 5mins and saying me force close what should be the problem i just downloaded the full code and just imported i havent mad e any changes..could you please respond to the query fast i am i a great need and this would help me out a lot...over all its a really nice project thanks for the effort
ReplyDeleteHi Abhinov,
DeleteCan you say which error it was showing. With a guess, I can say that, its because of java.lang.OutOfMemoryError because of limited heap size. You can find many articles on this issue. If still you have any problem, then please reply and be specific this time.
This comment has been removed by the author.
ReplyDeleteHi Chandra,
ReplyDeleteI'd like to develop an app that split an image (as your app do) and then I can move (or remove) the chunks for change the original picture.
What do you think about? I'm a newbie in android develp world...
Can you give me some advice?
Regards,
matpil