mirror of
https://github.com/octoleo/plantuml.git
synced 2024-12-22 10:59:01 +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;
|
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>
|
* <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) {
|
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() {
|
public String toString() {
|
||||||
|
@ -56,18 +56,20 @@ public class FlashCodeUtilsZxing implements FlashCodeUtils {
|
|||||||
if (USE_FLASH == false) {
|
if (USE_FLASH == false) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
synchronized (FlashCodeUtilsZxing.class) {
|
||||||
final QRCodeWriter writer = new QRCodeWriter();
|
try {
|
||||||
final Hashtable hints = new Hashtable();
|
final QRCodeWriter writer = new QRCodeWriter();
|
||||||
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
|
final Hashtable hints = new Hashtable();
|
||||||
hints.put(EncodeHintType.CHARACTER_SET, "UTF8");
|
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
|
||||||
final int multiple = 1;
|
hints.put(EncodeHintType.CHARACTER_SET, "UTF8");
|
||||||
final BitMatrix bit = writer.encode(s, BarcodeFormat.QR_CODE, multiple, hints);
|
final int multiple = 1;
|
||||||
return MatrixToImageWriter.toBufferedImage(bit, fore.getRGB() | 0xFF000000, back.getRGB() | 0xFF000000);
|
final BitMatrix bit = writer.encode(s, BarcodeFormat.QR_CODE, multiple, hints);
|
||||||
} catch (WriterException e) {
|
return MatrixToImageWriter.toBufferedImage(bit, fore.getRGB() | 0xFF000000, back.getRGB() | 0xFF000000);
|
||||||
Log.debug("Cannot create qrcode " + e);
|
} catch (WriterException e) {
|
||||||
// e.printStackTrace();
|
Log.debug("Cannot create qrcode " + e);
|
||||||
return null;
|
// e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user