mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Use ARGB when on/off colors are not opaque
This commit is contained in:
parent
17da7bbe4c
commit
15b4dedb98
|
@ -55,8 +55,20 @@ public final class MatrixToImageConfig {
|
|||
}
|
||||
|
||||
int getBufferedImageColorModel() {
|
||||
// Use faster BINARY if colors match default
|
||||
return onColor == BLACK && offColor == WHITE ? BufferedImage.TYPE_BYTE_BINARY : BufferedImage.TYPE_INT_ARGB;
|
||||
if (onColor == BLACK && offColor == WHITE) {
|
||||
// Use faster BINARY if colors match default
|
||||
return BufferedImage.TYPE_BYTE_BINARY;
|
||||
}
|
||||
if (hasTransparency(onColor) || hasTransparency(offColor)) {
|
||||
// Use ARGB representation if colors specify non-opaque alpha
|
||||
return BufferedImage.TYPE_INT_ARGB;
|
||||
}
|
||||
// Default otherwise to RGB representation with ignored alpha channel
|
||||
return BufferedImage.TYPE_INT_RGB;
|
||||
}
|
||||
|
||||
private static boolean hasTransparency(int argb) {
|
||||
return (argb & 0xFF000000) != 0xFF000000;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue