Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1), thread 21581 (enderscripttest)
- @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());
- //RENDERSCRIPT ALLOCATION
- mRS = RenderScript.create(this);
- mInAllocation = Allocation.createFromBitmap(mRS, originalBitmap,Allocation.MipmapControl.MIPMAP_NONE,Allocation.USAGE_SCRIPT);
- mOutAllocation = Allocation.createTyped(mRS, mInAllocation.getType());
- mOutAllocation.copyFrom(originalBitmap);
- mOutAllocation.copyTo(filteredBitmap);
- ScriptC_brightnessfilter helloworldScript = new ScriptC_brightnessfilter(mRS);
- helloworldScript.set_brightnessValue(4.0f);
- helloworldScript.bind_gPixels(mInAllocation);
- helloworldScript.set_gIn(mInAllocation);
- helloworldScript.set_gOut(mOutAllocation);
- helloworldScript.set_gScript(helloworldScript);
- helloworldScript.invoke_filter();
- mOutAllocation.copyTo(filteredBitmap);
- }
- #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);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement