@Override public byte[] getRow(int y, byte[] row) { row = delegate.getRow(y, row); int width = getWidth(); for (int i = 0; i < width; i++) { row[i] = (byte) (255 - (row[i] & 0xFF)); } return row; }
@Override public byte[] getRow(int y, byte[] row) { row = delegate.getRow(y, row); int width = getWidth(); for (int i = 0; i < width; i++) { row[i] = (byte) (255 - (row[i] & 0xFF)); } return row; }
@Override public final String toString() { byte[] row = new byte[width]; StringBuilder result = new StringBuilder(height * (width + 1)); for (int y = 0; y < height; y++) { row = getRow(y, row); for (int x = 0; x < width; x++) { int luminance = row[x] & 0xFF; char c; if (luminance < 0x40) { c = '#'; } else if (luminance < 0x80) { c = '+'; } else if (luminance < 0xC0) { c = '.'; } else { c = ' '; } result.append(c); } result.append('\n'); } return result.toString(); }
@Override public final String toString() { byte[] row = new byte[width]; StringBuilder result = new StringBuilder(height * (width + 1)); for (int y = 0; y < height; y++) { row = getRow(y, row); for (int x = 0; x < width; x++) { int luminance = row[x] & 0xFF; char c; if (luminance < 0x40) { c = '#'; } else if (luminance < 0x80) { c = '+'; } else if (luminance < 0xC0) { c = '.'; } else { c = ' '; } result.append(c); } result.append('\n'); } return result.toString(); }
public BitArray getBlackRow(int y, BitArray row) throws NotFoundException { LuminanceSource source = getLuminanceSource(); int width = source.getWidth(); if (row == null || row.getSize() < width) { row = new BitArray(width); } else { row.clear(); } initArrays(width); byte[] localLuminances = source.getRow(y, luminances); int[] localBuckets = buckets; for (int x = 0; x < width; x++) { int pixel = localLuminances[x] & 0xff; localBuckets[pixel >> LUMINANCE_SHIFT]++; } int blackPoint = estimateBlackPoint(localBuckets); int left = localLuminances[0] & 0xff; int center = localLuminances[1] & 0xff; for (int x = 1; x < width - 1; x++) { int right = localLuminances[x + 1] & 0xff; // A simple -1 4 -1 box filter with a weight of 2. int luminance = ((center << 2) - left - right) >> 1; if (luminance < blackPoint) { row.set(x); } left = center; center = right; } return row; }
for (int y = 1; y < 5; y++) { int row = height * y / 5; byte[] localLuminances = source.getRow(row, luminances); int right = (width * 4) / 5; for (int x = width / 5; x < right; x++) {
for (int y = 1; y < 5; y++) { int row = height * y / 5; byte[] localLuminances = source.getRow(row, luminances); int right = (width * 4) / 5; for (int x = width / 5; x < right; x++) {
for (int y = 1; y < 5; y++) { int row = height * y / 5; byte[] localLuminances = source.getRow(row, luminances); int right = (width << 2) / 5; for (int x = width / 5; x < right; x++) {
byte[] localLuminances = source.getRow(y, luminances); int[] localBuckets = buckets; for (int x = 0; x < width; x++) {
byte[] localLuminances = source.getRow(y, luminances); int[] localBuckets = buckets; for (int x = 0; x < width; x++) {