List of usage examples for android.graphics Canvas drawPoint
public void drawPoint(float x, float y, @NonNull Paint paint)
From source file:Main.java
public static void drawKnots(Canvas canvas, List<PointF> knots, int color) { Log.d("GammaGraph", "function drawKnots"); Paint paint = new Paint(); paint.setAntiAlias(true);//from www. java 2 s .c om paint.setColor(color); paint.setStrokeWidth(7); for (PointF knot : knots) { canvas.drawPoint(knot.x, knot.y, paint); } }
From source file:Main.java
/** * Draws a circular arc on the given {@code Canvas}. * * @param canvas The canvas to draw into. * @param circleCenter The center of the circle on which to draw the arc. * @param circleRadius The radius of the circle on which to draw the arc. * @param startAngle Starting angle (in degrees) where the arc begins. * @param sweepAngle Sweep angle (in degrees) measured clockwise. * @param paint The paint to use then drawing the arc. * @param arcsPointsOnCircle See {@link #createBezierArcDegrees(PointF, float, float, float, int, boolean, Path)}. * @param arcsOverlayPoints See {@link #createBezierArcDegrees(PointF, float, float, float, int, boolean, Path)}. * * @see #drawArc(Canvas, PointF, float, float, float, Paint) *//*from w w w . j a v a2 s . co m*/ public static void drawArc(@NonNull Canvas canvas, PointF circleCenter, float circleRadius, float startAngle, float sweepAngle, @NonNull Paint paint, int arcsPointsOnCircle, boolean arcsOverlayPoints) { if (sweepAngle == 0f) { final PointF p = pointFromAngleDegrees(circleCenter, circleRadius, startAngle); canvas.drawPoint(p.x, p.y, paint); } else { canvas.drawPath(createBezierArcDegrees(circleCenter, circleRadius, startAngle, sweepAngle, arcsPointsOnCircle, arcsOverlayPoints, null), paint); } }
From source file:com.github.barcodeeye.scan.CaptureActivity.java
/** * Superimpose a line for 1D or dots for 2D to highlight the key features of * the barcode.// w w w . j a v a 2s . c o m * * @param barcode * A bitmap of the captured image. * @param scaleFactor * amount by which thumbnail was scaled * @param rawResult * The decoded results which contains the points to draw. */ private static void drawResultPoints(Bitmap barcode, float scaleFactor, Result rawResult, int color) { ResultPoint[] points = rawResult.getResultPoints(); if (points != null && points.length > 0) { Canvas canvas = new Canvas(barcode); Paint paint = new Paint(); paint.setColor(color); if (points.length == 2) { paint.setStrokeWidth(4.0f); drawLine(canvas, paint, points[0], points[1], scaleFactor); } else if (points.length == 4 && (rawResult.getBarcodeFormat() == BarcodeFormat.UPC_A || rawResult.getBarcodeFormat() == BarcodeFormat.EAN_13)) { // Hacky special case -- draw two lines, for the barcode and metadata drawLine(canvas, paint, points[0], points[1], scaleFactor); drawLine(canvas, paint, points[2], points[3], scaleFactor); } else { paint.setStrokeWidth(10.0f); for (ResultPoint point : points) { if (point != null) { canvas.drawPoint(scaleFactor * point.getX(), scaleFactor * point.getY(), paint); } } } } }
From source file:com.coinomi.wallet.ui.ScanActivity.java
public void handleResult(final Result scanResult, final Bitmap thumbnailImage, final float thumbnailScaleFactor) { vibrator.vibrate(VIBRATE_DURATION);/*from w ww .j a v a2s . co m*/ // superimpose dots to highlight the key features of the qr code final ResultPoint[] points = scanResult.getResultPoints(); if (points != null && points.length > 0) { final Paint paint = new Paint(); paint.setColor(getResources().getColor(R.color.scan_result_dots)); paint.setStrokeWidth(10.0f); final Canvas canvas = new Canvas(thumbnailImage); canvas.scale(thumbnailScaleFactor, thumbnailScaleFactor); for (final ResultPoint point : points) canvas.drawPoint(point.getX(), point.getY(), paint); } scannerView.drawResultBitmap(thumbnailImage); final Intent result = new Intent(); result.putExtra(INTENT_EXTRA_RESULT, scanResult.getText()); setResult(RESULT_OK, result); // delayed finish new Handler().post(new Runnable() { @Override public void run() { finish(); } }); }
From source file:com.fillerino.wallet.ui.ScanActivity.java
public void handleResult(final Result scanResult, final Bitmap thumbnailImage, final float thumbnailScaleFactor) { vibrator.vibrate(VIBRATE_DURATION);//from w w w . j a v a2 s.c om // superimpose dots to highlight the key features of the qr code final ResultPoint[] points = scanResult.getResultPoints(); if (points != null && points.length > 0) { final Paint paint = new Paint(); paint.setColor(getResources().getColor(com.fillerino.wallet.R.color.scan_result_dots)); paint.setStrokeWidth(10.0f); final Canvas canvas = new Canvas(thumbnailImage); canvas.scale(thumbnailScaleFactor, thumbnailScaleFactor); for (final ResultPoint point : points) canvas.drawPoint(point.getX(), point.getY(), paint); } scannerView.drawResultBitmap(thumbnailImage); final Intent result = new Intent(); result.putExtra(INTENT_EXTRA_RESULT, scanResult.getText()); setResult(RESULT_OK, result); // delayed finish new Handler().post(new Runnable() { @Override public void run() { finish(); } }); }
From source file:ee.ioc.phon.android.speak.Utils.java
/** * <p>Returns a bitmap that visualizes the given waveform (byte array), * i.e. a sequence of 16-bit integers.</p> * * TODO: show to high/low points in other color * TODO: show end pause data with another color */// w w w . ja v a 2s . c o m public static Bitmap drawWaveform(byte[] waveBuffer, int w, int h, int start, int end) { final Bitmap b = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); final Canvas c = new Canvas(b); final Paint paint = new Paint(); paint.setColor(0xFFFFFFFF); // 0xRRGGBBAA paint.setAntiAlias(true); paint.setStrokeWidth(0); final Paint redPaint = new Paint(); redPaint.setColor(0xFF000080); redPaint.setAntiAlias(true); redPaint.setStrokeWidth(0); final ShortBuffer buf = ByteBuffer.wrap(waveBuffer).order(ByteOrder.LITTLE_ENDIAN).asShortBuffer(); buf.position(0); final int numSamples = waveBuffer.length / 2; //final int delay = (SAMPLING_RATE * 100 / 1000); final int delay = 0; int endIndex = end / 2 + delay; if (end == 0 || endIndex >= numSamples) { endIndex = numSamples; } int index = start / 2 - delay; if (index < 0) { index = 0; } final int size = endIndex - index; int numSamplePerPixel = 32; int delta = size / (numSamplePerPixel * w); if (delta == 0) { numSamplePerPixel = size / w; delta = 1; } final float scale = 3.5f / 65536.0f; // do one less column to make sure we won't read past // the buffer. try { for (int i = 0; i < w - 1; i++) { final float x = i; for (int j = 0; j < numSamplePerPixel; j++) { final short s = buf.get(index); final float y = (h / 2) - (s * h * scale); if (s > Short.MAX_VALUE - 10 || s < Short.MIN_VALUE + 10) { // TODO: make it work c.drawPoint(x, y, redPaint); } else { c.drawPoint(x, y, paint); } index += delta; } } } catch (IndexOutOfBoundsException e) { // this can happen, but we don't care } return b; }
From source file:com.abhi.barcode.frag.libv2.BarcodeFragment.java
/** * Superimpose a line for 1D or dots for 2D to highlight the key features of * the barcode./* w ww. j a v a 2s. co m*/ * * @param barcode * A bitmap of the captured image. * @param scaleFactor * amount by which thumbnail was scaled * @param rawResult * The decoded results which contains the points to draw. */ private void drawResultPoints(Bitmap barcode, float scaleFactor, Result rawResult) { ResultPoint[] points = rawResult.getResultPoints(); if (points != null && points.length > 0) { Canvas canvas = new Canvas(barcode); Paint paint = new Paint(); paint.setColor(Color.parseColor("#c099cc00")); if (points.length == 2) { paint.setStrokeWidth(4.0f); drawLine(canvas, paint, points[0], points[1], scaleFactor); } else if (points.length == 4 && (rawResult.getBarcodeFormat() == BarcodeFormat.UPC_A || rawResult.getBarcodeFormat() == BarcodeFormat.EAN_13)) { // Hacky special case -- draw two lines, for the barcode and // metadata drawLine(canvas, paint, points[0], points[1], scaleFactor); drawLine(canvas, paint, points[2], points[3], scaleFactor); } else { paint.setStrokeWidth(10.0f); for (ResultPoint point : points) { canvas.drawPoint(scaleFactor * point.getX(), scaleFactor * point.getY(), paint); } } } }
From source file:piuk.blockchain.android.ui.zxing.CaptureActivity.java
/** * Superimpose a line for 1D or dots for 2D to highlight the key features of the barcode. * * @param barcode A bitmap of the captured image. * @param rawResult The decoded results which contains the points to draw. *//* w w w.jav a2s . co m*/ private void drawResultPoints(Bitmap barcode, Result rawResult) { ResultPoint[] points = rawResult.getResultPoints(); if (points != null && points.length > 0) { Canvas canvas = new Canvas(barcode); Paint paint = new Paint(); paint.setColor(ContextCompat.getColor(this, R.color.primary_blue_accent)); if (points.length == 2) { paint.setStrokeWidth(4.0f); drawLine(canvas, paint, points[0], points[1]); } else if (points.length == 4 && (rawResult.getBarcodeFormat() == BarcodeFormat.UPC_A || rawResult.getBarcodeFormat() == BarcodeFormat.EAN_13)) { // Hacky special case -- draw two lines, for the barcode and metadata drawLine(canvas, paint, points[0], points[1]); drawLine(canvas, paint, points[2], points[3]); } else { paint.setStrokeWidth(10.0f); for (ResultPoint point : points) { canvas.drawPoint(point.getX(), point.getY(), paint); } } } }
From source file:co.jlabs.cersei_retailer.zxingfragmentlib.BarCodeScannerFragment.java
/** * Superimpose a line for 1D or dots for 2D to highlight the key features of the barcode. * * @param barcode A bitmap of the captured image. * @param scaleFactor amount by which thumbnail was scaled * @param rawResult The decoded results which contains the points to draw. *///from www.jav a 2 s . com private void drawResultPoints(Bitmap barcode, float scaleFactor, Result rawResult) { ResultPoint[] points = rawResult.getResultPoints(); if (points != null && points.length > 0 && barcode != null) { Canvas canvas = new Canvas(barcode); Paint paint = new Paint(); paint.setColor(getResources().getColor(R.color.result_points)); if (points.length == 2) { paint.setStrokeWidth(4.0f); drawLine(canvas, paint, points[0], points[1], scaleFactor); } else if (points.length == 4 && (rawResult.getBarcodeFormat() == BarcodeFormat.UPC_A || rawResult.getBarcodeFormat() == BarcodeFormat.EAN_13)) { // Hacky special case -- draw two lines, for the barcode and metadata drawLine(canvas, paint, points[0], points[1], scaleFactor); drawLine(canvas, paint, points[2], points[3], scaleFactor); } else { paint.setStrokeWidth(10.0f); for (ResultPoint point : points) { canvas.drawPoint(scaleFactor * point.getX(), scaleFactor * point.getY(), paint); } } if (isPortrait()) { Log.d(TAG, "rotating results canvas"); canvas.rotate(90); } } }
From source file:com.abhi.barcode.fragment.BarCodeFragment.java
/** * Superimpose a line for 1D or dots for 2D to highlight the key features of * the barcode.//from w w w . j a v a2 s . c o m * * @param barcode * A bitmap of the captured image. * @param rawResult * The decoded results which contains the points to draw. */ private void drawResultPoints(Bitmap barcode, Result rawResult) { ResultPoint[] points = rawResult.getResultPoints(); if (points != null && points.length > 0) { Canvas canvas = new Canvas(barcode); Paint paint = new Paint(); paint.setColor(getResources().getColor(R.color.result_image_border)); paint.setStrokeWidth(3.0f); paint.setStyle(Paint.Style.STROKE); Rect border = new Rect(2, 2, barcode.getWidth() - 2, barcode.getHeight() - 2); canvas.drawRect(border, paint); paint.setColor(getResources().getColor(R.color.result_points)); if (points.length == 2) { paint.setStrokeWidth(4.0f); drawLine(canvas, paint, points[0], points[1]); } else if (points.length == 4 && (rawResult.getBarcodeFormat() == BarcodeFormat.UPC_A || rawResult.getBarcodeFormat() == BarcodeFormat.EAN_13)) { drawLine(canvas, paint, points[0], points[1]); drawLine(canvas, paint, points[2], points[3]); } else { paint.setStrokeWidth(10.0f); for (ResultPoint point : points) { canvas.drawPoint(point.getX(), point.getY(), paint); } } } }