For the program I am currently writing I need a simple image editor. Essentially the user navigates to this editor by simply selecting an image from a gallery. Upon selection the image editor activity is created and should allow the user to perform simple editing actions such as rotation, brightness adjustment, zoom etc.
At the moment I have managed to implement the aforementioned functionality with relative ease. My problem lies in dynamically adding the image in question to the ImageView
. As many of you might know; the Binder transaction buffer has a limited fixed size, currently 1Mb, which is shared by all transactions in progress for the process. Thus I am only able to load compressed versions of the bitmap into my ImageView and this presents a rather large problem for me (my program is mainly designed for use on tablets). I have done significant research on this issue and have found that one can essentially split a Bitmap into several smaller bitmaps and place them in several ImageView to create the illusion of one contiguous image using BitmapRegionDecoder
(as suggested in this thread). While this has successfully allowed me to display large images I have no idea how I am supposed to implement zooming functionality using multiple instances of ImageView
. Is there a relatively simple way of going about doing this?
Choose the most appropriate decode method based on your image data source. These methods attempt to allocate memory for the constructed bitmap and therefore can easily result in an OutOfMemory exception. Each type of decode method has additional signatures that let you specify decoding options via the BitmapFactory.
Have a look at this video from Google I/O where they develop an Advanced gallery app with image editing.
You can download source code for the application here. This is how it opens the activity for image editing:
private OnItemClickListener mPhotoClickListener = new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// User clicked on photo, open our viewer
final Intent intent = new Intent(AlbumActivity.this, PhotoActivity.class);
final Uri data = ContentUris.withAppendedId(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, id);
intent.setData(data);
startActivity(intent);
}
};
The gallery also implements image editing functionality. The code might be helpful.
Did you try this? options.inJustDecodeBounds should be set to true.
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeResource(getResources(), R.id.myimage, options);
int imageHeight = options.outHeight;
int imageWidth = options.outWidth;
String imageType = options.outMimeType;
http://developer.android.com/training/displaying-bitmaps/load-bitmap.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With