public void useImageFilter(
      ImageSmallFilter imageSmallFilter, ImageFilter imageFilter, boolean setBorder) {
    if (imageFilter == null) {
      return;
    }

    if (mCurrentImageSmallFilter != null) {
      mCurrentImageSmallFilter.setSelected(false);
    }
    mCurrentImageSmallFilter = imageSmallFilter;
    mCurrentImageSmallFilter.setSelected(true);

    ImagePreset oldPreset = mImageShow.getImagePreset();
    ImagePreset copy = new ImagePreset(oldPreset);
    // TODO: use a numerical constant instead.

    copy.add(imageFilter);

    mImageShow.setImagePreset(copy);
    invalidateViews();
  }
  public void useImagePreset(ImageSmallFilter imageSmallFilter, ImagePreset preset) {
    if (preset == null) {
      return;
    }

    if (mCurrentImageSmallFilter != null) {
      mCurrentImageSmallFilter.setSelected(false);
    }
    mCurrentImageSmallFilter = imageSmallFilter;
    mCurrentImageSmallFilter.setSelected(true);

    ImagePreset copy = new ImagePreset(preset);
    mImageShow.setImagePreset(copy);
    if (preset.isFx()) {
      // if it's an FX we rest the curve adjustment too
      mImageCurves.resetCurve();
    }
    invalidateViews();
  }
  private void fillListImages(LinearLayout listFilters) {
    // TODO: use listview
    // TODO: load the filters straight from the filesystem

    ImageFilterFx[] fxArray = new ImageFilterFx[18];
    int p = 0;

    int[] drawid = {
      R.drawable.filtershow_fx_0005_punch,
      R.drawable.filtershow_fx_0000_vintage,
      R.drawable.filtershow_fx_0004_bw_contrast,
      R.drawable.filtershow_fx_0002_bleach,
      R.drawable.filtershow_fx_0001_instant,
      R.drawable.filtershow_fx_0007_washout,
      R.drawable.filtershow_fx_0003_blue_crush,
      R.drawable.filtershow_fx_0008_washout_color,
      R.drawable.filtershow_fx_0006_x_process
    };

    int[] fxNameid = {
      R.string.ffx_punch,
      R.string.ffx_vintage,
      R.string.ffx_bw_contrast,
      R.string.ffx_bleach,
      R.string.ffx_instant,
      R.string.ffx_washout,
      R.string.ffx_blue_crush,
      R.string.ffx_washout_color,
      R.string.ffx_x_process
    };

    ImagePreset preset = new ImagePreset(getString(R.string.history_original)); // empty
    preset.setImageLoader(mImageLoader);
    mNullFxFilter = new ImageSmallFilter(this);

    mNullFxFilter.setSelected(true);
    mCurrentImageSmallFilter = mNullFxFilter;

    mNullFxFilter.setImageFilter(new ImageFilterFx(null, getString(R.string.none)));

    mNullFxFilter.setController(this);
    mNullFxFilter.setImageLoader(mImageLoader);
    listFilters.addView(mNullFxFilter);
    ImageSmallFilter previousFilter = mNullFxFilter;

    BitmapFactory.Options o = new BitmapFactory.Options();
    o.inScaled = false;

    for (int i = 0; i < drawid.length; i++) {
      Bitmap b = BitmapFactory.decodeResource(getResources(), drawid[i], o);
      fxArray[p++] = new ImageFilterFx(b, getString(fxNameid[i]));
    }
    ImageSmallFilter filter;
    for (int i = 0; i < p; i++) {
      filter = new ImageSmallFilter(this);
      filter.setImageFilter(fxArray[i]);
      filter.setController(this);
      filter.setNulfilter(mNullFxFilter);
      filter.setImageLoader(mImageLoader);
      listFilters.addView(filter);
      previousFilter = filter;
    }

    // Default preset (original)
    mImageShow.setImagePreset(preset);
  }