applying effect using Renderscript in android
<p>i am new to android and just started using the renderscript in order to do some imageprocessing,first i followed the android documentation and import the sample program for renderscript for android 14 and import the project Hellocompute which says it will give the greyscale effect to the image.Mentioning all the class and file used in it.</p>

<p>Hellocompute.java file:-</p>

<pre><code>public class HelloCompute extends Activity {
    private Bitmap mBitmapIn;
    private Bitmap mBitmapOut;

    private RenderScript mRS;
    private Allocation mInAllocation;
    private Allocation mOutAllocation;
    private ScriptC_mono mScript;
    private ImageView in ,out;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mBitmapIn = loadBitmap(R.drawable.a06);
        mBitmapOut = Bitmap.createBitmap(mBitmapIn.getWidth(), mBitmapIn.getHeight(),
                                         mBitmapIn.getConfig());

         in = (ImageView) findViewById(R.id.displayin);
        in.setImageBitmap(mBitmapIn);
        Log.e("INPUT", "IMAGE");

      out = (ImageView) findViewById(R.id.displayout);
        //out.setImageBitmap(mBitmapOut);

        createScript();

        out.setImageBitmap(mBitmapOut);

        Log.e("OUTPUT", "IMAGE");

    }


    private void createScript() {
        mRS = RenderScript.create(this);

        mInAllocation = Allocation.createFromBitmap(mRS, mBitmapIn,
                                                    Allocation.MipmapControl.MIPMAP_NONE,
                                                    Allocation.USAGE_SCRIPT);
        mOutAllocation = Allocation.createTyped(mRS, mInAllocation.getType());

        mScript = new ScriptC_mono(mRS, getResources(), R.raw.mono);

        mScript.forEach_root(mInAllocation, mOutAllocation);

        mOutAllocation.copyTo(mBitmapOut);
       // out.invalidate();



    }

    private Bitmap loadBitmap(int resource) {
        final BitmapFactory.Options options = new BitmapFactory.Options();
        options.inPreferredConfig = Bitmap.Config.ARGB_8888;
        return BitmapFactory.decodeResource(getResources(), resource, options);
    }
}
</code></pre>

<p>and now the mono.rs which is used for effect applying in the image.
mono.rs file:-</p>

<pre><code>#pragma version(1)
#pragma rs java_package_name(com.example.android.rs.hellocompute)

const static float3 gMonoMult = {0.299f, 0.590f, 0.134f};

void root(const uchar4 *v_in, uchar4 *v_out) {
    float4 f4 = rsUnpackColor8888(*v_in);

    float3 mono = dot(f4.rgb, gMonoMult);
    *v_out = rsPackColorTo8888(mono);


}
</code></pre>

<p>taken some image in the drawable and then execute it.while in the process of executing logcat also having some error so mentioning that also.</p>

<p>logcat info.</p>

<pre><code>04-29 14:40:51.283: D/dalvikvm(1045): GC_FOR_ALLOC freed 62K, 2% free 14120K/14339K, paused 42ms
04-29 14:40:51.303: I/dalvikvm-heap(1045): Grow heap (frag case) to 15.618MB for 1846416-byte allocation
04-29 14:40:51.453: D/dalvikvm(1045): GC_CONCURRENT freed 1K, 2% free 15922K/16199K, paused 11ms+3ms
04-29 14:40:51.595: D/dalvikvm(1045): GC_FOR_ALLOC freed 0K, 2% free 15922K/16199K, paused 32ms
04-29 14:40:51.643: I/dalvikvm-heap(1045): Grow heap (frag case) to 22.660MB for 7385616-byte allocation
04-29 14:40:51.773: D/dalvikvm(1045): GC_CONCURRENT freed 0K, 2% free 23135K/23431K, paused 15ms+6ms
04-29 14:40:52.003: D/dalvikvm(1045): GC_FOR_ALLOC freed 1803K, 9% free 21331K/23431K, paused 32ms
04-29 14:40:52.053: I/dalvikvm-heap(1045): Grow heap (frag case) to 27.943MB for 7385616-byte allocation
04-29 14:40:52.183: D/dalvikvm(1045): GC_CONCURRENT freed &lt;1K, 7% free 28544K/30663K, paused 11ms+5ms
04-29 14:40:52.193: E/INPUT(1045): IMAGE
04-29 14:40:52.193: V/RenderScript(1045): rsContextCreate dev=0x1696a8
04-29 14:40:52.193: V/RenderScript(1045): 0x1b79e0 Launching thread(s), CPUs 1
04-29 14:40:52.403: V/ScriptC(1045): Create script for resource = mono
04-29 14:40:52.403: I/bcc(1045): LIBBCC build time: 2011/11/23 22:56:57
04-29 14:40:52.403: I/bcc(1045): LIBBCC build revision: df1bc78e24cf2b6a71f2b3809ffb46521e5521a8 (git)
04-29 14:40:52.463: D/StopWatch(1045): StopWatch calcFileSHA1 time (us): 58162 
04-29 14:40:52.473: D/StopWatch(1045): StopWatch calcFileSHA1 time (us): 8238 
04-29 14:40:52.483: D/bcc(1045): Read object file size 727
04-29 14:40:52.483: D/StopWatch(1045): StopWatch bcc: PrepareExecutable time (us): 2824 
04-29 14:40:52.483: E/bcc(1045): Symbol not found: init
04-29 14:40:52.483: E/bcc(1045): Symbol not found: .rs.dtor
04-29 14:40:53.444: E/OUTPUT(1045): IMAGE
04-29 14:40:53.573: D/gralloc_goldfish(1045): Emulator without GPU emulation detected.
</code></pre>

<p>so u will find in the logcat info that <strong>symbol not found:init</strong>
and another one <strong>.rs.dtor</strong></p>

<p>and after sucessfull execution(no force closing) there is no effect on the image the same image(input) is displayed.so not getting and stuck so can anyone tell me where i m doing wrong and is there any missing in any file content.Thanks for any reply.</p>
