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. 各种层次NET人应该知道些什么?

    A.任何一个使用.NET的人 1.描述线程与进程的区别? 2.什么是Windows服务,它的生命周期与标准的EXE程序有什么不同 ? 3.Windows上的单个进程所能访问的最大内存量是多少?它与系统 ...

  2. centos-iptables-scripts

    author:headsen chen date:2018-06-04  11:20:38 notice:This  article is created by headsen chen himsel ...

  3. 【BZOJ4864】[BeiJing 2017 Wc]神秘物质 Splay

    [BZOJ4864][BeiJing 2017 Wc]神秘物质 Description 21ZZ 年,冬. 小诚退休以后, 不知为何重新燃起了对物理学的兴趣. 他从研究所借了些实验仪器,整天研究各种微 ...

  4. iOS UITextField更改placeholder颜色

    [_textField setValue:COLOR_PLACEHOLDER   forKeyPath:@"_placeholderLabel.textColor"];

  5. python3 + selenium + (chrome and firefox)使用

    目录 瞎扯一句 简介 最后放模板 瞎扯一句 最近在做一个关于 selenium 相关的项目,在选择浏览器方面,一般有3种方案: chrome phantomJs firefox(推荐) 网上有很多教程 ...

  6. Linux安装vsftpd

    卸载vsftpd sudo yum remove vsftpd 安装vsftpd sudo yum -y install vsftpd 创建一个文件夹用来当作ftp得仓库 cd / sudo mkdi ...

  7. setTimeout 里 传递字符串代码报错

    js高程 第三版 p203 重点:超时调用的代码都是在全局作用域中执行的,因此函数中this 的值在非严格模 式下指向window 对象,在严格模式下是undefined. 不过这里仅仅解释前半句: ...

  8. linux devcie lspci,lscpu,blkdiscard,fstrim,parted,partprobe,smartctl

    blkdiscard/sparse/thin-provisioned device,like ssdfstrim--- discard unused blocks on a mounted files ...

  9. bash characters

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

  10. Big Data资料汇总

    整理和翻新一下自己看过和笔记过的Big Data相关的论文和Blog Streaming & Spark In-Stream Big Data Processing Discretized S ...