https://stackoverflow.com/questions/20783830/how-to-use-renderscript-with-multiple-input-allocations

For the kernel with multiple inputs you would have to manually handle additional inputs.

Let's say you want 2 inputs.

example.rs:

rs_allocation extra_alloc;

uchar4 __attribute__((kernel)) kernel(uchar4 i1, uint32_t x, uint32_t y)
{
// Manually getting current element from the extra input
uchar4 i2 = rsGetElementAt_uchar4(extra_alloc, x, y);
// Now process i1 and i2 and generate out
uchar4 out = ...;
return out;
}

Java:

Bitmap bitmapIn = ...;
Bitmap bitmapInExtra = ...;
Bitmap bitmapOut = Bitmap.createBitmap(bitmapIn.getWidth(),
bitmapIn.getHeight(), bitmapIn.getConfig()); RenderScript rs = RenderScript.create(this);
ScriptC_example script = new ScriptC_example(rs); Allocation inAllocation = Allocation.createFromBitmap(rs, bitmapIn);
Allocation inAllocationExtra = Allocation.createFromBitmap(rs, bitmapInExtra);
Allocation outAllocation = Allocation.createFromBitmap(rs, bitmapOut); // Execute this kernel on two inputs
script.set_extra_alloc(inAllocationExtra);
script.forEach_kernel(inAllocation, outAllocation); // Get the data back into bitmap
outAllocation.copyTo(bitmapOut); //-----------------------------------------------------------------------------

hen you only need a grayscale camera preview, you could use a very simple renderscript:

# pragma version(1)
# pragma rs java_package_name(com.example.name)
# pragma rs_fp_relaxed rs_allocation gIn; // Allocation filled with camera preview data (byte[])
int previewwidth; // camera preview width (int) // the parallel executed kernel
void root(uchar4 *v_out, uint32_t x,uint32_t y){
uchar c = rsGetElementAt_uchar(gIn,x+y*previewwidth);
*v_out = (uchar4){c,c,c,255};
}
 

RenderScript多输入参数的更多相关文章

  1. 如何获得Webapp的根项目路径 即ServletContext.getRealPath() 的输入参数要以"/"开头

    ServletContext.getRealPath() 的输入参数要以"/"开头 2014-03-26 15:54 5738人阅读 评论(1) 收藏 举报 版权声明:本文为博主原 ...

  2. 阿里云提示:对输入参数id未进行正确类型转义,导致整型注入的发生

    类似以下提示: XXX.php中,对输入参数id未进行正确类型转义,导致整型注入的发生 解决办法: 找到对应文件:$id = $_GET['id']; 增加以下标红过滤: $id = $_GET['i ...

  3. java Servlet+mysql 调用带有输入参数和返回值的存储过程(原创)

    这个数据访问的功能,我在.NET+Mysql .NET+Sqlserver  PHP+Mysql上都实现过,并且都发布在了我博客园里面,因为我觉得这个功能实在是太重要,会让你少写很多SQL语句不说,还 ...

  4. 使用getopts处理shell中的输入参数

    在编写shell脚本中,经常要处理一些输入参数,在使用过程中发现getopts更加方便,能够很好的处理用户输入的参数和参数值.   getopts用于处理用户输入参数,举例说明使用方法: while ...

  5. SQL Server存储过程中使用表值作为输入参数示例

    这篇文章主要介绍了SQL Server存储过程中使用表值作为输入参数示例,使用表值参数,可以不必创建临时表或许多参数,即可向 Transact-SQL 语句或例程(如存储过程或函数)发送多行数据,这样 ...

  6. 输入参数是NSDate,输出结果是星期几的字符串

    给你一个方法,输入参数是NSDate,输出结果是星期几的字符串.+ (NSString*)weekdayStringFromDate:(NSDate*)inputDate { NSArray *wee ...

  7. Shell脚本中判断输入参数个数的方法投稿:junjie 字体:[增加 减小] 类型:转载

    Shell脚本中判断输入参数个数的方法 投稿:junjie 字体:[增加 减小] 类型:转载   这篇文章主要介绍了Shell脚本中判断输入参数个数的方法,使用内置变量$#即可实现判断输入了多少个参数 ...

  8. main()函数的输入参数 main(int argc, char** argv)

    一般简单的C++程序,main函数的写法都是 int main() {... ; return 0;},但是,如果在运行程序时需要有参数输入,可以是使用将主函数写成int main(int argv, ...

  9. 输入参数varargin

    一种特别的输入参数varargin 可以在自定义函数中得到,这种函数支持输入参数的变量的个数.这个参数显在输入参数列表的最后一项,它返回一个单元阵列,所以一个输入实参可以包括任意数目的实参.每一个实参 ...

随机推荐

  1. Android中的TextView实现多行显示省略号以及下划线的实现

    android:lines="2" android:ellipsize="end" 显示两行,多余部分…显示 textView.getPaint().setFl ...

  2. 11.Curator扩展库

        Recipes组件包含了丰富的Curator应用的组件.但是这些并不是ZooKeeper Recipe的全部.大量的分布式应用已经抽象出了许许多多的的Recipe,其中有些还是可以通过Cura ...

  3. react-native 学习(二)

    上一节讲到了 react-native的开发环境的配置,,这一节我门具体讲讲怎么看样式,怎么调试 看样式的话 有一个 神奇 react-native-developer tools(个人推荐,可选择性 ...

  4. web.xml 中以编码方式添加filter并设置初始化参数AbstractAnnotationConfigDispatchServletInitializer

    web.xml中配置filter <?xml version="1.0" encoding="UTF-8"?> <web-app versio ...

  5. puppeteer部署到centOS上出现launch chrome fail的情况

    在Mac上调试无问题,放到阿里云上运行会报错. 需要先安装依赖, yum install pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 lib ...

  6. Spring Data 之 Repository 接口

    1. 介绍 Repository是一个空接口,即是一个标记性接口; 若我们定义的接口继承了Repository,则该接口会被IOC容器识别为一个 Repository Bean; 也可以通过@Repo ...

  7. window 如何枚举设备并禁用该设备和启用该设备?如何注册设备热拔插消息通知?

    目前实现的功能: 1.设备枚举 2.设置设备禁用和启用 3.注册设备热拔插消息通知 4.获取设备 vid pid 数值 需要链接的库 SetupAPI.lib DeviceManager 类如下: D ...

  8. Linux命令:nl

    全称:number lines of files 用途:显示的时候添加行号. 格式:nl [OPTION]... [FILE]... 类型:nl is /usr/bin/nl 说明: 该命令主要就是针 ...

  9. 利用AES算法加密数据

    准备工作: 模块安装问题: 首先在python中安装Crypto这个包 但是在安装模块后在使用过程中他会报错 下面是解决方法: pip3 install pycrypto 安装会报错 https:// ...

  10. HTML容易遗忘内容(二)

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> ...