I am trying to read the QR Code using Zxing library. When I did Script Evaluation in Script code, the result was successfully came out. But when I deployed and tested in Browser, the result was not came out and it was shown Nothing noticeable happened yet... But it surely will come! My code is as the following:
import com.google.zxing.BinaryBitmap
import com.google.zxing.EncodeHintType
import com.google.zxing.LuminanceSource
import com.google.zxing.ReaderException
import com.google.zxing.Result
import com.google.zxing.client.j2se.BufferedImageLuminanceSource
import com.google.zxing.common.HybridBinarizer
import com.google.zxing.qrcode.QRCodeReader
import com.google.zxing.qrcode.encoder.Encoder
import java.awt.image.BufferedImage
import javax.imageio.ImageIOString filename = "C:\\Users\\Min\\Desktop\\qrCode.png";
BufferedImage image = ImageIO.read(new FileInputStream(filename));LuminanceSource source = new BufferedImageLuminanceSource(image);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));def charset = "UTF-8" //"ISO-8859-1"
def hints = new Hashtable<EncodeHintType, String>([(EncodeHintType.CHARACTER_SET): charset])QRCodeReader reader = new QRCodeReader();
Result result;
try {
result = reader.decode(bitmap, hints);
} catch (ReaderException e) {
e.message;
}return result.toString();
Any comments and suggestions would be appreciated. Thank you!