Time for action – writing a luminance threshold filter

Let's append a new component to our UI and implement the new image filter.

  1. Add a new Threshold SeekBar and Button in res/activity_renderscript.xml:
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
      xmlns:a="http://schemas.android.com/apk/res/android"
      a:layout_width="fill_parent" a:layout_height="fill_parent"
      a:layout_weight="1" a:orientation="vertical" >
      <LinearLayout 
        a:orientation="horizontal"
        a:layout_width="fill_parent" a:layout_height="wrap_content" >
        ...
        <SeekBar a:id="@+id/thresholdBar" a:max="100"
          a:layout_gravity="center_vertical"
          a:layout_width="128dp" a:layout_height="wrap_content" />
        <Button a:id="@+id/thresholdButton" a:text="Threshold"
     a:layout_width="wrap_content" a:layout_height="wrap_content"/> ...

Get Android NDK Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.