| 61 | | @Override |
|---|
| 62 | | public void readRows(byte[] data, int rows) { |
|---|
| 63 | | // TODO Auto-generated method stub |
|---|
| 64 | | |
|---|
| | 65 | private boolean secondGreenValid; |
|---|
| | 66 | |
|---|
| | 67 | private byte secondGreen; |
|---|
| | 68 | |
|---|
| | 69 | void read(byte[] pixel, int offset, byte[] saved, int sOffset, int off0, |
|---|
| | 70 | int off1, int off2) { |
|---|
| | 71 | if (xStep == 1) { |
|---|
| | 72 | if (secondGreenValid) { |
|---|
| | 73 | // use the second green |
|---|
| | 74 | secondGreenValid = false; |
|---|
| | 75 | pixel[offset + off0] = saved[sOffset + off0]; |
|---|
| | 76 | pixel[offset + off1] = secondGreen; |
|---|
| | 77 | pixel[offset + off2] = saved[sOffset + off2]; |
|---|
| | 78 | |
|---|
| | 79 | return; |
|---|
| | 80 | } |
|---|
| | 81 | |
|---|
| | 82 | // otherwise, load a new thing |
|---|
| | 83 | pixel[offset + off1] = readSubpixel(); // G |
|---|
| | 84 | pixel[offset + off0] = readSubpixel(); // G |
|---|
| | 85 | secondGreen = readSubpixel(); // G |
|---|
| | 86 | pixel[offset + off2] = readSubpixel(); // G |
|---|
| | 87 | |
|---|
| | 88 | secondGreenValid = true; |
|---|
| | 89 | } else { |
|---|
| | 90 | skipSubpixel(); |
|---|
| | 91 | pixel[offset + off0] = readSubpixel(); |
|---|
| | 92 | pixel[offset + off1] = readSubpixel(); |
|---|
| | 93 | pixel[offset + off2] = readSubpixel(); |
|---|
| | 94 | } |
|---|
| | 97 | void skip(int i) { |
|---|
| | 98 | for (int z = 0; z < i; z++) { |
|---|
| | 99 | skipSubpixel(); |
|---|
| | 100 | skipSubpixel(); |
|---|
| | 101 | skipSubpixel(); |
|---|
| | 102 | skipSubpixel(); |
|---|
| | 103 | } |
|---|
| | 104 | } |
|---|
| | 105 | |
|---|
| | 106 | @Override |
|---|
| | 107 | public int readRows(byte[] data, int rows) { |
|---|
| | 108 | // First read into frame |
|---|
| | 109 | seekTop(); |
|---|
| | 110 | |
|---|
| | 111 | for (int r = 0; r < rows; r++) { |
|---|
| | 112 | int x = x0; |
|---|
| | 113 | // First read into line |
|---|
| | 114 | seekLeft(); |
|---|
| | 115 | |
|---|
| | 116 | if (coi == CHANNEL_ALL) { |
|---|
| | 117 | for (int j = 0; j < width; j++) { |
|---|
| | 118 | int offset = r * width + j * 3; |
|---|
| | 119 | read(data, offset, data, offset - 3, 0, 1, 2); |
|---|
| | 120 | |
|---|
| | 121 | // advance by x_step, but don't go over the edge |
|---|
| | 122 | if (xStep == 1) { |
|---|
| | 123 | |
|---|
| | 124 | } else if (xStep + x >= x1) { |
|---|
| | 125 | skip((rawWidth - x - 1) / 2); |
|---|
| | 126 | } else { |
|---|
| | 127 | // printf("inside the window\n"); |
|---|
| | 128 | x += xStep; |
|---|
| | 129 | skip((xStep - 1) / 2); |
|---|
| | 130 | } |
|---|
| | 131 | } |
|---|
| | 132 | } else { |
|---|
| | 133 | // XXX: single channel |
|---|
| | 134 | } |
|---|
| | 135 | |
|---|
| | 136 | // advance by y_step, but don't go over the edge |
|---|
| | 137 | if (yStep == 1) { |
|---|
| | 138 | yLoc++; |
|---|
| | 139 | } else if (yStep + yLoc > y1) { |
|---|
| | 140 | // we're done |
|---|
| | 141 | yLoc += yStep; |
|---|
| | 142 | } else { |
|---|
| | 143 | skip((yStep - 1) * rawWidth / 2); |
|---|
| | 144 | yLoc += yStep; |
|---|
| | 145 | } |
|---|
| | 146 | } |
|---|
| | 147 | return rows; |
|---|
| | 148 | } |
|---|
| | 149 | |
|---|
| | 150 | private void seekLeft() { |
|---|
| | 151 | // TODO Auto-generated method stub |
|---|
| | 152 | |
|---|
| | 153 | } |
|---|
| | 154 | |
|---|
| | 155 | private void seekTop() { |
|---|
| | 156 | // TODO Auto-generated method stub |
|---|
| | 157 | |
|---|
| | 158 | } |
|---|