I am trying to create an image processing library built into renderscript. I played with android samples for renderscript here.
Renderscript has everything I need to create this library, unfortunately, I cannot get many examples to work for me.
Example ImageProcecssing is a good example of how everything works for me. Most of Script Intrinsics work out of the box, no errors. However, as soon as I go to the ScriptC file, even performing basic operations tends to fail. And unfortunately, I mean
Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1), thread 21581 (enderscripttest)
So, to help debugging, I created a github repo with literally the most basic example that I could come up with. Basically this is just an attempt to apply a brightness filter to the image representation.
Relevant Code:
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); imageView = (ImageView)findViewById(R.id.image); BitmapFactory.Options opts = new BitmapFactory.Options(); opts.inSampleSize = 8; originalBitmap = BitmapFactory.decodeResource(getResources(),R.drawable.colors,opts); filteredBitmap = Bitmap.createBitmap(originalBitmap.getWidth(),originalBitmap.getHeight(), originalBitmap.getConfig());
Then renderscript file
#pragma version(1) #pragma rs java_package_name(com.dss.renderscripttest) float brightnessValue; rs_allocation gIn; rs_allocation gOut; rs_script gScript; static int mImageWidth; const uchar4 *gPixels; void root(const uchar4 *v_in, uchar4 *v_out, const void *usrData, uint32_t x, uint32_t y) { float4 apixel = rsUnpackColor8888(*v_in); float3 pixel = apixel.rgb; float factor = brightnessValue; pixel = pixel + factor; pixel = clamp(pixel,0.0f,1.0f); *v_out = rsPackColorTo8888(pixel.rgb); } void filter() { mImageWidth = rsAllocationGetDimX(gIn); rsDebug("Image size is ", rsAllocationGetDimX(gIn), rsAllocationGetDimY(gOut)); rsForEach(gScript, gIn, gOut, 0, 0); }
I tested this only on the Galaxy S3 and S4. I will spend on Nexus 4 tonight and see if I get a different result.
Edit:
I have confirmed that this code works on Nexus 4. I will work with some other devices for a good evaluation. I’ll also see if I can get the APK together in case Stephen Hines or Tim Murray wants to watch, but now it seems that only Galaxy S3 and S4 are implemented (both 4.3)
Edit 2: I believe this is the very problem that is happening here here . I will be updated as both issues move forward.