summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/drawable-nodpi/brush1.pngbin8861 -> 0 bytes
-rw-r--r--res/drawable-nodpi/brush_marker.pngbin0 -> 19953 bytes
-rw-r--r--res/drawable-nodpi/brush_spatter.png (renamed from res/drawable-nodpi/brush2.png)bin16366 -> 16366 bytes
-rw-r--r--res/menu/filtershow_menu_draw.xml7
-rw-r--r--res/values/filtershow_strings.xml6
-rw-r--r--src/com/android/gallery3d/filtershow/editors/EditorDraw.java9
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java51
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageDraw.java3
8 files changed, 50 insertions, 26 deletions
diff --git a/res/drawable-nodpi/brush1.png b/res/drawable-nodpi/brush1.png
deleted file mode 100644
index 6030f25de..000000000
--- a/res/drawable-nodpi/brush1.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-nodpi/brush_marker.png b/res/drawable-nodpi/brush_marker.png
new file mode 100644
index 000000000..24eb7476c
--- /dev/null
+++ b/res/drawable-nodpi/brush_marker.png
Binary files differ
diff --git a/res/drawable-nodpi/brush2.png b/res/drawable-nodpi/brush_spatter.png
index ae15c221c..ae15c221c 100644
--- a/res/drawable-nodpi/brush2.png
+++ b/res/drawable-nodpi/brush_spatter.png
Binary files differ
diff --git a/res/menu/filtershow_menu_draw.xml b/res/menu/filtershow_menu_draw.xml
index be6dc7058..9455f70a7 100644
--- a/res/menu/filtershow_menu_draw.xml
+++ b/res/menu/filtershow_menu_draw.xml
@@ -22,8 +22,11 @@
android:id="@+id/draw_menu_style_line"
android:title="@string/draw_style_line" />
<item
- android:id="@+id/draw_menu_style_brush"
- android:title="@string/draw_style_brush" />
+ android:id="@+id/draw_menu_style_brush_marker"
+ android:title="@string/draw_style_brush_marker"/>
+ <item
+ android:id="@+id/draw_menu_style_brush_spatter"
+ android:title="@string/draw_style_brush_spatter"/>
<item
android:id="@+id/draw_menu_size"
android:title="@string/draw_size" />
diff --git a/res/values/filtershow_strings.xml b/res/values/filtershow_strings.xml
index 92cc06a0f..cf6e80d68 100644
--- a/res/values/filtershow_strings.xml
+++ b/res/values/filtershow_strings.xml
@@ -162,8 +162,10 @@
<string name="draw_color">Color</string>
<!-- Label for the line style of drawing in [CHAR LIMIT=14] -->
<string name="draw_style_line">Lines</string>
- <!-- Label for the brush style of drawing in [CHAR LIMIT=14] -->
- <string name="draw_style_brush">Brush</string>
+ <!-- Label for the Marker brush style of drawing in [CHAR LIMIT=14] -->
+ <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 select the color [CHAR LIMIT=30] -->
<string name="color_pick_select">Choose custom color</string>
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorDraw.java b/src/com/android/gallery3d/filtershow/editors/EditorDraw.java
index ff4018501..128af8ec7 100644
--- a/src/com/android/gallery3d/filtershow/editors/EditorDraw.java
+++ b/src/com/android/gallery3d/filtershow/editors/EditorDraw.java
@@ -111,11 +111,12 @@ public class EditorDraw extends Editor {
showColorGrid(item);
} else if (item.getItemId() == R.id.draw_menu_size) {
showSizeDialog(item);
- } else if (item.getItemId() == R.id.draw_menu_style_brush) {
+ } else if (item.getItemId() == R.id.draw_menu_style_brush_marker) {
ImageDraw idraw = (ImageDraw) mImageShow;
- idraw.setStyle((byte) (idraw.getStyle() + 1));
- item.setIcon(idraw.getIcon(mContext));
- popupMenu.show();
+ idraw.setStyle(ImageFilterDraw.BRUSH_STYLE_MARKER);
+ } else if (item.getItemId() == R.id.draw_menu_style_brush_spatter) {
+ ImageDraw idraw = (ImageDraw) mImageShow;
+ idraw.setStyle(ImageFilterDraw.BRUSH_STYLE_SPATTER);
} else if (item.getItemId() == R.id.draw_menu_style_line) {
ImageDraw idraw = (ImageDraw) mImageShow;
idraw.setStyle(ImageFilterDraw.SIMPLE_STYLE);
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java
index ed02c1de4..d2b5507a1 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java
@@ -16,7 +16,6 @@
package com.android.gallery3d.filtershow.filters;
-import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
@@ -28,10 +27,9 @@ import android.graphics.Path;
import android.graphics.PathMeasure;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
+import android.util.Log;
import com.android.gallery3d.R;
-import com.android.gallery3d.filtershow.FilterShowActivity;
-import com.android.gallery3d.filtershow.editors.EditorDraw;
import com.android.gallery3d.filtershow.filters.FilterDrawRepresentation.StrokeData;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
@@ -40,7 +38,8 @@ import java.util.Vector;
public class ImageFilterDraw extends ImageFilter {
private static final String LOGTAG = "ImageFilterDraw";
public final static byte SIMPLE_STYLE = 0;
- public final static byte BRUSH_STYLE = 1;
+ public final static byte BRUSH_STYLE_SPATTER = 1;
+ public final static byte BRUSH_STYLE_MARKER = 2;
public final static int NUMBER_OF_STYLES = 3;
Bitmap mOverlayBitmap; // this accelerates interaction
int mCachedStrokes = -1;
@@ -53,7 +52,10 @@ public class ImageFilterDraw extends ImageFilter {
}
DrawStyle[] mDrawingsTypes = new DrawStyle[] {
- new SimpleDraw(), new Brush(R.drawable.brush1), new Brush(R.drawable.brush2) };
+ new SimpleDraw(),
+ new Brush(R.drawable.brush_marker),
+ new Brush(R.drawable.brush_spatter)
+ };
{
for (int i = 0; i < mDrawingsTypes.length; i++) {
mDrawingsTypes[i].setType((byte) i);
@@ -109,7 +111,7 @@ public class ImageFilterDraw extends ImageFilter {
paint.setColor(sd.mColor);
paint.setStrokeWidth(toScrMatrix.mapRadius(sd.mRadius));
- // don this way because of a bug in path.transform(matrix)
+ // done this way because of a bug in path.transform(matrix)
Path mCacheTransPath = new Path();
mCacheTransPath.addPath(sd.mPath, toScrMatrix);
@@ -118,7 +120,7 @@ public class ImageFilterDraw extends ImageFilter {
}
class Brush implements DrawStyle {
- int mBrushID = R.drawable.brush2;
+ int mBrushID;
Bitmap mBrush;
byte mType;
@@ -138,23 +140,32 @@ public class ImageFilterDraw extends ImageFilter {
@Override
public void paint(FilterDrawRepresentation.StrokeData sd, Canvas canvas, Matrix toScrMatrix,
boolean highQuality) {
- if (sd == null) {
- return;
- }
-
if (sd == null || sd.mPath == null) {
return;
}
Paint paint = new Paint();
paint.setStyle(Style.STROKE);
-
- float scale = toScrMatrix.mapRadius(1);
+ paint.setAntiAlias(true);
Path mCacheTransPath = new Path();
mCacheTransPath.addPath(sd.mPath, toScrMatrix);
- draw(canvas, paint, sd.mColor, toScrMatrix.mapRadius(sd.mRadius),
+ draw(canvas, paint, sd.mColor, toScrMatrix.mapRadius(sd.mRadius) * 2,
mCacheTransPath);
}
+ public Bitmap createScaledBitmap(Bitmap src, int dstWidth, int dstHeight, boolean filter)
+ {
+ Matrix m = new Matrix();
+ m.setScale(dstWidth / (float) src.getWidth(), dstHeight / (float) src.getHeight());
+ Bitmap result = Bitmap.createBitmap(dstWidth, dstHeight, src.getConfig());
+ Canvas canvas = new Canvas(result);
+
+ Paint paint = new Paint();
+ paint.setFilterBitmap(filter);
+ canvas.drawBitmap(src, m, paint);
+
+ return result;
+
+ }
void draw(Canvas canvas, Paint paint, int color, float size, Path path) {
PathMeasure mPathMeasure = new PathMeasure();
float[] mPosition = new float[2];
@@ -164,11 +175,15 @@ public class ImageFilterDraw extends ImageFilter {
paint.setAntiAlias(true);
paint.setColor(color);
+
paint.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
- Bitmap brush = Bitmap.createScaledBitmap(getBrush(), (int) size, (int) size, true);
+ Bitmap brush;
+ // done this way because of a bug in
+ // Bitmap.createScaledBitmap(getBrush(),(int) size,(int) size,true);
+ brush = createScaledBitmap(getBrush(), (int) size, (int) size, true);
float len = mPathMeasure.getLength();
float s2 = size / 2;
- float step = s2 / 6;
+ float step = s2 / 8;
for (float i = 0; i < len; i += step) {
mPathMeasure.getPosTan(i, mPosition, mTan);
// canvas.drawCircle(pos[0], pos[1], size, paint);
@@ -196,7 +211,7 @@ public class ImageFilterDraw extends ImageFilter {
paint.setColor(Color.RED);
paint.setStrokeWidth(40);
- if (mParameters.getDrawing().isEmpty()) {
+ if (mParameters.getDrawing().isEmpty() && mParameters.getCurrentDrawing() == null) {
return;
}
if (highQuality) {
@@ -252,9 +267,9 @@ public class ImageFilterDraw extends ImageFilter {
Matrix m = new Matrix();
m.setScale(scaleFactor, scaleFactor);
-
drawData(new Canvas(bitmap), m, highQuality);
+
return bitmap;
}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageDraw.java b/src/com/android/gallery3d/filtershow/imageshow/ImageDraw.java
index 65ccf1f7a..2dc0221e4 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageDraw.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageDraw.java
@@ -5,8 +5,11 @@ import android.content.Context;
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;
import android.view.MotionEvent;
import com.android.gallery3d.filtershow.editors.EditorDraw;