这是qr生成器方法。我试图在android中生成一个二维码,下面的代码生成一个非常小的图像。如果我尝试将其大小从500增加到700它终止。如何在java中增加该图像的大小。
全局变量
Bitmap bitmap ;
public final static int QRcodeWidth = 500 ;
private void UploadFile(final String orderId){
try{
bitmap = TextToImageEncode(orderId);
FirebaseStorage storage = FirebaseStorage.getInstance();
final StorageReference mStorage = storage.getReferenceFromUrl("gs://samyatadb.appspot.com/qrcode");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
//==============storing image to storage=====================//
byte[] data = baos.toByteArray();
UploadTask uploadTask = mStorage.child(user_id).child(String.valueOf(orderId)).putBytes(data);
uploadTask.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
}
}).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
downloadURL = taskSnapshot.getDownloadUrl();
Log.e("auth", "onSuccess: "+downloadURL);
String imgpath = downloadURL.toString();
Map<String, Object> data = new HashMap<>();
DocumentReference newqr = db.collection("Orders").document(orderId);
data.put("ImageQR",imgpath);
newqr.set(data, SetOptions.merge());
Map<String, Object> data1 = new HashMap<>();
DocumentReference newqr1 = db.collection("Orderers").document(user_id).collection("OpenOrders").document(orderId);
data1.put("ImageQR",imgpath);
newqr1.set(data1, SetOptions.merge());
pd.dismiss();
Toast.makeText(Qrcode.this,"Your Order was Completed...",Toast.LENGTH_LONG).show();
taskSnapshot.getMetadata();
}
});
imageView.setImageBitmap(bitmap);
}
catch (WriterException e){
e.printStackTrace();
}
}
xml代码
<ImageView
android:id="@+id/imageView"
android:layout_width="140dp"
android:layout_height="140dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="15dp"
android:background="@drawable/placeholder"
android:scaleType="centerCrop"
android:visibility="visible"
tools:ignore="ContentDescription" />