Loading core/java/android/gesture/Gesture.java +19 −10 Original line number Diff line number Diff line Loading @@ -216,16 +216,15 @@ public class Gesture implements Parcelable { * * @param width * @param height * @param edge * @param inset * @param color * @return the bitmap */ public Bitmap toBitmap(int width, int height, int edge, int color) { final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); public Bitmap toBitmap(int width, int height, int inset, int color) { final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(bitmap); canvas.translate(edge, edge); final Paint paint = new Paint(); paint.setAntiAlias(BITMAP_RENDERING_ANTIALIAS); paint.setDither(BITMAP_RENDERING_DITHER); Loading @@ -235,12 +234,22 @@ public class Gesture implements Parcelable { paint.setStrokeCap(Paint.Cap.ROUND); paint.setStrokeWidth(BITMAP_RENDERING_WIDTH); final ArrayList<GestureStroke> strokes = mStrokes; final int count = strokes.size(); final Path path = toPath(); final RectF bounds = new RectF(); path.computeBounds(bounds, true); for (int i = 0; i < count; i++) { strokes.get(i).draw(canvas, paint); } final float sx = (width - 2 * inset) / bounds.width(); final float sy = (height - 2 * inset) / bounds.height(); final float scale = sx > sy ? sy : sx; paint.setStrokeWidth(2.0f / scale); path.offset(-bounds.left + (width - bounds.width() * scale) / 2.0f, -bounds.top + (height - bounds.height() * scale) / 2.0f); canvas.translate(inset, inset); canvas.scale(scale, scale); canvas.drawPath(path, paint); return bitmap; } Loading core/java/android/gesture/GestureOverlayView.java +1 −0 Original line number Diff line number Diff line Loading @@ -294,6 +294,7 @@ public class GestureOverlayView extends FrameLayout { final RectF bounds = new RectF(); path.computeBounds(bounds, true); // TODO: The path should also be scaled to fit inside this view mPath.rewind(); mPath.addPath(path, -bounds.left + (getWidth() - bounds.width()) / 2.0f, -bounds.top + (getHeight() - bounds.height()) / 2.0f); Loading core/jni/android_hardware_Camera.cpp +6 −8 Original line number Diff line number Diff line Loading @@ -115,15 +115,13 @@ static void android_hardware_Camera_native_setup(JNIEnv *env, jobject thiz, jobj // make sure camera hardware is alive if (camera->getStatus() != NO_ERROR) { jniThrowException(env, "java/io/IOException", "Camera initialization failed"); jniThrowException(env, "java/lang/RuntimeException", "Camera initialization failed"); return; } jclass clazz = env->GetObjectClass(thiz); if (clazz == NULL) { LOGE("Can't find android/hardware/Camera"); // XXX no idea what to throw here, can this even happen? jniThrowException(env, "java/lang/Exception", NULL); jniThrowException(env, "java/lang/RuntimeException", "Can't find android/hardware/Camera"); return; } Loading Loading @@ -241,7 +239,7 @@ static void android_hardware_Camera_startPreview(JNIEnv *env, jobject thiz) if (camera == 0) return; if (camera->startPreview() != NO_ERROR) { jniThrowException(env, "java/io/IOException", "startPreview failed"); jniThrowException(env, "java/lang/RuntimeException", "startPreview failed"); return; } } Loading Loading @@ -305,7 +303,7 @@ static void android_hardware_Camera_autoFocus(JNIEnv *env, jobject thiz) c->setAutoFocusCallback(autofocus_callback_impl, context); if (c->autoFocus() != NO_ERROR) { jniThrowException(env, "java/io/IOException", "autoFocus failed"); jniThrowException(env, "java/lang/RuntimeException", "autoFocus failed"); } } Loading Loading @@ -398,7 +396,7 @@ static void android_hardware_Camera_takePicture(JNIEnv *env, jobject thiz) camera->setRawCallback(raw_callback, context); camera->setJpegCallback(jpeg_callback, context); if (camera->takePicture() != NO_ERROR) { jniThrowException(env, "java/io/IOException", "takePicture failed"); jniThrowException(env, "java/lang/RuntimeException", "takePicture failed"); return; } Loading @@ -418,7 +416,7 @@ static void android_hardware_Camera_setParameters(JNIEnv *env, jobject thiz, jst env->ReleaseStringCritical(params, str); } if (camera->setParameters(params8) != NO_ERROR) { jniThrowException(env, "java/lang/IllegalArgumentException", "setParameters failed"); jniThrowException(env, "java/lang/RuntimeException", "setParameters failed"); return; } } Loading Loading
core/java/android/gesture/Gesture.java +19 −10 Original line number Diff line number Diff line Loading @@ -216,16 +216,15 @@ public class Gesture implements Parcelable { * * @param width * @param height * @param edge * @param inset * @param color * @return the bitmap */ public Bitmap toBitmap(int width, int height, int edge, int color) { final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); public Bitmap toBitmap(int width, int height, int inset, int color) { final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(bitmap); canvas.translate(edge, edge); final Paint paint = new Paint(); paint.setAntiAlias(BITMAP_RENDERING_ANTIALIAS); paint.setDither(BITMAP_RENDERING_DITHER); Loading @@ -235,12 +234,22 @@ public class Gesture implements Parcelable { paint.setStrokeCap(Paint.Cap.ROUND); paint.setStrokeWidth(BITMAP_RENDERING_WIDTH); final ArrayList<GestureStroke> strokes = mStrokes; final int count = strokes.size(); final Path path = toPath(); final RectF bounds = new RectF(); path.computeBounds(bounds, true); for (int i = 0; i < count; i++) { strokes.get(i).draw(canvas, paint); } final float sx = (width - 2 * inset) / bounds.width(); final float sy = (height - 2 * inset) / bounds.height(); final float scale = sx > sy ? sy : sx; paint.setStrokeWidth(2.0f / scale); path.offset(-bounds.left + (width - bounds.width() * scale) / 2.0f, -bounds.top + (height - bounds.height() * scale) / 2.0f); canvas.translate(inset, inset); canvas.scale(scale, scale); canvas.drawPath(path, paint); return bitmap; } Loading
core/java/android/gesture/GestureOverlayView.java +1 −0 Original line number Diff line number Diff line Loading @@ -294,6 +294,7 @@ public class GestureOverlayView extends FrameLayout { final RectF bounds = new RectF(); path.computeBounds(bounds, true); // TODO: The path should also be scaled to fit inside this view mPath.rewind(); mPath.addPath(path, -bounds.left + (getWidth() - bounds.width()) / 2.0f, -bounds.top + (getHeight() - bounds.height()) / 2.0f); Loading
core/jni/android_hardware_Camera.cpp +6 −8 Original line number Diff line number Diff line Loading @@ -115,15 +115,13 @@ static void android_hardware_Camera_native_setup(JNIEnv *env, jobject thiz, jobj // make sure camera hardware is alive if (camera->getStatus() != NO_ERROR) { jniThrowException(env, "java/io/IOException", "Camera initialization failed"); jniThrowException(env, "java/lang/RuntimeException", "Camera initialization failed"); return; } jclass clazz = env->GetObjectClass(thiz); if (clazz == NULL) { LOGE("Can't find android/hardware/Camera"); // XXX no idea what to throw here, can this even happen? jniThrowException(env, "java/lang/Exception", NULL); jniThrowException(env, "java/lang/RuntimeException", "Can't find android/hardware/Camera"); return; } Loading Loading @@ -241,7 +239,7 @@ static void android_hardware_Camera_startPreview(JNIEnv *env, jobject thiz) if (camera == 0) return; if (camera->startPreview() != NO_ERROR) { jniThrowException(env, "java/io/IOException", "startPreview failed"); jniThrowException(env, "java/lang/RuntimeException", "startPreview failed"); return; } } Loading Loading @@ -305,7 +303,7 @@ static void android_hardware_Camera_autoFocus(JNIEnv *env, jobject thiz) c->setAutoFocusCallback(autofocus_callback_impl, context); if (c->autoFocus() != NO_ERROR) { jniThrowException(env, "java/io/IOException", "autoFocus failed"); jniThrowException(env, "java/lang/RuntimeException", "autoFocus failed"); } } Loading Loading @@ -398,7 +396,7 @@ static void android_hardware_Camera_takePicture(JNIEnv *env, jobject thiz) camera->setRawCallback(raw_callback, context); camera->setJpegCallback(jpeg_callback, context); if (camera->takePicture() != NO_ERROR) { jniThrowException(env, "java/io/IOException", "takePicture failed"); jniThrowException(env, "java/lang/RuntimeException", "takePicture failed"); return; } Loading @@ -418,7 +416,7 @@ static void android_hardware_Camera_setParameters(JNIEnv *env, jobject thiz, jst env->ReleaseStringCritical(params, str); } if (camera->setParameters(params8) != NO_ERROR) { jniThrowException(env, "java/lang/IllegalArgumentException", "setParameters failed"); jniThrowException(env, "java/lang/RuntimeException", "setParameters failed"); return; } } Loading