|
|
@ -2,43 +2,87 @@ package com.otaliastudios.cameraview.filters; |
|
|
|
|
|
|
|
|
|
|
|
import android.graphics.Color; |
|
|
|
import android.graphics.Color; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.ColorInt; |
|
|
|
import androidx.annotation.NonNull; |
|
|
|
import androidx.annotation.NonNull; |
|
|
|
|
|
|
|
|
|
|
|
import com.otaliastudios.cameraview.filter.BaseFilter; |
|
|
|
import com.otaliastudios.cameraview.filter.BaseFilter; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Representation of preview using only two color tones. |
|
|
|
* Representation of input frames using only two color tones. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class DuotoneFilter extends BaseFilter { |
|
|
|
public class DuotoneFilter extends BaseFilter { |
|
|
|
|
|
|
|
|
|
|
|
// Default values
|
|
|
|
// Default values
|
|
|
|
private int mFirstColor = Color.MAGENTA; |
|
|
|
private int mFirstColor = Color.MAGENTA; |
|
|
|
private int mSecondColor = Color.YELLOW; |
|
|
|
private int mSecondColor = Color.YELLOW; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("WeakerAccess") |
|
|
|
|
|
|
|
public DuotoneFilter() { } |
|
|
|
|
|
|
|
|
|
|
|
public DuotoneFilter() { |
|
|
|
/** |
|
|
|
|
|
|
|
* Sets the two duotone ARGB colors. |
|
|
|
|
|
|
|
* @param firstColor first |
|
|
|
|
|
|
|
* @param secondColor second |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@SuppressWarnings({"unused", "WeakerAccess"}) |
|
|
|
|
|
|
|
public void setColors(@ColorInt int firstColor, @ColorInt int secondColor) { |
|
|
|
|
|
|
|
setFirstColor(firstColor); |
|
|
|
|
|
|
|
setSecondColor(secondColor); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* setDuotoneColors |
|
|
|
* Sets the first of the duotone ARGB colors. |
|
|
|
|
|
|
|
* Defaults to {@link Color#MAGENTA}. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param firstColor Integer, representing an ARGB color with 8 bits per channel. |
|
|
|
* @param color first color |
|
|
|
* May be created using Color class. |
|
|
|
|
|
|
|
* @param secondColor Integer, representing an ARGB color with 8 bits per channel. |
|
|
|
|
|
|
|
* May be created using Color class. |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setDuotoneColors(int firstColor, int secondColor) { |
|
|
|
@SuppressWarnings("WeakerAccess") |
|
|
|
this.mFirstColor = firstColor; |
|
|
|
public void setFirstColor(@ColorInt int color) { |
|
|
|
this.mSecondColor = secondColor; |
|
|
|
mFirstColor = color; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Sets the second of the duotone ARGB colors. |
|
|
|
|
|
|
|
* Defaults to {@link Color#YELLOW}. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param color second color |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@SuppressWarnings("WeakerAccess") |
|
|
|
|
|
|
|
public void setSecondColor(@ColorInt int color) { |
|
|
|
|
|
|
|
mSecondColor = color; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns the first color. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @see #setFirstColor(int) |
|
|
|
|
|
|
|
* @return first |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@SuppressWarnings("unused") |
|
|
|
|
|
|
|
@ColorInt |
|
|
|
public int getFirstColor() { |
|
|
|
public int getFirstColor() { |
|
|
|
return mFirstColor; |
|
|
|
return mFirstColor; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns the second color. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @see #setSecondColor(int) |
|
|
|
|
|
|
|
* @return second |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@SuppressWarnings("unused") |
|
|
|
|
|
|
|
@ColorInt |
|
|
|
public int getSecondColor() { |
|
|
|
public int getSecondColor() { |
|
|
|
return mSecondColor; |
|
|
|
return mSecondColor; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
protected BaseFilter onCopy() { |
|
|
|
|
|
|
|
DuotoneFilter filter = new DuotoneFilter(); |
|
|
|
|
|
|
|
filter.setColors(mFirstColor, mSecondColor); |
|
|
|
|
|
|
|
return filter; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@NonNull |
|
|
|
@NonNull |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public String getFragmentShader() { |
|
|
|
public String getFragmentShader() { |
|
|
|