<dimen name="gradcontrol_dot_size">20dip</dimen>
<!-- Grad filter minimum touch distance -->
- <dimen name="gradcontrol_min_touch_dist">40dip</dimen>
+ <dimen name="gradcontrol_min_touch_dist">80dip</dimen>
</resources>
\ No newline at end of file
super("Grad");
setSerializationName(SERIALIZATION_NAME);
creatExample();
- setOverlayId(R.drawable.filtershow_button_colors_vignette);
+ setOverlayId(R.drawable.filtershow_button_grad);
setFilterClass(ImageFilterGrad.class);
setTextId(R.string.grad);
setEditorId(EditorGrad.ID);
static class Band {
private boolean mask = true;
- private boolean active = true;
+
private int xPos1 = -1;
private int yPos1 = 100;
private int xPos2 = -1;
private int brightness = 40;
private int contrast = 0;
private int saturation = 0;
- private boolean inking;
+
public Band() {
}
public Band(Band copy) {
mask = copy.mask;
- active = copy.active;
xPos1 = copy.xPos1;
yPos1 = copy.yPos1;
xPos2 = copy.xPos2;
brightness = copy.brightness;
contrast = copy.contrast;
saturation = copy.saturation;
- inking = copy.inking;
}
}
private void creatExample() {
Band p = new Band();
p.mask = false;
- p.active = true;
p.xPos1 = -1;
p.yPos1 = 100;
p.xPos2 = -1;
p.brightness = 40;
p.contrast = 0;
p.saturation = 0;
- p.inking = false;
mBands.add(0, p);
mCurrentBand = p;
trimVector();
@Override
public boolean equals(FilterRepresentation representation) {
if (representation instanceof FilterGradRepresentation) {
- return true; // TODO much more extensive equals needed
+ FilterGradRepresentation rep = (FilterGradRepresentation) representation;
+ int n = getNumberOfBands();
+ if (rep.getNumberOfBands() != n) {
+ return false;
+ }
+ for (int i = 0; i < mBands.size(); i++) {
+ Band b1 = mBands.get(i);
+ Band b2 = rep.mBands.get(i);
+ if (b1.mask != b2.mask
+ || b1.brightness != b2.brightness
+ || b1.contrast != b2.contrast
+ || b1.saturation != b2.saturation
+ || b1.xPos1 != b2.xPos1
+ || b1.xPos2 != b2.xPos2
+ || b1.yPos1 != b2.yPos1
+ || b1.yPos2 != b2.yPos2) {
+ return false;
+ }
+ }
+ return true;
}
return false;
}
return count;
}
- public void toggleInking() {
- mCurrentBand.inking = !mCurrentBand.inking;
- }
-
- public void setInking(boolean on) {
- for (Band point : mBands) {
- point.inking = false;
- }
- mCurrentBand.inking = on;
- }
-
public int addBand(Rect rect) {
mBands.add(0, mCurrentBand = new Band(rect.centerX(), rect.centerY()));
mCurrentBand.mask = false;
return ret;
}
- public boolean[] getActive() {
- boolean[] ret = new boolean[mBands.size()];
- int i = 0;
- String s = "";
- for (Band point : mBands) {
- ret[i++] = point.active;
- s += (point.active) ? "1" : "0";
- }
- return ret;
- }
-
public int[] getXPos1() {
int[] ret = new int[mBands.size()];
int i = 0;
return ret;
}
- public boolean[] getInking() {
- boolean[] ret = new boolean[mBands.size()];
- int i = 0;
- for (Band point : mBands) {
- ret[i++] = point.inking;
- }
- return ret;
- }
-
public int getParameter(int type) {
switch (type){
case PARAM_BRIGHTNESS:
mScript.set_inputHeight(height);
}
- private boolean hasInk() {
- boolean[] ink = mParameters.getInking();
- for (int i = 0; i < ink.length; i++) {
- if (ink[i])
- return true;
- }
- return false;
- }
-
@Override
protected void runFilter() {
int[] x1 = mParameters.getXPos1();
}
mScript.set_mask(mParameters.getMask());
- mScript.set_active(mParameters.getActive());
mScript.set_xPos1(x1);
mScript.set_yPos1(y1);
mScript.set_xPos2(x2);
mScript.set_brightness(mParameters.getBrightness());
mScript.set_contrast(mParameters.getContrast());
mScript.set_saturation(mParameters.getSaturation());
- mScript.set_inking(mParameters.getInking());
mScript.invoke_setupGradParams();
runSelectiveAdjust(
//static const float size_scale = 0.01f;
typedef struct {
- bool active;
- bool inking;
rs_matrix3x3 colorMatrix;
float rgbOff;
float dx;
int mNumberOfLines;
// input data
bool mask[MAX_POINTS];
-bool active[MAX_POINTS];
int xPos1[MAX_POINTS];
int yPos1[MAX_POINTS];
int xPos2[MAX_POINTS];
int brightness[MAX_POINTS];
int contrast[MAX_POINTS];
int saturation[MAX_POINTS];
-bool inking[MAX_POINTS];
-
// generated data
static UPointData grads[MAX_POINTS];
void setupGradParams() {
int k = 0;
for (int i = 0; i < MAX_POINTS; i++) {
- grads[i].active = false;
if (!mask[i]) {
continue;
}
float denom = (y2 * y2 - 2 * y1 * y2 + x2 * x2 - 2 * x1 * x2 + y1 * y1 + x1 * x1);
if (denom == 0) {
- grads[i].active = false;
continue;
}
grads[k].dy = (y1 - y2) / denom;
rsMatrixSet(&grads[i].colorMatrix, 1, 2, b * Gt);
rsMatrixSet(&grads[i].colorMatrix, 2, 2, b * (Bt + S));
-
- grads[k].active = true;
- grads[k].inking = inking[i];
k++;
}
mNumberOfLines = k;
private static final String LOGTAG = "ImageGrad";
private FilterGradRepresentation mGradRep;
private EditorGrad mEditorGrad;
- private int mMinTouchDist;
+ private float mMinTouchDist;
private int mActiveHandle = -1;
private GradControl mEllipse;
public ImageGrad(Context context, AttributeSet attrs) {
super(context, attrs);
+ Resources res = context.getResources();
+ mMinTouchDist = res.getDimensionPixelSize(R.dimen.gradcontrol_min_touch_dist);
mEllipse = new GradControl(context);
mEllipse.setShowReshapeHandles(false);
}
public boolean onTouchEvent(MotionEvent event) {
int mask = event.getActionMasked();
- if (mask == MotionEvent.ACTION_DOWN || mask == MotionEvent.ACTION_UP) {
- mGradRep.setInking(MotionEvent.ACTION_DOWN == mask);
- }
-
if (mActiveHandle == -1) {
if (MotionEvent.ACTION_DOWN != mask) {
return super.onTouchEvent(event);
if (pos != -1) {
mGradRep.setSelectedPoint(pos);
- mGradRep.setInking(true);
resetImageCaches(this);
mEditorGrad.updateSeekBar(mGradRep);
mEditorGrad.commitLocalRepresentation();