mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Avoid check for transparency when there is no alpha channel
git-svn-id: https://zxing.googlecode.com/svn/trunk@2327 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
f0fb20f055
commit
7bc138ed7a
|
@ -49,18 +49,20 @@ public final class BufferedImageLuminanceSource extends LuminanceSource {
|
||||||
// The color of fully-transparent pixels is irrelevant. They are often, technically, fully-transparent
|
// The color of fully-transparent pixels is irrelevant. They are often, technically, fully-transparent
|
||||||
// black (0 alpha, and then 0 RGB). They are often used, of course as the "white" area in a
|
// black (0 alpha, and then 0 RGB). They are often used, of course as the "white" area in a
|
||||||
// barcode image. Force any such pixel to be white:
|
// barcode image. Force any such pixel to be white:
|
||||||
int[] buffer = new int[width];
|
if (image.getAlphaRaster() != null) {
|
||||||
for (int y = top; y < top + height; y++) {
|
int[] buffer = new int[width];
|
||||||
image.getRGB(left, y, width, 1, buffer, 0, sourceWidth);
|
for (int y = top; y < top + height; y++) {
|
||||||
boolean rowChanged = false;
|
image.getRGB(left, y, width, 1, buffer, 0, sourceWidth);
|
||||||
for (int x = 0; x < width; x++) {
|
boolean rowChanged = false;
|
||||||
if ((buffer[x] & 0xFF000000) == 0) {
|
for (int x = 0; x < width; x++) {
|
||||||
buffer[x] = 0xFFFFFFFF; // = white
|
if ((buffer[x] & 0xFF000000) == 0) {
|
||||||
rowChanged = true;
|
buffer[x] = 0xFFFFFFFF; // = white
|
||||||
|
rowChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (rowChanged) {
|
||||||
|
image.setRGB(left, y, width, 1, buffer, 0, sourceWidth);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (rowChanged) {
|
|
||||||
image.setRGB(left, y, width, 1, buffer, 0, sourceWidth);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,18 +51,20 @@ public final class BufferedImageLuminanceSource extends LuminanceSource {
|
||||||
// The color of fully-transparent pixels is irrelevant. They are often, technically, fully-transparent
|
// The color of fully-transparent pixels is irrelevant. They are often, technically, fully-transparent
|
||||||
// black (0 alpha, and then 0 RGB). They are often used, of course as the "white" area in a
|
// black (0 alpha, and then 0 RGB). They are often used, of course as the "white" area in a
|
||||||
// barcode image. Force any such pixel to be white:
|
// barcode image. Force any such pixel to be white:
|
||||||
int[] buffer = new int[width];
|
if (image.getAlphaRaster() != null) {
|
||||||
for (int y = top; y < top + height; y++) {
|
int[] buffer = new int[width];
|
||||||
image.getRGB(left, y, width, 1, buffer, 0, sourceWidth);
|
for (int y = top; y < top + height; y++) {
|
||||||
boolean rowChanged = false;
|
image.getRGB(left, y, width, 1, buffer, 0, sourceWidth);
|
||||||
for (int x = 0; x < width; x++) {
|
boolean rowChanged = false;
|
||||||
if ((buffer[x] & 0xFF000000) == 0) {
|
for (int x = 0; x < width; x++) {
|
||||||
buffer[x] = 0xFFFFFFFF; // = white
|
if ((buffer[x] & 0xFF000000) == 0) {
|
||||||
rowChanged = true;
|
buffer[x] = 0xFFFFFFFF; // = white
|
||||||
|
rowChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (rowChanged) {
|
||||||
|
image.setRGB(left, y, width, 1, buffer, 0, sourceWidth);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (rowChanged) {
|
|
||||||
image.setRGB(left, y, width, 1, buffer, 0, sourceWidth);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue