首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >android-gpuimage -在像instagram这样的水平滚动视图中提供图像过滤器。

问android-gpuimage -在像instagram这样的水平滚动视图中提供图像过滤器。
EN

Stack Overflow用户
提问于 2014-06-11 17:08:27
回答 1查看 1.4K关注 0票数 0

作为标题,我正试图开发一个应用程序的图像过滤器,如instagram。我可以使用CPUImage库为照片添加效果,但在水平滚动视图中显示图像过滤器选项有困难。

我的想法是创建一组显示不同过滤效果的演示图片,并将它们列在水平滚动视图中。当选择演示图片时,使用CPUImage库添加相应的效果。

问题是:

:这是在水平滚动视图中实现图像过滤器的最简单的方法吗?

我错过了做同样事情的任何现有的引用、教程或库吗?

任何帮助都是非常感谢的。谢谢你们。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-06-21 07:58:13

在花了一些时间来理解我们如何合并水平滚动视图和gpuImageFilter之后,我能够实现instagram一样的图像过滤器。

一些相关的链接和代码共享,下面的任何人有相同的问题。

代码

代码语言:javascript
复制
// 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/

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24168668

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档