List of usage examples for android.graphics Canvas drawLine
public void drawLine(float startX, float startY, float stopX, float stopY, @NonNull Paint paint)
From source file:Main.java
/** * Draw a straight line through the points. *//* w ww . j a va 2s . co m*/ public static void drawLine(Point p1, Point p2, Canvas canvas, Paint paint) { canvas.save(); canvas.drawLine(p1.x, p1.y, p2.x, p2.y, paint); canvas.restore(); }
From source file:Main.java
/** * Draw a straight line through the points *//* w w w. j a v a 2 s .co m*/ public static void drawLine(PointF p1, PointF p2, Canvas canvas, Paint paint) { canvas.save(); canvas.drawLine(p1.x, p1.y, p2.x, p2.y, paint); canvas.restore(); }
From source file:Main.java
public static void drawCross(Bitmap bm, int x, int y) { Canvas c = new Canvas(bm); Paint p = new Paint(); p.setColor(0xffff0000);//www .j a v a2 s . c o m c.drawLine(x - 4, y, x + 4, y, p); c.drawLine(x, y - 4, x, y + 4, p); }
From source file:Main.java
private static void drawLine(Canvas canvas, int coordX, int coordY) { //Draw the line canvas.drawLine(coord_A[coordX], coord_A[coordY], coord_B[coordX], coord_B[coordY], paintBlack); /*A-B*/ canvas.drawLine(coord_B[coordX], coord_B[coordY], coord_C[coordX], coord_C[coordY], paintBlack); /*B-C*/ canvas.drawLine(coord_C[coordX], coord_C[coordY], coord_D[coordX], coord_D[coordY], paintBlack); /*C-D*/ canvas.drawLine(coord_D[coordX], coord_D[coordY], coord_E[coordX], coord_E[coordY], paintBlack); /*D-E*/ canvas.drawLine(coord_E[coordX], coord_E[coordY], coord_F[coordX], coord_F[coordY], paintBlack); /*E-F*/ canvas.drawLine(coord_F[coordX], coord_F[coordY], coord_G[coordX], coord_G[coordY], paintBlack); /*F-G*/ canvas.drawLine(coord_G[coordX], coord_G[coordY], coord_H[coordX], coord_H[coordY], paintBlack); /*G-H*/ canvas.drawLine(coord_H[coordX], coord_H[coordY], coord_I[coordX], coord_I[coordY], paintBlack); /*H-I*/ canvas.drawLine(coord_I[coordX], coord_I[coordY], coord_J[coordX], coord_J[coordY], paintBlack); /*I-J*/ canvas.drawLine(coord_J[coordX], coord_J[coordY], coord_A[coordX], coord_A[coordY], paintBlack); /*J-A*/ }
From source file:Main.java
public static Bitmap getHistogram(Bitmap bmpOriginal) { //Scale bmpOriginal to improve performance final int dstWidth = 200; int dstHeight = dstWidth * bmpOriginal.getHeight() / bmpOriginal.getWidth(); Bitmap bmpScaled = Bitmap.createScaledBitmap(bmpOriginal, dstWidth, dstHeight, false); int[] histogramValues = new int[256]; int[] pixels = new int[dstWidth]; int pxBrightness; for (int row = 0; row < dstHeight; row++) { bmpScaled.getPixels(pixels, 0, dstWidth, 0, row, dstWidth, 1); for (int col = 0; col < dstWidth; col++) { pxBrightness = rgbToGray(pixels[col]); histogramValues[pxBrightness]++; }//from www. j av a2s . c o m } bmpScaled.recycle(); int histogramMax = max(histogramValues); Bitmap bmpHistogram = Bitmap.createBitmap(256, histogramMax, Config.ARGB_8888); Canvas canvas = new Canvas(bmpHistogram); Paint paint = new Paint(); paint.setColor(Color.CYAN); for (int i = 0; i < 256; i++) canvas.drawLine(i, histogramMax - histogramValues[i], i, histogramMax, paint); return bmpHistogram; }
From source file:com.jwetherell.quick_response_code.DecoderActivity.java
protected static void drawLine(Canvas canvas, Paint paint, ResultPoint a, ResultPoint b) { canvas.drawLine(a.getX(), a.getY(), b.getX(), b.getY(), paint); }
From source file:Main.java
public static Bitmap drawBackground(int cellSize, int height, int widht) { Bitmap bitmap = Bitmap.createBitmap(widht, height, Config.ARGB_8888); Canvas cv = new Canvas(bitmap); Paint background = new Paint(); background.setColor(BACKGROUND_COLOR); cv.drawRect(0, 0, widht, height, background); background.setAntiAlias(true);/*ww w. ja va 2 s .c om*/ background.setColor(LINE_COLOR); for (int i = 0; i < widht / cellSize; i++) { cv.drawLine(cellSize * i, 0, cellSize * i, height, background); } for (int i = 0; i < height / cellSize; i++) { cv.drawLine(0, cellSize * i, widht, cellSize * i, background); } return bitmap; }
From source file:Main.java
public static void drawRuleOfThird(Canvas canvas, RectF bounds) { Paint p = new Paint(); p.setStyle(Paint.Style.STROKE); p.setColor(Color.argb(128, 255, 255, 255)); p.setStrokeWidth(2);//from ww w. ja v a 2s. c o m float stepX = bounds.width() / 3.0f; float stepY = bounds.height() / 3.0f; float x = bounds.left + stepX; float y = bounds.top + stepY; for (int i = 0; i < 2; i++) { canvas.drawLine(x, bounds.top, x, bounds.bottom, p); x += stepX; } for (int j = 0; j < 2; j++) { canvas.drawLine(bounds.left, y, bounds.right, y, p); y += stepY; } }
From source file:com.cleverzone.zhizhi.capture.CaptureActivity.java
private static void drawLine(Canvas canvas, Paint paint, ResultPoint a, ResultPoint b, float scaleFactor) { if (a != null && b != null) { canvas.drawLine(scaleFactor * a.getX(), scaleFactor * a.getY(), scaleFactor * b.getX(), scaleFactor * b.getY(), paint); }// w ww. j av a 2 s. com }
From source file:Main.java
/** * Draw a straight line through the points */// ww w . j a va 2 s . co m public void drawLine(PointF p1, PointF p2, Canvas canvas, Paint paint) { canvas.save(); canvas.drawLine(p1.x, p1.y, p2.x, p2.y, paint); canvas.restore(); }