我正在寻找Google相册应用风格的图像处理。我对图像处理有点陌生。关于如何使图像的裁剪矩形与裁剪矩形具有相同大小,旋转(旋转图像和裁剪矩形)以及图像拉直(包括如何获得那种角度滑块的UI)的任何线索都将是很棒的。如果有些库具有这些功能,那也将起作用。
最佳答案
Square具有用于加载和播放图像的库。
以下是一些功能:
- Handling ImageView recycling and download cancelation in an adapter.
- Complex image transformations with minimal memory use.
- Automatic memory and disk caching.
在他们的网站上有有关如何使用lib的详细信息。签出:Picasso
您需要添加的gradle行是:
compile 'com.squareup.picasso:picasso:2.5.2'
它很容易使用。这是我在示例应用程序中如何将图像加载并调整到ImageView中的方法:
Picasso.with(mContext).load("http://cdn0.vox-cdn.com/uploads/chorus_asset/file/798874/DSCF1913.0.jpg").fit().centerCrop().into(imageView);
如您所见,我在这里使用了
fit().centerCrop()
。这将调整图像以使其按比例适合我的imageView
。您可以尝试不同形式的图像转换,以更好地满足您的需求。您还可以从可绘制文件夹或直接从文件加载图像:
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);
编辑:
初次阅读时,我似乎不太了解您的问题。以下是您要实现的一些技巧。可能不是您想要的,但我认为这可能是一个开始。
如果要旋转图像,可以使用
RequestCreator.rotate(float degrees)
在Picasso中进行旋转。这是RequestCreator的文档。
至于裁剪图像(如您所示,在指定的矩形内),有:
Android crop。
或者您可以使用Picasso Transformations并创建一个类似
CropTransformation(Top, Center, Bottom);
并要求毕加索像这样变换图像:
Picasso.with(mContext).load(R.drawable.demo)
.transform(transformation).into((ImageView) findViewById(R.id.image));
另外,正如@Amit K Saha在回答中所说,您可以使用一些Android SDK效果。检查
android.media.effect
。希望这可以帮助。
关于android - Google相册应用风格的图像裁剪,拉直和平移,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31617081/