mirror of
https://github.com/octoleo/plantuml.git
synced 2024-10-31 19:22:31 +00:00
Try to avoid memory issues
This commit is contained in:
parent
d9552dfc34
commit
51ee3fb7c7
@ -16,6 +16,8 @@
|
||||
|
||||
package ext.plantuml.com.google.zxing.common;
|
||||
|
||||
import ext.plantuml.com.google.zxing.WriterException;
|
||||
|
||||
/**
|
||||
* <p>A simple, fast array of bits, represented compactly by an array of ints internally.</p>
|
||||
*
|
||||
@ -230,7 +232,10 @@ public final class BitArray {
|
||||
}
|
||||
|
||||
private static int[] makeArray(int size) {
|
||||
return new int[(size + 31) >> 5];
|
||||
final int tmp = (size + 31) >> 5;
|
||||
if (tmp>1000)
|
||||
throw new IllegalArgumentException("Memory error");
|
||||
return new int[tmp];
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
@ -56,18 +56,20 @@ public class FlashCodeUtilsZxing implements FlashCodeUtils {
|
||||
if (USE_FLASH == false) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
final QRCodeWriter writer = new QRCodeWriter();
|
||||
final Hashtable hints = new Hashtable();
|
||||
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
|
||||
hints.put(EncodeHintType.CHARACTER_SET, "UTF8");
|
||||
final int multiple = 1;
|
||||
final BitMatrix bit = writer.encode(s, BarcodeFormat.QR_CODE, multiple, hints);
|
||||
return MatrixToImageWriter.toBufferedImage(bit, fore.getRGB() | 0xFF000000, back.getRGB() | 0xFF000000);
|
||||
} catch (WriterException e) {
|
||||
Log.debug("Cannot create qrcode " + e);
|
||||
// e.printStackTrace();
|
||||
return null;
|
||||
synchronized (FlashCodeUtilsZxing.class) {
|
||||
try {
|
||||
final QRCodeWriter writer = new QRCodeWriter();
|
||||
final Hashtable hints = new Hashtable();
|
||||
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
|
||||
hints.put(EncodeHintType.CHARACTER_SET, "UTF8");
|
||||
final int multiple = 1;
|
||||
final BitMatrix bit = writer.encode(s, BarcodeFormat.QR_CODE, multiple, hints);
|
||||
return MatrixToImageWriter.toBufferedImage(bit, fore.getRGB() | 0xFF000000, back.getRGB() | 0xFF000000);
|
||||
} catch (WriterException e) {
|
||||
Log.debug("Cannot create qrcode " + e);
|
||||
// e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user