简体   繁体   English

Google关于RenderScript的代码不起作用?

[英]the Google's code about RenderScript does not work?

i find that the google's doc about the RenderScript has update( https://developer.android.com/guide/topics/renderscript/compute.html ). 我发现有关RenderScript的Google文档已更新( https://developer.android.com/guide/topics/renderscript/compute.html )。 so i use it's code to test but o got an error about that 所以我用它的代码来测试,但是关于这个有一个错误

Error:(31, 23) error: implicit declaration of function 'rsCreateAllocation_uchar4' is invalid in C99
Error:(31, 17) error: initializing 'rs_allocation' (aka 'struct rs_allocation') with an expression of incompatible type 'int'

that is the code: 那是代码:

rs_allocation tmp = rsCreateAllocation_uchar4(imageWidth, imageHeight);
rsForEach(invert, inputImage, tmp);
rsForEach(greyscale, tmp, outputImage);

so i want to know: 1:why this happen(i think the sdk api is the reason but i have update my AS, SDK and sdk tool to newest)? 所以我想知道:1:为什么会这样(我认为sdk api是原因,但是我已经将AS,SDK和sdk工具更新到最新)? 2:what's the difference between the 2:两者之间有什么区别

uchar4 RS_KERNEL root(uchr4 in, unit32_t x, uint32_t y)

and

void RS_KERNEL root(uchr4* in, uchar4* out, unit32_t x, uint32_t y)

i think the second method is more fast?! 我认为第二种方法更快? but i can't sure. 但我不确定。 and the method that using the pointer as params is'n used to a function that not named root()(i test it).so if the method with pointer params is faster how can i use 2 or more kernel function in a RS file? 并且使用指针作为参数的方法不用于未命名为root()的函数(我对其进行测试)。因此,如果使用指针参数的方法更快,我如何在RS文件中使用2个或更多内核函数?

The rsCreateAllocation*() functions are only available when targeting Android Nougat (ie API level 24 and higher). rsCreateAllocation *()函数仅在以Android Nougat为目标(即API级别24和更高版本)时可用。 I assume that you are getting this error because you have chosen a RenderScript target API that is much lower than that. 我认为您收到此错误是因为您选择的RenderScript目标API远低于此。

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

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