|
|
Subject: Issue 1154 in zxing: MatrixToImageWriter : resize image - msg#00157
Status: New
Owner: ----
New issue 1154 by pgoiff...@xxxxxxxxx: MatrixToImageWriter : resize image
http://code.google.com/p/zxing/issues/detail?id=1154
Add a method to resize the image.
For exemple, I want to encode a 75 car url, so I have to use the qr code
mode 4 (33*33 modules, 78 car for binary data with a L ECC). I would pass
to the encoder a size of 33 + 2*4 (4 = quiet zone size), and then use
MatrixToImageWriter to obtain a 600*600px png file.
Here is a piece of code I already use :
BufferedImage imageOrig = MatrixToImageWriter.toBufferedImage(matrix);
BufferedImage imageFinal = new BufferedImage(size,
size,
BufferedImage.TYPE_BYTE_GRAY);
Graphics2D grph = (Graphics2D) imageFinal.getGraphics();
grph.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_OFF);
grph.setRenderingHint(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
grph.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
double scaleFactor = (double) sizeFinalImage / (double) sizeOrigImage;
grph.scale(scaleFactor, scaleFactor);
grph.drawImage(imageOrig, 0, 0, null);
grph.dispose();
Thread at a glance:
Previous Message by Date:
Issue 1153 in zxing: QR Code : utilities to select the correct qr code version
Status: New
Owner: ----
New issue 1153 by pgoiff...@xxxxxxxxx: QR Code : utilities to select the
correct qr code version
http://code.google.com/p/zxing/issues/detail?id=1153
Before encoding a value, it would be nice to have utilities to get :
- the data type (data bits, numeric, alfanumeric, binary, kanji)
- the minimal qr code version to use (modules numbers) to encode the value
considering its type and the ecc the user wants to be applied
- the quiet zone size
For exemple in my code I wrote :
public static int QUIET_ZONE_SIZE = 4;
public static enum QRCodeModesByteCapacityEccL {
Mode1(21, 17),
Mode2(25, 32),
Mode3(29, 53),
Mode4(33, 78),
Mode5(37, 106),
Mode6(41, 134),
Mode7(45, 154),
Mode8(49, 192),
Mode9(53, 230),
Mode10(57, 271),
Mode11(61, 321),
Mode12(65, 367),
Mode13(69, 425),
Mode14(73, 458),
Mode15(77, 520),
Mode16(81, 586),
Mode17(85, 644),
Mode18(89, 718),
Mode19(93, 792),
Mode20(97, 858);
private int modules;
private int capacity;
private QRCodeModesByteCapacityEccL(int modules, int capacity) {
this.modules = modules;
this.capacity = capacity;
}
public int getModulesNb() {
return modules;
}
public int getSize() {
return modules + 2 * QUIET_ZONE_SIZE;
}
public int getCapacity() {
return capacity;
}
public String getLabel(Locale locale) {
// custom implementation
}
}
public static QRCodeModesByteCapacityEccL getModeForLentgh(int length) {
for (QRCodeModesByteCapacityEccL qrMode :
QRCodeModesByteCapacityEccL.values()) {
if (qrMode.getCapacity() >= length) {
return qrMode;
}
}
return null;
}
Previous Message by Thread:
Issue 1153 in zxing: QR Code : utilities to select the correct qr code version
Status: New
Owner: ----
New issue 1153 by pgoiff...@xxxxxxxxx: QR Code : utilities to select the
correct qr code version
http://code.google.com/p/zxing/issues/detail?id=1153
Before encoding a value, it would be nice to have utilities to get :
- the data type (data bits, numeric, alfanumeric, binary, kanji)
- the minimal qr code version to use (modules numbers) to encode the value
considering its type and the ecc the user wants to be applied
- the quiet zone size
For exemple in my code I wrote :
public static int QUIET_ZONE_SIZE = 4;
public static enum QRCodeModesByteCapacityEccL {
Mode1(21, 17),
Mode2(25, 32),
Mode3(29, 53),
Mode4(33, 78),
Mode5(37, 106),
Mode6(41, 134),
Mode7(45, 154),
Mode8(49, 192),
Mode9(53, 230),
Mode10(57, 271),
Mode11(61, 321),
Mode12(65, 367),
Mode13(69, 425),
Mode14(73, 458),
Mode15(77, 520),
Mode16(81, 586),
Mode17(85, 644),
Mode18(89, 718),
Mode19(93, 792),
Mode20(97, 858);
private int modules;
private int capacity;
private QRCodeModesByteCapacityEccL(int modules, int capacity) {
this.modules = modules;
this.capacity = capacity;
}
public int getModulesNb() {
return modules;
}
public int getSize() {
return modules + 2 * QUIET_ZONE_SIZE;
}
public int getCapacity() {
return capacity;
}
public String getLabel(Locale locale) {
// custom implementation
}
}
public static QRCodeModesByteCapacityEccL getModeForLentgh(int length) {
for (QRCodeModesByteCapacityEccL qrMode :
QRCodeModesByteCapacityEccL.values()) {
if (qrMode.getCapacity() >= length) {
return qrMode;
}
}
return null;
}
Next Message by Thread:
Re: Issue 1154 in zxing: MatrixToImageWriter : resize image
Updates:
Status: NotABug
Comment #1 on issue 1154 by srowen: MatrixToImageWriter : resize image
http://code.google.com/p/zxing/issues/detail?id=1154
Hmm, I think there are 100 things you may want to do with the image
afterwards, and that's what the java.awt APIs are for. I can see taking a
size as a parameter in the config though.
|
|