android - Is it possible to use one allocation for a chain of renderscript actions? -
For example, I do it) to allocate a bitmap, then aplly brightnessContrastRs (and then something different with the same implementation create filters that allocation, but replaced by brightnessContrastRs () action?
public bitmap brightnessContrastRs (bitmap bmIn, integer brightness, contrast integer) {bitmap bmOut = Bitmap.createBitmap (bmIn.getWidth () , bmIn. GetHeight (), Bimin Confif .get ()); allocation allocation; allocIn = Allocation.createFromBitmap (Rs, bmIn, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT); Distribution AllocOut = Allocation. Cut (RS, allocIn.getType ()); scriptCBrightnessContrast.set_in (allocIn); allocIn.destroy (); scriptCBrightnessContrast.set_out (allocOut); scriptCBrightnessContrast.set_script (scriptCBrightnessContrast); Float row Contrast = (( 100.0 F + Contrast) * (100.0 F + Contrast) / 10000.0F); Float Row Brightness = Brightness / 255.F; scriptCBrightnessContrast.set_rowBrightness (rowBrightness); ScriptCBrightnessContrast.set_rowContrast (rowContrast); ScriptCBrightnessContrast.invoke_filter (); AllocOut.copyTo (bmOut); AllocOut.destroy (); Back to BMOt; } RS script:
rs_allocation outside; In rs_allocation; Rs_script script; Float line brightness; Float row contrast; Zero root (constant uchar4 * v_in, uchar4 * v_out, const void * usrData, uint32_t X, Uint32_t y) {Float4 current = rsUnpackColor8888 (* v_in); Current.r = clamp ((clamp (current.r + rowBrightness, 0.0f, 1.0f) - 0.5f) * rowContrast + 0.5f), 0.0f, 1.0f); Current.g = clamp ((Clamp (current. G + robertite, 0.0 f, 1.0 f) - 0.5 f) * Row Communication + 0.5 F), 0.0 F, 1.0 F); Current.b = clamp ((clamp (current.b + rowBrightness, 0.0f, 1.0f) - 0.5f) * rowContrast + 0.5f), 0.0f, 1.0f); * V_out = rsPackColorTo8888 (current .r, current g, current b, current. A); } Zero filter () {#if! Defined (RS_VERSION) || (RS_VERSION & lt; 14) rsForEach (script, in, out, 0); #alles rsfarh (script, in, out); #endif}
If you are asking if you pass allotment like this Yes, you can definitely do this, however, you can not start allocin that fast, because it still needs to be used by the script when it is introduced.
Comments
Post a Comment