Android library to load multiple image from server, pan, zoom and rotate - android

In my project, there is a activity where I need to load 2/3 images from server in a image view. Then need to do the below operation with them:
Paging, zooming and rotation by touch gesture.
I have searched a lot but could not manage to find any suitable library for those options.
I tried to achieve it by combining libraries( Picasso +others) but could not manage.
Please guide my to achieve this.
Any sample code, library reference or tutorial will be better.

TouchImageView
which helps to zoom the image

I really like Volley for working with image downloads. It offers a class called "NetworkImageView" which allows you to give it a URL and it loads the image directly, and even scales it down if needed.
As for your zoom & rotation gestures, have a look at uk.co.senab.PhotoView - it's a class which extends ImageView (you can change it to extend NetworkImageView), and allows touch interactions such as zoom. I'm not sure if it supports rotation, but I'm sure that once you get familiar with it, you can add this functionality.
Volley: https://github.com/mcxiaoke/android-volley
PhotoView: https://github.com/chrisbanes/PhotoView

Related

android: scale ImageView like telegram app

How can I implement telegram app scaling ImageView effect?
telegram has rounded images for contacts. if I touch it in a amazing animation it gets scale and fill the screen. in animation transition image convert from circle to rectangle smoothly. I cannot find anyway to do this. I found libraries like shapedImageView but I have trouble with converting circle to rectangle smoothly.
my main challenge is the animation effect.
The source code of telegram is available on github, so you can check it and see, how they implemented that.
Maybe it is also possible to achieve this effect with material transition animations, if you want to open picture in another activity/fragment. Have a look at this library, for example: Material-Animations. I think you could try using shared elements.

TouchImageView & Volley NetworkImageView working together

