Advertisement
Guest User

Untitled

a guest
Nov 25th, 2014
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1), thread 21581 (enderscripttest)
  2.  
  3. @Override
  4. protected void onCreate(Bundle savedInstanceState) {
  5. super.onCreate(savedInstanceState);
  6. setContentView(R.layout.activity_main);
  7.  
  8. imageView = (ImageView)findViewById(R.id.image);
  9.  
  10. BitmapFactory.Options opts = new BitmapFactory.Options();
  11. opts.inSampleSize = 8;
  12. originalBitmap = BitmapFactory.decodeResource(getResources(),R.drawable.colors,opts);
  13. filteredBitmap = Bitmap.createBitmap(originalBitmap.getWidth(),originalBitmap.getHeight(), originalBitmap.getConfig());
  14.  
  15. //RENDERSCRIPT ALLOCATION
  16. mRS = RenderScript.create(this);
  17. mInAllocation = Allocation.createFromBitmap(mRS, originalBitmap,Allocation.MipmapControl.MIPMAP_NONE,Allocation.USAGE_SCRIPT);
  18. mOutAllocation = Allocation.createTyped(mRS, mInAllocation.getType());
  19. mOutAllocation.copyFrom(originalBitmap);
  20. mOutAllocation.copyTo(filteredBitmap);
  21.  
  22. ScriptC_brightnessfilter helloworldScript = new ScriptC_brightnessfilter(mRS);
  23.  
  24. helloworldScript.set_brightnessValue(4.0f);
  25. helloworldScript.bind_gPixels(mInAllocation);
  26.  
  27. helloworldScript.set_gIn(mInAllocation);
  28. helloworldScript.set_gOut(mOutAllocation);
  29. helloworldScript.set_gScript(helloworldScript);
  30. helloworldScript.invoke_filter();
  31. mOutAllocation.copyTo(filteredBitmap);
  32.  
  33. }
  34.  
  35. #pragma version(1)
  36. #pragma rs java_package_name(com.dss.renderscripttest)
  37.  
  38. float brightnessValue;
  39.  
  40. rs_allocation gIn;
  41. rs_allocation gOut;
  42. rs_script gScript;
  43.  
  44. static int mImageWidth;
  45. const uchar4 *gPixels;
  46.  
  47. void root(const uchar4 *v_in, uchar4 *v_out, const void *usrData, uint32_t x, uint32_t y) {
  48.  
  49. float4 apixel = rsUnpackColor8888(*v_in);
  50. float3 pixel = apixel.rgb;
  51. float factor = brightnessValue;
  52. pixel = pixel + factor;
  53. pixel = clamp(pixel,0.0f,1.0f);
  54. *v_out = rsPackColorTo8888(pixel.rgb);
  55. }
  56.  
  57.  
  58. void filter() {
  59. mImageWidth = rsAllocationGetDimX(gIn);
  60. rsDebug("Image size is ", rsAllocationGetDimX(gIn), rsAllocationGetDimY(gOut));
  61. rsForEach(gScript, gIn, gOut, 0, 0);
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement