- // We could be tricky and use the first row in each set of multiple as the temporary storage,
- // instead of allocating this separate array.
- byte[] row = new byte[outputWidth];
-
- // 1. Write the white lines at the top
- for (int y = 0; y < topPadding; y++) {
- setRowColor(outputArray[y], (byte) 255);
- }
-
- // 2. Expand the QR image to the multiple
- byte[][] inputArray = input.getArray();
- for (int y = 0; y < inputHeight; y++) {
- // a. Write the white pixels at the left of each row
- for (int x = 0; x < leftPadding; x++) {
- row[x] = (byte) 255;
- }
-
- // b. Write the contents of this row of the barcode
- int offset = leftPadding;
- for (int x = 0; x < inputWidth; x++) {
- byte value = (inputArray[y][x] == 1) ? 0 : (byte) 255;
- for (int z = 0; z < multiple; z++) {
- row[offset + z] = value;
+ for (int inputY = 0, outputY = topPadding; inputY < inputHeight; inputY++, outputY += multiple) {
+ // Write the contents of this row of the barcode
+ for (int inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) {
+ if (input.get(inputX, inputY) == 1) {
+ output.setRegion(outputX, outputY, multiple, multiple);