I'm Using a ViewPager in my project and so far i found Volley to be very good at loading in the images for the individual pages.
Volley needs com.android.volley.toolbox.NetworkImageView and TouchImageView needs com.android.touch.TouchImageView for ImageView in the xml
My question is how i do combine both of these
I cant get the zoom to work when using Volley
Or i can get the zoom to work by loading in standard bitmaps but swapping pages is slow with that and i'm not that experienced with Bitmaps cashing etc hence why i need volley for the easy of use.
Is there a way to get both of these to work together.
My Pager code
Thanks
UPD
I noticed in touch view class public class TouchImageView extends ImageView {
I wonder if changing to public class TouchImageView extends NetworkImageView { would make it work.
but i moved on since i asked the Q and now use uni image loaded instead. Just out of interest Ill give this a go at some stage and report back. It may be that simple
Well if you are sure the issue is with this line:
Bitmap bitmap = BitmapFactory.decodeByteArray(entry.data, 0, entry.data.length);
then you can run this in an AsyncTask and that'll be better I think.
But I suggest you using Picasso library for image loading, because there are many articles out there that say Picasso is faster in image loading and handles all the hard work itself (caching and...).
Then you can use TouchImageView with Picasso.load(urlString).into(touchImageView);

Google Photos App style Image Cropping, Straightening and panning

I am looking for Google Photos app style image manipulation. I am kind of new to image processing. Any leads on how to make the cropping rectangle with the image the same size as cropping rectangle, rotation (which rotates both the image and cropping rectangle), image straightening (including how to get that angle slider kind of UI) will be great. If there are some libraries that has these features, that will also work.
Square has a library for loading and playing with images.
Here are some features:
- Handling ImageView recycling and download cancelation in an adapter.
- Complex image transformations with minimal memory use.
- Automatic memory and disk caching.
There is detailed information on how to use the lib on their website. Check it out: Picasso
The gradle line you need to add is:
compile 'com.squareup.picasso:picasso:2.5.2'
It's very easy to use. Here is how I load and adjust an image into an ImageView in my example app:
Picasso.with(mContext).load("http://cdn0.vox-cdn.com/uploads/chorus_asset/file/798874/DSCF1913.0.jpg").fit().centerCrop().into(imageView);
As you can see, I've used fit().centerCrop() here. This will adjust the image to fit proportionally inside my imageView. You can try different forms of image transformations to better fit your needs.
You can also load images from your drawable folder or directly from file:
Picasso.with(context).load(R.drawable.landing_screen).into(imageView1);
Picasso.with(context).load("file:///android_asset/DvpvklR.png").into(imageView2);
Picasso.with(context).load(new File(...)).into(imageView3);
EDIT:
Looks like I didn't fully understand your question when I first read it. Here are some tips for what you're trying to achieve. May not be exactly what you want, but I think it might be a start.
If you want to rotate your image, you can do it with Picasso using RequestCreator.rotate(float degrees).
Here's the documentation for RequestCreator.
As for cropping images (inside a specified rectangle, as you've shown), there is:
Android crop.
Or you can use Picasso Transformations and create a transformation like
CropTransformation(Top, Center, Bottom);
And ask Picasso to transform the image like this:
Picasso.with(mContext).load(R.drawable.demo)
.transform(transformation).into((ImageView) findViewById(R.id.image));
Also, as #Amit K Saha said on his answer, you can use some Android SDK effects. Check android.media.effect.
Hope this helps.
There are some help from android sdk. May not be exactly what you are looking but worth of a shot to start. Have a look here.
android.media.effect
And list of available effects can be found here
http://developer.android.com/reference/android/media/effect/EffectFactory.html

Trying to get a handle on displaying an image with zoom and pan

I've read a ton of posts, and tried a few of the suggested solutions, but not having much luck.
I have a ViewPager which is happily displaying text views.
I now want to enhance it to also support ImageViews. The images may be in a wide variety of shapes and sizes, so I need to give the user the ability to zoom and pan in order to focus on any area.
NB. I do not necessarily want pinch zoom, as the pinch-zoom libraries I've tried (eg. https://github.com/jasonpolites/gesture-imageview/blob/master/main/src/com/polites/android/GestureImageView.java and http://blog.sephiroth.it/2011/04/04/imageview-zoom-and-scroll/) seem to work intermittently, and crash with out-of-memory. So rather than complicate the solution with gesture detection, I'm happy to put a slider control above the view to achieve the zoom UI.
I'm struggling to get a handle on what is an appropriate view hierarchy to achieve this (eg. do I need a ScrollView or is panning a feature within the ImageView), and should I be scaling the bitmap, or resizing the view?
Any suggestions on what view components I need to use would be much appreciated.
Should I even be using ImageView? I've seen some answers suggesting that a WebView is a better starting point.
My instinct is that what I'm trying to do should be pretty basic, and require no more than the right view hierarchy and view config settings. It seems too simple to require a custom ImageView class, but of course I might be wrong.
Should I even be using ImageView? I've seen some answers suggesting that a WebView is a better starting point.
This is the way I solved it in the end. I simply wrapped the image filename in some HTML and gave it to a webview.
This gave me the following specific benefits:-
The detailed user behaviour (eg. zoom rate, pinch sensitivity, availability of an on screen control) were consistent with the browser, and so familiar to the user's muscle memory
I don't need to depend on any third party code
Since it's core Android, it's probably better tested against edge cases (eg. one library I considered didn't support landscape)
I don't need to worry about out of memory situations with Bitmap processing
In the future, I might want to provide "web page" as one of the items in my ViewPager anyway, so one stone, two birds.
Here is the code I ended up with.
File imgFile = new File(FILESDIR,FILENAME);
if(imgFile.exists()){
WebView wv = (WebView) rootView.findViewById(R.id.imageView1);
wv.getSettings().setBuiltInZoomControls(true);
wv.getSettings().setDisplayZoomControls(true);
String html = ("<html><img src='"+imgFile.getName()+"'></html>" );
wv.loadDataWithBaseURL("file://"+imgFile.getAbsolutePath(),
html,
"text/html",
"utf-8",
"");
}
You need to use GestureDetectors. Google has excellent sample interactiveChart for this, see https://android.googlesource.com/platform/development/+/master/samples/training/InteractiveChart and http://developer.android.com/training/gestures/scroll.html

How to create imageview with zoom and pan functionality?

I created an app that has a small image loaded from URL of a website. I want that when user clicks on that small image it'll show the image in full screen and will also have the ability to zoom and pan that image.
What I've done was showing the image in WebView with built-in zoom controls but the result was ugly. (I've set the layout to wrap_content so no white areas are shown, but it cause the image doesn't zoom dynamically).
Any solution? and sorry for my bad English.
Problem solved! For anyone who have the same problem, I've use this library and it works great! http://blog.sephiroth.it/2011/04/04/imageview-zoom-and-scroll/
Here's a link to the Github ImageViewZoom page.
You can build that from scratch or... you can use this library:
http://code.google.com/p/android-pinch
Take a look at the PinchImageView class
You need to use GestureDetectors. Google has excellent sample interactiveChart for this, see https://android.googlesource.com/platform/development/+/master/samples/training/InteractiveChart
and http://developer.android.com/training/gestures/scroll.html

Categories

Resources