QR 바코드로 앱을 만들고 있습니다. 바코드가 올바르게로드되지만 어떻게 든 탭을 클릭하거나 메뉴를 클릭하면 약 3 ~ 5 초 후에 느리게 비트가로드됩니다.Zxing을 사용하여 QR 코드를 생성하는 시간을 단축하는 방법
더 빨라질 수 있습니까? 또는 페이지가 오래 걸리는 것이 정상입니까? 다른 부분 적재는 1 초 이하로 소요됩니다. 앱도 오프라인이므로 인터넷 연결이 필요하지 않습니다.
ImageView imageViewBarcode = (ImageView)findViewById(R.id.imageViewBarcode);
try {
bitmap = TextToImageEncode(barcode_user);
imageViewBarcode.setImageBitmap(bitmap);
} catch (WriterException e) {
e.printStackTrace();
}
위의 그 코드에서 onCreate 안에 넣어 :
여기 내 코드는 QR 바코드를 생성합니다. 따라서 페이지가로드되면 바코드가 생성됩니다. 여기
기능은 바코드Bitmap TextToImageEncode(String Value) throws WriterException {
BitMatrix bitMatrix;
try {
bitMatrix = new MultiFormatWriter().encode(
Value,
BarcodeFormat.DATA_MATRIX.QR_CODE,
QRcodeWidth, QRcodeWidth, null
);
} catch (IllegalArgumentException Illegalargumentexception) {
return null;
}
int bitMatrixWidth = bitMatrix.getWidth();
int bitMatrixHeight = bitMatrix.getHeight();
int[] pixels = new int[bitMatrixWidth * bitMatrixHeight];
for (int y = 0; y < bitMatrixHeight; y++) {
int offset = y * bitMatrixWidth;
for (int x = 0; x < bitMatrixWidth; x++) {
pixels[offset + x] = bitMatrix.get(x, y) ?
getResources().getColor(R.color.colorBlack):getResources().getColor(R.color.colorWhite);
}
}
Bitmap bitmap = Bitmap.createBitmap(bitMatrixWidth, bitMatrixHeight, Bitmap.Config.ARGB_4444);
bitmap.setPixels(pixels, 0, 500, 0, 0, bitMatrixWidth, bitMatrixHeight);
return bitmap;
}
나는 그것을 성취하는 방법을 잘 모른다. 코드 스 니펫 업데이트를 제공 하시겠습니까? – Gabriel
당신이 이해하지 못했던 것을 설명해 주시겠습니까? – Okas
고마워요 @ 오카! 나는 그것을 시도 할 것이다, 늦은 응답에 대해 유감스럽게 생각한다. 나는 그것이 다시 작동한다면 게시 할 것이다. – Gabriel