Android RenderScript - Syntax Error -


my current script is:

#pragma version(1) #pragma rs java_package_name(foo.bar)  rs_allocation inpixels; int height; int width; int threebythree[];  void root(const uchar4 *in, uchar4 *out, uint32_t x, uint32_t y) {     float3 pixel = convert_float4(in[0]).rgb;      if(x==0 || x==width || y==0 || y==height){         pixel.r = 0;         pixel.g = 191;         pixel.b = 255;     }else{ //do image processing here          float3 pixelnh = convert_float4(rsgetelementat_uchar4(inpixels, x+1, y)).rgb;         float3 pixelnv = convert_float4(rsgetelementat_uchar4(inpixels, x, y+1)).rgb;          int grayavg = (pixel.r + pixel.g + pixel.b)/3;         int grayavgnh = (pixelnh.r + pixelnh.g + pixelnh.b)/3;         int grayavgnv = (pixelnv.r + pixelnv.g + pixelnv.b)/3;          int edgeoperatorvalue = 2*grayavg - grayavgnh - grayavgnv;          if(edgeoperatorvalue < 0){             edgeoperatorvalue = -1 * edgeoperatorvalue;         };          pixel.r = edgeoperatorvalue;         pixel.g = edgeoperatorvalue;         pixel.b = edgeoperatorvalue;     };      out->xyz = convert_uchar3(pixel); } 

after following advice here: renderscript, `in` parameter?

i replaced code 1 (it doesnt matter if not same thing want compile now):

uchar4 rs_kernel root(uchar4 in, uint32_t x, uint32_t y) {   // x , y aren't used, can remove above signature too.   uchar4 out;   float3 pixel = convert_float4(in).rgb;    pixel.r = (pixel.r + pixel.g + pixel.b)/3;   // seems buggy me below, since pixel.r modified.   // think need temporary variable (assuming trying make work , getting weird behavior).   pixel.g = (pixel.r + pixel.g + pixel.b)/3;   pixel.b = (pixel.r + pixel.g + pixel.b)/3;    //int topright   //float4 f4 = rsunpackcolor8888(*(uchar*)rsgetelementat(inpixels, x+1, y+1));    out.xyz = convert_uchar3(pixel);   return out; } 

and now:

/home/projects/android/bar/app/src/main/rs/edgedetect.rs:8:17: error: expected ';' after top level declarator 

what complaining ? (line 8 btw uchar4 rs_kernel root(uchar4 in, uint32_t x, uint32_t y) {)

edit: in build.gradle:

apply plugin: 'com.android.application'  android {     compilesdkversion 19     buildtoolsversion '19.1.0'      defaultconfig {         applicationid "foo.bar"         minsdkversion 15         targetsdkversion 19         versioncode 1         versionname "1.0"          renderscripttargetapi 19         renderscriptsupportmodeenabled true //not applicable rs targetapi 21+     }     buildtypes {         release {             minifyenabled false             proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro'         }     } } 

this type of error appears when use variables have not been defined. i'll agree it's not clear.

if notice, defined following variable:

uchar4 out; 

then later, use this:

out.xyz = convert_uchar3(pixel); 

except, you're trying access property of variable never defined.

try initializing this:

uchar4 out = in; 

if gets rid of error, problem. if reason cant use out = in, other ways of initializing out variable.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -