本文整理汇总了Java中android.graphics.drawable.shapes.PathShape.resize方法的典型用法代码示例。如果您正苦于以下问题:Java PathShape.resize方法的具体用法?Java PathShape.resize怎么用?Java PathShape.resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.drawable.shapes.PathShape
的用法示例。
在下文中一共展示了PathShape.resize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSignatureBitmap
import android.graphics.drawable.shapes.PathShape; //导入方法依赖的package包/类
/**
* 1. Iterating over the path points, saving them in an array ... not bueno. Try to use
* {@link android.graphics.PathMeasure} class and get minX and minY from that.
* <p>
* 2. Scale bitmap down. Currently drawing at density of device.
*/
public Bitmap createSignatureBitmap() {
Paint bitmapSigPaint = new Paint(sigPaint);
bitmapSigPaint.setColor(sigPrintColor);
RectF sigBounds = new RectF();
sigPath.computeBounds(sigBounds, true);
if (sigBounds.width() != 0 && sigBounds.height() != 0) {
float density = getResources().getDisplayMetrics().density;
int dipWidth = (int) (sigBounds.width() / density);
int dipHeight = (int) (sigBounds.height() / density);
Bitmap returnedBitmap = Bitmap.createBitmap(dipWidth, dipHeight,
Bitmap.Config.ARGB_4444);
float minX = Integer.MAX_VALUE;
float minY = Integer.MAX_VALUE;
for (LinePathPoint point : sigPoints) {
minX = Math.min(minX, point.x);
minY = Math.min(minY, point.y);
}
sigPath.offset(-minX, -minY);
PathShape pathShape = new PathShape(sigPath, sigBounds.width(), sigBounds.height());
pathShape.resize(dipWidth, dipHeight);
Canvas canvas = new Canvas(returnedBitmap);
pathShape.draw(canvas, bitmapSigPaint);
return returnedBitmap;
}
return null;
}
示例2: draw
import android.graphics.drawable.shapes.PathShape; //导入方法依赖的package包/类
/**
* Draw the graphic on the supplied canvas. Drawing should use the following methods to
* convert to view coordinates for the graphics that are drawn:
* <ol>
* <li>{@link GraphicOverlay.Graphic#scaleX(float)} and {@link GraphicOverlay.Graphic#scaleY(float)} adjust the size of
* the supplied value from the preview scale to the view scale.</li>
* <li>{@link GraphicOverlay.Graphic#translateX(float)} and {@link GraphicOverlay.Graphic#translateY(float)} adjust the
* coordinate from the preview's coordinate system to the view coordinate system.</li>
* </ol>
*
* @param canvas drawing canvas
*/
@Override
public void draw(Canvas canvas) {
//TODO fix the coordinates see http://zhengrui.github.io/android-coordinates.html
if(scannedDoc != null && scannedDoc.detectedQuad != null){
//boolean isPortrait = Util.isPortraitMode(mOverlay.getContext());
Path path = new Path();
/*
Log.d("DOC-GRAPHIC", "IsPortrait? " + isPortrait);
float tlX = isPortrait? translateY((float) scannedDoc.detectedQuad.points[0].y):translateX((float) scannedDoc.detectedQuad.points[0].x);
float tlY = isPortrait? translateX((float) scannedDoc.detectedQuad.points[0].x):translateY((float) scannedDoc.detectedQuad.points[0].y);
Log.d("DOC-GRAPHIC", "Top left: x: " + scannedDoc.detectedQuad.points[0].x + ", y: " + scannedDoc.detectedQuad.points[0].y
+ " -> x: " + tlX + ", y: " + tlY);
float blX = isPortrait? translateY((float) scannedDoc.detectedQuad.points[1].y):translateX((float) scannedDoc.detectedQuad.points[1].x);
float blY = isPortrait? translateX((float) scannedDoc.detectedQuad.points[1].x):translateY((float) scannedDoc.detectedQuad.points[1].y);
Log.d("DOC-GRAPHIC", "Bottom left: x: " + scannedDoc.detectedQuad.points[1].x + ", y: " + scannedDoc.detectedQuad.points[1].y
+ " -> x: " + blX + ", y: " + blY);
float brX = isPortrait? translateY((float) scannedDoc.detectedQuad.points[2].y):translateX((float) scannedDoc.detectedQuad.points[2].x);
float brY = isPortrait? translateX((float) scannedDoc.detectedQuad.points[2].x):translateY((float) scannedDoc.detectedQuad.points[2].y);
Log.d("DOC-GRAPHIC", "Bottom right: x: " + scannedDoc.detectedQuad.points[2].x + ", y: " + scannedDoc.detectedQuad.points[2].y
+ " -> x: " + brX + ", y: " + brY);
float trX = isPortrait? translateY((float) scannedDoc.detectedQuad.points[3].y):translateX((float) scannedDoc.detectedQuad.points[3].x);
float trY = isPortrait? translateX((float) scannedDoc.detectedQuad.points[3].x):translateY((float) scannedDoc.detectedQuad.points[3].y);
Log.d("DOC-GRAPHIC", "Top right: x: " + scannedDoc.detectedQuad.points[3].x + ", y: " + scannedDoc.detectedQuad.points[3].y
+ " -> x: " + trX + ", y: " + trY);
*/
int frameWidth = scannedDoc.getImage().getMetadata().getHeight();
path.moveTo(((float)(frameWidth - scannedDoc.detectedQuad.points[0].y)), ((float)scannedDoc.detectedQuad.points[0].x));
path.lineTo(((float)(frameWidth - scannedDoc.detectedQuad.points[1].y)), ((float)scannedDoc.detectedQuad.points[1].x));
path.lineTo(((float)(frameWidth - scannedDoc.detectedQuad.points[2].y)), ((float)scannedDoc.detectedQuad.points[2].x));
path.lineTo(((float)(frameWidth - scannedDoc.detectedQuad.points[3].y)), ((float)scannedDoc.detectedQuad.points[3].x));
path.close();
PathShape shape = new PathShape(path, scannedDoc.getImage().getMetadata().getHeight(), scannedDoc.getImage().getMetadata().getWidth());
shape.resize(canvas.getWidth(), canvas.getHeight());
shape.draw(canvas, bodyPaint);
shape.draw(canvas, borderPaint);
//canvas.drawPath(path, borderPaint);
//canvas.drawPath(path, bodyPaint);
Log.d("DOC-GRAPHIC", "DONE DRAWING");
}
}