Google Photos App style Image Cropping, Straightening and panning

隐身守侯 提交于 2019-12-24 03:28:49

问题


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.


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/31617081/google-photos-app-style-image-cropping-straightening-and-panning

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!