【发布时间】:2015-10-15 12:18:41
【问题描述】:
我正在寻找 Google 相册应用风格的图像处理。我对图像处理有点陌生。任何关于如何使图像的裁剪矩形与裁剪矩形大小相同、旋转(旋转图像和裁剪矩形)、图像拉直(包括如何获得那种角度滑块类型的 UI)的任何线索都会很棒。如果有一些库具有这些功能,那也可以。
【问题讨论】:
标签: android image crop panning
我正在寻找 Google 相册应用风格的图像处理。我对图像处理有点陌生。任何关于如何使图像的裁剪矩形与裁剪矩形大小相同、旋转(旋转图像和裁剪矩形)、图像拉直(包括如何获得那种角度滑块类型的 UI)的任何线索都会很棒。如果有一些库具有这些功能,那也可以。
【问题讨论】:
标签: android image crop panning
Square 有一个用于加载和播放图像的库。 以下是一些功能:
- Handling ImageView recycling and download cancelation in an adapter. - Complex image transformations with minimal memory use. - Automatic memory and disk caching.
在他们的网站上有关于如何使用该库的详细信息。看看吧: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);
编辑: 看起来我第一次阅读时并没有完全理解你的问题。这里有一些关于你想要达到的目标的提示。可能不是你想要的,但我认为这可能是一个开始。
如果要旋转图像,可以使用 Picasso 使用 RequestCreator.rotate(float degrees) 来完成。
这是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 sdk 提供了一些帮助。可能不完全是您正在寻找的东西,但值得一试。看看这里。
可以在这里找到可用效果列表
http://developer.android.com/reference/android/media/effect/EffectFactory.html
【讨论】: