Android Open Source - android-imgpro-lib Worker






From Project

Back to project page android-imgpro-lib.

License

The source code is released under:

MIT License

If you think the Android project android-imgpro-lib listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package net.akhyar.android.perf;
//www  . jav  a2s.c o  m
import java.io.IOException;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.util.Log;

public abstract class Worker {

  public abstract Bitmap process(Bitmap... bitmap);

  public static class FileDecoder extends Worker {

    private String path;
    private boolean isMutable = false;

    public FileDecoder(String path, boolean isMutable) {
      this.path = path;
      this.isMutable = isMutable;
    }

    public FileDecoder(String path) {
      this.path = path;
    }

    @Override
    public Bitmap process(Bitmap... bitmap) {
      Bitmap result = BitmapFactory.decodeFile(path);
      if (isMutable) {
        Log.i("HAE", "Bitmap copy >.<");
        result = result.copy(Config.ARGB_8888, true);
      }

      return result;
    }

  }

  public static class AssetDecoder extends Worker {

    private Context context;
    private String path;
    private boolean isMutable = false;

    public AssetDecoder(Context context, String path, boolean isMutable) {
      this.context = context;
      this.path = path;
      this.isMutable = isMutable;
    }

    public AssetDecoder(Context context, String path) {
      this.context = context;
      this.path = path;
    }

    @Override
    public Bitmap process(Bitmap... bitmap) {
      Bitmap result = null;
      try {
        result = BitmapFactory.decodeStream(context.getAssets().open(
            path));
      } catch (IOException e) {
        e.printStackTrace();
      }

      // Make mutable as needed
      if (result != null && isMutable) {
        Log.i("HAE", "Bitmap copy >.<");
        result = result.copy(Config.ARGB_8888, true);
      }

      return result;
    }

  }

}




Java Source Code List

net.akhyar.android.imgpro.Action.java
net.akhyar.android.imgpro.Channel.java
net.akhyar.android.imgpro.FilterListener.java
net.akhyar.android.imgpro.FilterTask.java
net.akhyar.android.imgpro.Filter.java
net.akhyar.android.imgpro.ImgPro.java
net.akhyar.android.imgpro.actions.Blend.java
net.akhyar.android.imgpro.actions.Blur.java
net.akhyar.android.imgpro.actions.Brightness.java
net.akhyar.android.imgpro.actions.ChannelMix.java
net.akhyar.android.imgpro.actions.Colorize.java
net.akhyar.android.imgpro.actions.Contrast.java
net.akhyar.android.imgpro.actions.Desaturate.java
net.akhyar.android.imgpro.actions.Invert.java
net.akhyar.android.imgpro.filters.Default.java
net.akhyar.android.imgpro.filters.Vintage.java
net.akhyar.android.imgpro.filters.XProcess.java
net.akhyar.android.perf.BitmapTask.java
net.akhyar.android.perf.SetBitmap.java
net.akhyar.android.perf.SetImageViewBitmapTask.java
net.akhyar.android.perf.Worker.java