イムないあなたが何を意味するか確認してください、私はあなたがやろうとしているものだと思うが、ユーザがあるということですシェイプを入れることができるか、自動的にシェイプを作成します。あなたは、第2のリンク:)
https://examples.javacodegeeks.com/android/core/graphics/canvas-graphics/android-canvas-example/
https://developer.android.com/reference/android/graphics/Canvas.html
void drawOval(float left, float top, float right, float bottom, Paint paint)
か何かこの
などは、以下の異なる形状を設定することができ、このための出発点として、うまくいけば提供されるリンクを使用することができます
public static Bitmap getRoundedShape(Bitmap scaleBitmapImage) {
if (scaleBitmapImage == null) {
return null;
}
int sourceWidth = scaleBitmapImage.getWidth();
int sourceHeight = scaleBitmapImage.getHeight();
int targetWidth = Math.min(sourceWidth, sourceHeight);
int targetHeight = targetWidth;
Bitmap targetBitmap = Bitmap.createBitmap(
targetWidth,
targetHeight,
Bitmap.Config.ARGB_8888
);
Canvas canvas = new Canvas(targetBitmap);
Path path = new Path();
path.addCircle(
((float) targetWidth - 1)/2,
((float) targetHeight - 1)/2,
Math.min(((float) targetWidth), ((float) targetHeight))/2,
Path.Direction.CCW
);
canvas.clipPath(path);
Bitmap sourceBitmap = scaleBitmapImage;
canvas.drawBitmap(
sourceBitmap,
new Rect(0, 0, sourceBitmap.getWidth(),
sourceBitmap.getHeight()),
new Rect(0, 0, targetWidth, targetHeight),
null
);
return targetBitmap;
}
出典:http://www.programcreek.com/java-api-examples/index.php?api=android.graphics.Canvas
そのクラスはAndroid以外のGUIで描画しませんが、 –
@ cricket_007 GUIを描画したくありません。キャンバスを作成しdrawArc drawLineのように描画したい場合は、ビットマップとして保存してください。 – Michal
Graphics2Dはすでにこれを行うことができます。 https://stackoverflow.com/questions/8202253/saving-a-java-2d-graphics-image-as-png-file –