Search code examples
androidrenderscriptcolormatrixandroid-renderscript

ScriptIntrinsicColorMatrix: setAdd method is not implemented in support library


Here is my question: I'm working with real time image processing, so I want to use ScriptIntrinsicColorMatrix instead of regular ColorMatrix (cause it's much faster)

android.renderscript.ScriptIntrinsicColorMatrix (API level 19) has method setAdd

void    setAdd(float r, float g, float b, float a)
void    setAdd(Float4 f)
Set the value to be added after the color matrix has been applied.

its parameters has the same meaning as (e, j, o, t) in ColorMatrix formula

   R’ = a*R + b*G + c*B + d*A + e;
   G’ = f*R + g*G + h*B + i*A + j;
   B’ = k*R + l*G + m*B + n*A + o;
   A’ = p*R + q*G + r*B + s*A + t;

My min SDK version is 14, so I've got to use android.support.v8.renderscript.ScriptIntrinsicColorMatrix from support library.
Unfortunately it doesn't have these setAdd methods. And I can't find a workaround for them.

Did anybody have deal with that problem? Is it possible to fully cover ColorMatrix features with render script Instrinsic from support library or should I write my own custom RenderScript?


Solution

  • Ok, possible solution (thanks to pskink for advising):

    1) Change build tool version to 23.0.0 (it won't compile at this point due to defect in this build tool)
    2) Try workaround from this guy
    3) Profit

    I've just tested it, and it works. Hope android will fix this defect soon