import com.google.zxing.qrcode.encoder.Encoder;
import com.google.zxing.qrcode.encoder.QRCode;
-import org.hedgecode.chess.ChessQRCodeConstants;
import org.hedgecode.chess.img.ImageFormat;
/**
private static final int DEF_QUIET_ZONE_SIZE = 4;
private static final int DEF_QRCODE_BIT_SIZE = 250;
+ private static final int MIN_QRCODE_BIT_SIZE = 50;
private static final ErrorCorrectionLevel DEF_ERR_CORR_LEVEL = ErrorCorrectionLevel.H; // todo: Q
private static ChessQRCodeWriter _instance = new ChessQRCodeWriter();
- private ChessQRCodeWriter() {
+ protected ChessQRCodeWriter() {
}
public void write(ChessQRCodeMode mode, String contents, ImageFormat format, String qrCodeFilePath)
);
}
- private BitMatrix encode(
+ protected BitMatrix encode(
ChessQRCodeMode mode,
String contents,
int width, int height,
);
}
- if (width < 0 || height < 0) { // todo
+ if (Math.min(width, height) < MIN_QRCODE_BIT_SIZE) { // todo: check for Version
throw new ChessQRCodeException(
ChessQRCodeException.Type.WRITE, "write.qrcode.size.incorrect"
);
}
+ String qrCodeContents = mode.name().concat(contents);
+
int quietZone = DEF_QUIET_ZONE_SIZE;
ErrorCorrectionLevel errorCorrectionLevel = DEF_ERR_CORR_LEVEL;
}
hints = newHints;
- String qrCodeText = mode.name().concat(contents);
-
QRCode qrCode;
try {
qrCode = Encoder.encode(
- qrCodeText, errorCorrectionLevel, hints
+ qrCodeContents, errorCorrectionLevel, hints
);
} catch (WriterException e) {
throw new ChessQRCodeException(
ChessQRCodeMode.FEN,
"rnbqkbnr/ppp1pppp/8/3p4/4P3/8/PPPP1PPP/RNBQKBNR w KQkq d6 0 2",
ImageFormat.PNG,
- "./MyQRCode.png"
+ "./qrcode.png"
);
/*
ChessQRCodeWriter.getInstance().write(
"11.Bf4 b5 12.a4 Bb7 13.Re1 Nd5 14.Bg3 Kc8 15.axb5 cxb5 16.Qd3 Bc6 \n" +
"17.Bf5 exf5 18.Rxe7 Bxe7 19.c4 1-0",
ImageFormat.PNG,
- "./MyQRCode.png"
+ "./qrcode.png"
);
*/
} catch (ChessQRCodeException e) {