5

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?

Community
  • 1
  • 1
Kent Hawkings
  • 2,793
  • 2
  • 25
  • 30

2 Answers2

3

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.

Taras Leskiv
  • 1,835
  • 15
  • 33
3

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

Durairaj Packirisamy
  • 4,635
  • 1
  • 21
  • 27