//gridLines[areaX][areaY][direction(x=0,y=1)][EachLines] internal virtual bool[][] getQRCodeMatrix(bool[][] image, SamplingGrid gridLines) { //int gridSize = gridLines.getWidth() * gridLines.getWidth(0,0); int gridSize = gridLines.TotalWidth; // now this is done within the SamplingGrid class... // if (gridLines.getWidth() >= 2) // gridSize-=1; canvas.println("gridSize=" + gridSize); //canvas.println("gridLines.getWidth() * gridLines.getWidth(0,0) = "+gridLines.getWidth() * gridLines.getWidth(0,0)); Point bottomRightPoint = null; bool[][] sampledMatrix = new bool[gridSize][]; for (int i = 0; i < gridSize; i++) { sampledMatrix[i] = new bool[gridSize]; } for (int ay = 0; ay < gridLines.getHeight(); ay++) { for (int ax = 0; ax < gridLines.getWidth(); ax++) { System.Collections.ArrayList sampledPoints = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); //only for visualiz; for (int y = 0; y < gridLines.getHeight(ax, ay); y++) { for (int x = 0; x < gridLines.getWidth(ax, ay); x++) { int x1 = gridLines.getXLine(ax, ay, x).getP1().X; int y1 = gridLines.getXLine(ax, ay, x).getP1().Y; int x2 = gridLines.getXLine(ax, ay, x).getP2().X; int y2 = gridLines.getXLine(ax, ay, x).getP2().Y; int x3 = gridLines.getYLine(ax, ay, y).getP1().X; int y3 = gridLines.getYLine(ax, ay, y).getP1().Y; int x4 = gridLines.getYLine(ax, ay, y).getP2().X; int y4 = gridLines.getYLine(ax, ay, y).getP2().Y; int e = (y2 - y1) * (x3 - x4) - (y4 - y3) * (x1 - x2); int f = (x1 * y2 - x2 * y1) * (x3 - x4) - (x3 * y4 - x4 * y3) * (x1 - x2); int g = (x3 * y4 - x4 * y3) * (y2 - y1) - (x1 * y2 - x2 * y1) * (y4 - y3); sampledMatrix[gridLines.getX(ax, x)][gridLines.getY(ay, y)] = image[f / e][g / e]; if ((ay == gridLines.getHeight() - 1 && ax == gridLines.getWidth() - 1) && y == gridLines.getHeight(ax, ay) - 1 && x == gridLines.getWidth(ax, ay) - 1) { bottomRightPoint = new Point(f / e, g / e); } //calling canvas.drawPoint in loop can be very slow. // use canvas.drawPoints if you need //canvas.drawPoint(new Point(f / e,g / e), Color.RED); } } } } if (bottomRightPoint.X > image.Length - 1 || bottomRightPoint.Y > image[0].Length - 1) { throw new System.IndexOutOfRangeException("Sampling grid pointed out of image"); } canvas.drawPoint(bottomRightPoint, ThoughtWorks.QRCode.Codec.Util.Color_Fields.BLUE); return(sampledMatrix); }
internal virtual bool[][] getQRCodeMatrix(bool[][] image, SamplingGrid gridLines) { int gridSize = gridLines.TotalWidth; canvas.println("gridSize=" + gridSize); Point bottomRightPoint = null; bool[][] sampledMatrix = new bool[gridSize][]; for (int i = 0; i < gridSize; i++) { sampledMatrix[i] = new bool[gridSize]; } for (int ay = 0; ay < gridLines.getHeight(); ay++) { for (int ax = 0; ax < gridLines.getWidth(); ax++) { System.Collections.ArrayList sampledPoints = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); for (int y = 0; y < gridLines.getHeight(ax, ay); y++) { for (int x = 0; x < gridLines.getWidth(ax, ay); x++) { int x1 = gridLines.getXLine(ax, ay, x).getP1().X; int y1 = gridLines.getXLine(ax, ay, x).getP1().Y; int x2 = gridLines.getXLine(ax, ay, x).getP2().X; int y2 = gridLines.getXLine(ax, ay, x).getP2().Y; int x3 = gridLines.getYLine(ax, ay, y).getP1().X; int y3 = gridLines.getYLine(ax, ay, y).getP1().Y; int x4 = gridLines.getYLine(ax, ay, y).getP2().X; int y4 = gridLines.getYLine(ax, ay, y).getP2().Y; int e = (y2 - y1) * (x3 - x4) - (y4 - y3) * (x1 - x2); int f = (x1 * y2 - x2 * y1) * (x3 - x4) - (x3 * y4 - x4 * y3) * (x1 - x2); int g = (x3 * y4 - x4 * y3) * (y2 - y1) - (x1 * y2 - x2 * y1) * (y4 - y3); sampledMatrix[gridLines.getX(ax, x)][gridLines.getY(ay, y)] = image[f / e][g / e]; if ((ay == gridLines.getHeight() - 1 && ax == gridLines.getWidth() - 1) && y == gridLines.getHeight(ax, ay) - 1 && x == gridLines.getWidth(ax, ay) - 1) { bottomRightPoint = new Point(f / e, g / e); } } } } } if (bottomRightPoint.X > image.Length - 1 || bottomRightPoint.Y > image[0].Length - 1) { throw new System.IndexOutOfRangeException("Sampling grid pointed out of image"); } canvas.drawPoint(bottomRightPoint, QRStudio.Engine.Codec.Util.Color_Fields.BLUE); return(sampledMatrix); }
internal virtual bool[][] getQRCodeMatrix(bool[][] image, SamplingGrid gridLines) { int totalWidth = gridLines.TotalWidth; this.canvas.println("gridSize=" + (object)totalWidth); Point point = (Point)null; bool[][] flagArray = new bool[totalWidth][]; for (int index = 0; index < totalWidth; ++index) { flagArray[index] = new bool[totalWidth]; } for (int ay = 0; ay < gridLines.getHeight(); ++ay) { for (int ax = 0; ax < gridLines.getWidth(); ++ax) { ArrayList.Synchronized(new ArrayList(10)); for (int y1 = 0; y1 < gridLines.getHeight(ax, ay); ++y1) { for (int x1 = 0; x1 < gridLines.getWidth(ax, ay); ++x1) { int x2 = gridLines.getXLine(ax, ay, x1).getP1().X; int y2 = gridLines.getXLine(ax, ay, x1).getP1().Y; int x3 = gridLines.getXLine(ax, ay, x1).getP2().X; int y3 = gridLines.getXLine(ax, ay, x1).getP2().Y; int x4 = gridLines.getYLine(ax, ay, y1).getP1().X; int y4 = gridLines.getYLine(ax, ay, y1).getP1().Y; int x5 = gridLines.getYLine(ax, ay, y1).getP2().X; int y5 = gridLines.getYLine(ax, ay, y1).getP2().Y; int num1 = (y3 - y2) * (x4 - x5) - (y5 - y4) * (x2 - x3); int num2 = (x2 * y3 - x3 * y2) * (x4 - x5) - (x4 * y5 - x5 * y4) * (x2 - x3); int num3 = (x4 * y5 - x5 * y4) * (y3 - y2) - (x2 * y3 - x3 * y2) * (y5 - y4); flagArray[gridLines.getX(ax, x1)][gridLines.getY(ay, y1)] = image[num2 / num1][num3 / num1]; if (ay == gridLines.getHeight() - 1 && ax == gridLines.getWidth() - 1 && y1 == gridLines.getHeight(ax, ay) - 1 && x1 == gridLines.getWidth(ax, ay) - 1) { point = new Point(num2 / num1, num3 / num1); } } } } } if (point.X > image.Length - 1 || point.Y > image[0].Length - 1) { throw new IndexOutOfRangeException("Sampling grid pointed out of image"); } this.canvas.drawPoint(point, Color_Fields.BLUE); return(flagArray); }
internal virtual bool[][] getQRCodeMatrix(bool[][] image, SamplingGrid gridLines) { int totalWidth = gridLines.TotalWidth; this.canvas.println("gridSize=" + totalWidth); Point point = null; bool[][] flagArray = new bool[totalWidth][]; for (int i = 0; i < totalWidth; i++) { flagArray[i] = new bool[totalWidth]; } for (int j = 0; j < gridLines.getHeight(); j++) { for (int k = 0; k < gridLines.getWidth(); k++) { ArrayList.Synchronized(new ArrayList(10)); for (int m = 0; m < gridLines.getHeight(k, j); m++) { for (int n = 0; n < gridLines.getWidth(k, j); n++) { int x = gridLines.getXLine(k, j, n).getP1().X; int y = gridLines.getXLine(k, j, n).getP1().Y; int num9 = gridLines.getXLine(k, j, n).getP2().X; int num10 = gridLines.getXLine(k, j, n).getP2().Y; int num11 = gridLines.getYLine(k, j, m).getP1().X; int num12 = gridLines.getYLine(k, j, m).getP1().Y; int num13 = gridLines.getYLine(k, j, m).getP2().X; int num14 = gridLines.getYLine(k, j, m).getP2().Y; int num15 = ((num10 - y) * (num11 - num13)) - ((num14 - num12) * (x - num9)); int num16 = (((x * num10) - (num9 * y)) * (num11 - num13)) - (((num11 * num14) - (num13 * num12)) * (x - num9)); int num17 = (((num11 * num14) - (num13 * num12)) * (num10 - y)) - (((x * num10) - (num9 * y)) * (num14 - num12)); flagArray[gridLines.getX(k, n)][gridLines.getY(j, m)] = image[num16 / num15][num17 / num15]; if ((((j == (gridLines.getHeight() - 1)) && (k == (gridLines.getWidth() - 1))) && (m == (gridLines.getHeight(k, j) - 1))) && (n == (gridLines.getWidth(k, j) - 1))) { point = new Point(num16 / num15, num17 / num15); } } } } } if ((point.X > (image.Length - 1)) || (point.Y > (image[0].Length - 1))) { throw new IndexOutOfRangeException("Sampling grid pointed out of image"); } this.canvas.drawPoint(point, Color_Fields.BLUE); return(flagArray); }
internal virtual bool[][] getQRCodeMatrix(bool[][] image, SamplingGrid gridLines) { int totalWidth = gridLines.TotalWidth; canvas.println("gridSize=" + totalWidth); Point point = null; bool[][] array = new bool[totalWidth][]; for (int i = 0; i < totalWidth; i++) { array[i] = new bool[totalWidth]; } for (int j = 0; j < gridLines.getHeight(); j++) { for (int k = 0; k < gridLines.getWidth(); k++) { ArrayList arrayList = ArrayList.Synchronized(new ArrayList(10)); for (int l = 0; l < gridLines.getHeight(k, j); l++) { for (int m = 0; m < gridLines.getWidth(k, j); m++) { int x = gridLines.getXLine(k, j, m).getP1().X; int y = gridLines.getXLine(k, j, m).getP1().Y; int x2 = gridLines.getXLine(k, j, m).getP2().X; int y2 = gridLines.getXLine(k, j, m).getP2().Y; int x3 = gridLines.getYLine(k, j, l).getP1().X; int y3 = gridLines.getYLine(k, j, l).getP1().Y; int x4 = gridLines.getYLine(k, j, l).getP2().X; int y4 = gridLines.getYLine(k, j, l).getP2().Y; int num = (y2 - y) * (x3 - x4) - (y4 - y3) * (x - x2); int num2 = (x * y2 - x2 * y) * (x3 - x4) - (x3 * y4 - x4 * y3) * (x - x2); int num3 = (x3 * y4 - x4 * y3) * (y2 - y) - (x * y2 - x2 * y) * (y4 - y3); array[gridLines.getX(k, m)][gridLines.getY(j, l)] = image[num2 / num][num3 / num]; if (j == gridLines.getHeight() - 1 && k == gridLines.getWidth() - 1 && l == gridLines.getHeight(k, j) - 1 && m == gridLines.getWidth(k, j) - 1) { point = new Point(num2 / num, num3 / num); } } } } } if (point.X > image.Length - 1 || point.Y > image[0].Length - 1) { throw new IndexOutOfRangeException("Sampling grid pointed out of image"); } canvas.drawPoint(point, Color_Fields.BLUE); return(array); }
internal virtual bool[][] getQRCodeMatrix(bool[][] image, SamplingGrid gridLines) { int gridSize = gridLines.TotalWidth; this.canvas.println("gridSize=" + gridSize); Point bottomRightPoint = null; bool[][] sampledMatrix = new bool[gridSize][]; for (int i = 0; i < gridSize; i++) { sampledMatrix[i] = new bool[gridSize]; } for (int ay = 0; ay < gridLines.getHeight(); ay++) { for (int ax = 0; ax < gridLines.getWidth(); ax++) { ArrayList sampledPoints = ArrayList.Synchronized(new ArrayList(10)); for (int y = 0; y < gridLines.getHeight(ax, ay); y++) { for (int x = 0; x < gridLines.getWidth(ax, ay); x++) { int x2 = gridLines.getXLine(ax, ay, x).getP1().X; int y2 = gridLines.getXLine(ax, ay, x).getP1().Y; int x3 = gridLines.getXLine(ax, ay, x).getP2().X; int y3 = gridLines.getXLine(ax, ay, x).getP2().Y; int x4 = gridLines.getYLine(ax, ay, y).getP1().X; int y4 = gridLines.getYLine(ax, ay, y).getP1().Y; int x5 = gridLines.getYLine(ax, ay, y).getP2().X; int y5 = gridLines.getYLine(ax, ay, y).getP2().Y; int e = (y3 - y2) * (x4 - x5) - (y5 - y4) * (x2 - x3); int f = (x2 * y3 - x3 * y2) * (x4 - x5) - (x4 * y5 - x5 * y4) * (x2 - x3); int g = (x4 * y5 - x5 * y4) * (y3 - y2) - (x2 * y3 - x3 * y2) * (y5 - y4); sampledMatrix[gridLines.getX(ax, x)][gridLines.getY(ay, y)] = image[f / e][g / e]; if (ay == gridLines.getHeight() - 1 && ax == gridLines.getWidth() - 1 && y == gridLines.getHeight(ax, ay) - 1 && x == gridLines.getWidth(ax, ay) - 1) { bottomRightPoint = new Point(f / e, g / e); } } } } } if (bottomRightPoint.X > image.Length - 1 || bottomRightPoint.Y > image[0].Length - 1) { throw new IndexOutOfRangeException("Sampling grid pointed out of image"); } this.canvas.drawPoint(bottomRightPoint, Color_Fields.BLUE); return(sampledMatrix); }