mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Speedup for black/white image rendering
git-svn-id: https://zxing.googlecode.com/svn/trunk@2365 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
6ce63cc1a2
commit
ba5dd02852
|
@ -16,6 +16,8 @@
|
|||
|
||||
package com.google.zxing.client.j2se;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
/**
|
||||
* Encapsulates custom configuration used in methods of {@link MatrixToImageWriter}.
|
||||
*/
|
||||
|
@ -52,4 +54,9 @@ public final class MatrixToImageConfig {
|
|||
return offColor;
|
||||
}
|
||||
|
||||
int getBufferedImageColorModel() {
|
||||
// Use faster BINARY if colors match default
|
||||
return onColor == BLACK && offColor == WHITE ? BufferedImage.TYPE_BYTE_BINARY : BufferedImage.TYPE_INT_RGB;
|
||||
}
|
||||
|
||||
}
|
|
@ -51,7 +51,7 @@ public final class MatrixToImageWriter {
|
|||
public static BufferedImage toBufferedImage(BitMatrix matrix, MatrixToImageConfig config) {
|
||||
int width = matrix.getWidth();
|
||||
int height = matrix.getHeight();
|
||||
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||
BufferedImage image = new BufferedImage(width, height, config.getBufferedImageColorModel());
|
||||
int onColor = config.getPixelOnColor();
|
||||
int offColor = config.getPixelOffColor();
|
||||
for (int x = 0; x < width; x++) {
|
||||
|
|
Loading…
Reference in a new issue