作为标题,我正试图开发一个应用程序的图像过滤器,如instagram。我可以使用CPUImage库为照片添加效果,但在水平滚动视图中显示图像过滤器选项有困难。
我的想法是创建一组显示不同过滤效果的演示图片,并将它们列在水平滚动视图中。当选择演示图片时,使用CPUImage库添加相应的效果。
问题是:
:这是在水平滚动视图中实现图像过滤器的最简单的方法吗?
我错过了做同样事情的任何现有的引用、教程或库吗?
任何帮助都是非常感谢的。谢谢你们。
发布于 2014-06-21 07:58:13
在花了一些时间来理解我们如何合并水平滚动视图和gpuImageFilter之后,我能够实现instagram一样的图像过滤器。
一些相关的链接和代码共享,下面的任何人有相同的问题。
代码
// Set the current effect mode as image border or filter
private void setEffectMode(String mode)
{
// Compute the width of a carousel item based on the screen width and
// number of initial items.
final DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
final int imageWidth = (int) (displayMetrics.widthPixels / INITIAL_ITEMS_COUNT);
TypedArray filterResourcesTypedArray = null;
mCarouselContainer.removeAllViews();
if (mode.equals(borderMode))
{
// Get the array of puppy resources
filterResourcesTypedArray = getResources().obtainTypedArray(R.array.borderArray);
} else if (mode.equals(filterMode))
{
// Get the array of puppy resources
filterResourcesTypedArray = getResources().obtainTypedArray(R.array.filterArray);
}
// Populate the carousel with items
for (int i = 0; i < filterResourcesTypedArray.length(); i++)
{
// Create new ImageView
imageItem = new ImageView(this);
imageItem.setId(i);
imageItem.setTag(mode);
// Set the image view resource
imageItem.setImageResource(filterResourcesTypedArray.getResourceId(i, -1));
// Set the size of the image view to the previously computed value
imageItem.setLayoutParams(new LinearLayout.LayoutParams(imageWidth, imageWidth));
// / Add image view to the carousel container
mCarouselContainer.addView(imageItem);
imageItem.setOnClickListener(this);
}
}如何创建水平图像滚动视图http://www.smashingmagazine.com/2013/02/01/android-carousel-design-pattern/
https://stackoverflow.com/questions/24168668
复制相似问题