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. centos6上安装docker

    yum -y install epel-releaseyum -y install docker-ioyum install device-mapper-event-libs  # 必需安装这一步,否 ...

  2. 【BZOJ1495】[NOI2006]网络收费 暴力+DP

    [BZOJ1495][NOI2006]网络收费 Description 网络已经成为当今世界不可或缺的一部分.每天都有数以亿计的人使用网络进行学习.科研.娱乐等活动.然而,不可忽视的一点就是网络本身有 ...

  3. 堪称神器的Windows软件推荐

    更多软件使用技巧.破解软件以及硬件选购知识,欢迎加入我的QQ群(701974765)与我们交流!! 先贴上软件列表,详细描述后期更新,可自行百度 TrafficMonitor CPU.内存.网速资源监 ...

  4. MongoDB 使用 ObjectId 代替时间

    An ObjectId is a 12-byte unique identifier consisting of: a 4-byte value representing the seconds si ...

  5. 粘性会话 session affinity sticky session requests from the same client to be passed to the same server in a group of servers

    Module ngx_http_upstream_module http://nginx.org/en/docs/http/ngx_http_upstream_module.html#sticky S ...

  6. the age of the TCP connection TCP Slow Start

    w防止网络过载和拥塞 HTTP The Definitive Guide The performance of TCP data transfer also depends on the age of ...

  7. bash characters

    linux shell通配符(wildcard) 通配符是由shell处理的(不是由所涉及到命令语句处理的,其实我们在shell各个命令中也没有发现有这些通配符介绍), 它只会出现在 命令的“参数”里 ...

  8. 用flask开发个人博客(4)—— flask中4种全局变量

    https://blog.csdn.net/hyman_c/article/details/53512109 一  current_app current_app代表当前的flask程序实例,使用时需 ...

  9. IIs7下配置php

    因为一个朋友的服务器是window的需要两个版本的php,一个是现在用的php5.2,现在要用一个5.3的版本,所以考虑IIS下的配置. 1.首先当然是要下载一份php了,我采用的是免安装的,很方便, ...

  10. 剑指Offer——不用加减乘除做加法

    题目描述: 写一个函数,求两个整数之和,要求在函数体内不得使用+.-.*./四则运算符号. 分析: "^"是不带进位的加法. "&"可以得到所有进位位组 ...