<item
android:id="@+id/draw_menu_color"
android:title="@string/draw_color"/>
+ <item
+ android:id="@+id/draw_menu_clear"
+ android:title="@string/draw_clear"/>
</group>
</menu>
\ No newline at end of file
<string name="draw_style_brush_spatter">Marker</string>
<!-- Label for the Spatter brush style of drawing in [CHAR LIMIT=14] -->
<string name="draw_style_brush_marker">Spatter</string>
+ <!-- Label for the removing drawing from screen [CHAR LIMIT=14] -->
+ <string name="draw_clear">Clear</string>
<!-- Label for the select the color [CHAR LIMIT=30] -->
<string name="color_pick_select">Choose custom color</string>
private void setPresetParameters(ImagePreset preset) {
preset.setScaleFactor(mPreviewScaleFactor);
if (mPreviewScaleFactor < 1.0f) {
- preset.setIsHighQuality(false);
+ preset.setQuality(ImagePreset.QUALITY_PREVIEW);
} else {
- preset.setIsHighQuality(true);
+ preset.setQuality(ImagePreset.QUALITY_PREVIEW);
}
}
public void saveImage(ImagePreset preset, final FilterShowActivity filterShowActivity,
File destination) {
- preset.setIsHighQuality(true);
+ preset.setQuality(ImagePreset.QUALITY_FINAL);
preset.setScaleFactor(1.0f);
new SaveCopyTask(mContext, mUri, destination, new SaveCopyTask.Callback() {
public void returnFilteredResult(ImagePreset preset,
final FilterShowActivity filterShowActivity) {
- preset.setIsHighQuality(true);
+ preset.setQuality(ImagePreset.QUALITY_FINAL);
preset.setScaleFactor(1.0f);
BitmapTask.Callbacks<ImagePreset> cb = new BitmapTask.Callbacks<ImagePreset>() {
} else if (item.getItemId() == R.id.draw_menu_style_line) {
ImageDraw idraw = (ImageDraw) mImageShow;
idraw.setStyle(ImageFilterDraw.SIMPLE_STYLE);
+ } else if (item.getItemId() == R.id.draw_menu_clear) {
+ FilterDrawRepresentation drawRep = (FilterDrawRepresentation) getLocalRepresentation();
+ drawRep.clear();
+ commitLocalRepresentation();
}
mView.invalidate();
return true;
package com.android.gallery3d.filtershow.filters;
import android.graphics.Path;
+import android.util.Log;
+
import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.editors.EditorDraw;
public Path mPath;
public float mRadius;
public int mColor;
-
+ public int noPoints = 0;
@Override
public String toString() {
return "stroke(" + mType + ", path(" + (mPath) + "), " + mRadius + " , "
@Override
public String toString() {
return getName() + " : strokes=" + mDrawing.size()
- + ((mCurrent == null) ? " no current " : ("current=" + mCurrent.mType));
+ + ((mCurrent == null) ? " no current "
+ : ("draw=" + mCurrent.mType + " " + mCurrent.noPoints));
}
public Vector<StrokeData> getDrawing() {
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
+ } else {
+ Log.v(LOGTAG, "cannot use parameters from " + a);
}
}
return false;
}
if (representation instanceof FilterDrawRepresentation) {
- // FIXME!
- return true;
+ FilterDrawRepresentation fdRep = (FilterDrawRepresentation) representation;
+ if (fdRep.mDrawing.size() != mDrawing.size())
+ return false;
+ if (fdRep.mCurrent == null && mCurrent.mPath == null) {
+ return true;
+ }
+ if (fdRep.mCurrent != null && mCurrent.mPath != null) {
+ if (fdRep.mCurrent.noPoints == mCurrent.noPoints) {
+ return true;
+ }
+ return false;
+ }
}
return false;
}
mCurrent.mType = type;
mCurrent.mPath = new Path();
mCurrent.mPath.moveTo(x, y);
+ mCurrent.noPoints = 0;
}
public void addPoint(float x, float y) {
+ mCurrent.noPoints++;
mCurrent.mPath.lineTo(x, y);
}
public void endSection(float x, float y) {
mCurrent.mPath.lineTo(x, y);
+ mCurrent.noPoints++;
mDrawing.add(mCurrent);
mCurrent = null;
}
return mName;
}
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
// do nothing here, subclasses will implement filtering here
return bitmap;
}
* Called on small bitmaps to create button icons for each filter.
* Override this to provide filter-specific button icons.
*/
- public Bitmap iconApply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
- return apply(bitmap, scaleFactor, highQuality);
+ public Bitmap iconApply(Bitmap bitmap, float scaleFactor, int quality) {
+ return apply(bitmap, scaleFactor, quality);
}
public ImagePreset getImagePreset() {
}
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
if (getParameters() == null || getParameters().getDrawableResource() == 0) {
return bitmap;
}
}
@Override
- public Bitmap iconApply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap iconApply(Bitmap bitmap, float scaleFactor, int quality) {
if (getParameters() == null || getParameters().getDrawableResource() == 0) {
return bitmap;
}
native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, int r, int g, int b);
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
if (getParameters() == null) {
return bitmap;
}
native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float strength);
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
if (getParameters() == null) {
return bitmap;
}
}
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
if (!mParameters.getSpline(Spline.RGB).isOriginal()) {
int[] rgbGradient = new int[256];
populateArray(rgbGradient, Spline.RGB);
}
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
if (getParameters() == null) {
return bitmap;
}
}
@Override
- public Bitmap iconApply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap iconApply(Bitmap bitmap, float scaleFactor, int quality) {
int w = bitmap.getWidth();
int h = bitmap.getHeight();
Bitmap ret = Bitmap.createScaledBitmap(bitmap, w / ICON_DOWNSAMPLE_FRACTION, h
import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.filters.FilterDrawRepresentation.StrokeData;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
+import com.android.gallery3d.filtershow.presets.ImagePreset;
import java.util.Vector;
public static interface DrawStyle {
public void setType(byte type);
public void paint(FilterDrawRepresentation.StrokeData sd, Canvas canvas, Matrix toScrMatrix,
- boolean highQuality);
+ int quality);
}
class SimpleDraw implements DrawStyle {
@Override
public void paint(FilterDrawRepresentation.StrokeData sd, Canvas canvas, Matrix toScrMatrix,
- boolean highQuality) {
+ int quality) {
if (sd == null) {
return;
}
@Override
public void paint(FilterDrawRepresentation.StrokeData sd, Canvas canvas, Matrix toScrMatrix,
- boolean highQuality) {
+ int quality) {
if (sd == null || sd.mPath == null) {
return;
}
}
void paint(FilterDrawRepresentation.StrokeData sd, Canvas canvas, Matrix toScrMatrix,
- boolean highQuality) {
- mDrawingsTypes[sd.mType].paint(sd, canvas, toScrMatrix, highQuality);
+ int quality) {
+ mDrawingsTypes[sd.mType].paint(sd, canvas, toScrMatrix, quality);
}
- public void drawData(Canvas canvas, Matrix originalRotateToScreen, boolean highQuality) {
+ public void drawData(Canvas canvas, Matrix originalRotateToScreen, int quality) {
Paint paint = new Paint();
- if (highQuality) {
+ if (quality == ImagePreset.QUALITY_FINAL) {
paint.setAntiAlias(true);
}
paint.setStyle(Style.STROKE);
if (mParameters.getDrawing().isEmpty() && mParameters.getCurrentDrawing() == null) {
return;
}
- if (highQuality) {
+ if (quality == ImagePreset.QUALITY_FINAL) {
for (FilterDrawRepresentation.StrokeData strokeData : mParameters.getDrawing()) {
- paint(strokeData, canvas, originalRotateToScreen, highQuality);
+ paint(strokeData, canvas, originalRotateToScreen, quality);
}
return;
}
StrokeData stroke = mParameters.getCurrentDrawing();
if (stroke != null) {
- paint(stroke, canvas, originalRotateToScreen, highQuality);
+ paint(stroke, canvas, originalRotateToScreen, quality);
}
}
int n = v.size();
for (int i = mCachedStrokes; i < n; i++) {
- paint(v.get(i), drawCache, originalRotateToScreen, false);
+ paint(v.get(i), drawCache, originalRotateToScreen, ImagePreset.QUALITY_PREVIEW);
}
mCachedStrokes = n;
}
public void draw(Canvas canvas, Matrix originalRotateToScreen) {
for (FilterDrawRepresentation.StrokeData strokeData : mParameters.getDrawing()) {
- paint(strokeData, canvas, originalRotateToScreen, false);
+ paint(strokeData, canvas, originalRotateToScreen, ImagePreset.QUALITY_PREVIEW);
}
- mDrawingsTypes[mCurrentStyle].paint(null, canvas, originalRotateToScreen, false);
+ mDrawingsTypes[mCurrentStyle].paint(
+ null, canvas, originalRotateToScreen, ImagePreset.QUALITY_PREVIEW);
}
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
int w = bitmap.getWidth();
int h = bitmap.getHeight();
short[] rect = new short[4];
Matrix m = new Matrix();
m.setScale(scaleFactor, scaleFactor);
- drawData(new Canvas(bitmap), m, highQuality);
+ drawData(new Canvas(bitmap), m, quality);
return bitmap;
native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float p);
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
if (getParameters() == null) {
return bitmap;
}
native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float bright);
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
if (getParameters() == null) {
return bitmap;
}
native protected void nativeApplyFilter(Bitmap bitmap, int w, int h,Bitmap fxBitmap, int fxw, int fxh);
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
if (getParameters() == null || getParameters().getFxBitmap() ==null) {
return bitmap;
}
Bitmap dst, int dstWidth, int dstHeight, float straightenAngle);
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
// TODO: implement bilinear or bicubic here... for now, just use
// canvas to do a simple implementation...
// TODO: and be more memory efficient! (do it in native?)
native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float []matrix);
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
if (getParameters() == null) {
return bitmap;
}
int swidth, int sheight, int p, int seed);
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
if (getParameters() == null) {
return bitmap;
}
native protected void nativeApplyFilter(Bitmap bitmap, int w, int h);
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
int w = bitmap.getWidth();
int h = bitmap.getHeight();
nativeApplyFilter(bitmap, w, h);
}
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
Canvas canvas = new Canvas(bitmap);
applyHelper(canvas, bitmap.getWidth(), bitmap.getHeight());
return bitmap;
}
@Override
- public Bitmap iconApply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap iconApply(Bitmap bitmap, float scaleFactor, int quality) {
Canvas canvas = new Canvas(bitmap);
applyHelper(canvas, bitmap.getWidth() * 4, bitmap.getHeight() * 4);
return bitmap;
mOldBitmap = null;
}
- public void prepare(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public void prepare(Bitmap bitmap, float scaleFactor, int quality) {
if (sOldBitmap == null
|| (bitmap.getWidth() != sOldBitmap.getWidth())
|| (bitmap.getHeight() != sOldBitmap.getHeight())) {
}
mInPixelsAllocation.copyFrom(bitmap);
if (mOldBitmap != sOldBitmap) {
- createFilter(mResources, scaleFactor, highQuality);
+ createFilter(mResources, scaleFactor, quality);
mOldBitmap = sOldBitmap;
}
}
public void createFilter(android.content.res.Resources res,
- float scaleFactor, boolean highQuality) {
+ float scaleFactor, int quality) {
// Stub
}
}
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
if (bitmap == null) {
return bitmap;
}
try {
- prepare(bitmap, scaleFactor, highQuality);
+ prepare(bitmap, scaleFactor, quality);
runFilter();
update(bitmap);
} catch (android.renderscript.RSIllegalArgumentException e) {
native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, short[] matrix);
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
int w = bitmap.getWidth();
int h = bitmap.getHeight();
short[] rect = new short[4];
native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float saturation);
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
if (getParameters() == null) {
return bitmap;
}
native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float factor);
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
if (getParameters() == null) {
return bitmap;
}
@Override
public void createFilter(android.content.res.Resources res, float scaleFactor,
- boolean highQuality) {
+ int quality) {
int w = mInPixelsAllocation.getType().getX();
int h = mInPixelsAllocation.getType().getY();
mScaleFactor = scaleFactor;
}
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
// TODO: implement bilinear or bicubic here... for now, just use
// canvas to do a simple implementation...
// TODO: and be more memory efficient! (do it in native?)
float angle);
@Override
- public Bitmap apply(Bitmap bitmapIn, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmapIn, float scaleFactor, int quality) {
int w = bitmapIn.getWidth();
int h = bitmapIn.getHeight();
int outputSize = (int) (w / 2f);
native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float bright);
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
if (getParameters() == null) {
return bitmap;
}
native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float strength);
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
if (getParameters() == null) {
return bitmap;
}
native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, int locX, int locY);
@Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
int w = bitmap.getWidth();
int h = bitmap.getHeight();
nativeApplyFilter(bitmap, w, h, -1, -1);
}
@Override
- public Bitmap iconApply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ public Bitmap iconApply(Bitmap bitmap, float scaleFactor, int quality) {
FilterRepresentation representation = getDefaultRepresentation();
this.useRepresentation(representation);
- return apply(bitmap, scaleFactor, highQuality);
+ return apply(bitmap, scaleFactor, quality);
}
}
return false;
}
- public Bitmap apply(Bitmap original, float scaleFactor, boolean highQuality) {
+ public Bitmap apply(Bitmap original, float scaleFactor, int quality) {
if (!hasModifications()) {
return original;
}
mImageFilter.setGeometryMetadata(this);
- Bitmap m = mImageFilter.apply(original, scaleFactor, highQuality);
+ Bitmap m = mImageFilter.apply(original, scaleFactor, quality);
return m;
}
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
-import android.graphics.Rect;
-import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
ImageFilterDraw filter = (ImageFilterDraw) getCurrentFilter();
if (event.getAction() == MotionEvent.ACTION_DOWN) {
-
mTmpPoint[0] = event.getX();
mTmpPoint[1] = event.getY();
mToOrig.mapPoints(mTmpPoint);
mTmpPoint[1] = event.getY();
mToOrig.mapPoints(mTmpPoint);
mFRep.endSection(mTmpPoint[0], mTmpPoint[1]);
- this.resetImageCaches(this);
-
}
mEditorDraw.commitLocalRepresentation();
invalidate();
private FilterRepresentation mBorder = null;
private float mScaleFactor = 1.0f;
- private boolean mIsHighQuality = false;
+ public static final int QUALITY_ICON = 0;
+ public static final int QUALITY_PREVIEW = 1;
+ public static final int QUALITY_FINAL = 2;
+ private int mQuality = QUALITY_PREVIEW;
private ImageLoader mImageLoader = null;
private Vector<FilterRepresentation> mFilters = new Vector<FilterRepresentation>();
public Bitmap applyGeometry(Bitmap bitmap) {
// Apply any transform -- 90 rotate, flip, straighten, crop
// Returns a new bitmap.
- return mGeoData.apply(bitmap, mScaleFactor, mIsHighQuality);
+ return mGeoData.apply(bitmap, mScaleFactor, mQuality);
}
public Bitmap applyBorder(Bitmap bitmap) {
if (mBorder != null && mDoApplyGeometry) {
ImageFilter filter = FiltersManager.getManager().getFilterForRepresentation(mBorder);
filter.useRepresentation(mBorder);
- bitmap = filter.apply(bitmap, mScaleFactor, mIsHighQuality);
+ bitmap = filter.apply(bitmap, mScaleFactor, mQuality);
}
return bitmap;
}
}
ImageFilter filter = FiltersManager.getManager().getFilterForRepresentation(representation);
filter.useRepresentation(representation);
- bitmap = filter.apply(bitmap, mScaleFactor, mIsHighQuality);
+ bitmap = filter.apply(bitmap, mScaleFactor, mQuality);
}
}
return mScaleFactor;
}
- public boolean isHighQuality() {
- return mIsHighQuality;
+ public int getQuality() {
+ return mQuality;
}
- public void setIsHighQuality(boolean value) {
- mIsHighQuality = value;
+ public void setQuality(int value) {
+ mQuality = value;
}
public void setScaleFactor(float value) {