简体   繁体   English

Renderscript 如何从 2d 浮点数组初始化缓冲区以进行分配

[英]Renderscript how to init a buffer from a 2d float array for an allocation

I read the Android documentation about allocations and I also used them in few renderscripts.我阅读了有关分配的 Android 文档,并且还在一些渲染脚本中使用了它们。 But there is something that still I couldn't understand.但是有一点我仍然无法理解。

If I create an allocation with createTyped() I create the structure but not the buffer, actually until now I used this method for input allocations and the buffer is then assigned when it does ioReceive() .如果我使用createTyped()创建分配,我会创建结构而不是缓冲区,实际上直到现在我使用这种方法进行输入分配,然后在执行ioReceive()时分配缓冲区。 To create an output allocation usually I use createFromBitmap() because this method also allocates the buffer.为了创建输出分配,我通常使用createFromBitmap()因为这个方法也会分配缓冲区。 Otherwise to assign the buffer I can use setSurface() .否则我可以使用setSurface()分配缓冲区。

But now I need an output allocation for a 2D float array, how can initialize and assign the buffer for such allocation?但是现在我需要一个 2D 浮点数组的输出分配,如何为这种分配初始化和分配缓冲区?

您可以使用 createTyped() 创建分配,然后通过调用 copyFrom(myfloatarray) 对其进行初始化,其中 myfloatarray 是 Java 中的浮点值数组。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM