可变画布的更改未反映在最终位图图像中

时间:2019-06-03 02:47:03

标签: android android-canvas

我看不到对位图所做的更改。任何帮助将不胜感激。

//Get the bitmap
Bitmap originalBitMap =  MediaStore.Images.Media.getBitmap(getContext().getContentResolver(), uri);
Bitmap mutuableBitMap = originalBitMap.copy(Bitmap.Config.ARGB_8888, true);

//ZXing
MultiFormatWriter formatWriter = new MultiFormatWriter();
try {
        BitMatrix bitMatrix = formatWriter.encode("Hello World", BarcodeFormat.QR_CODE, 200, 200);
        BarcodeEncoder barcodeEncoder = new BarcodeEncoder();
        Bitmap bMapQRCode = barcodeEncoder.createBitmap(bitMatrix);

        Canvas canvas = new Canvas(mutuableBitMap);
        canvas.drawBitmap(bMapQRCode, mutuableBitMap.getWidth() / 4, 250, new Paint());


    } catch (WriterException e) {
        e.printStackTrace();
    }

//Now I compress the bitmap
mutuableBitMap.compress(Bitmap.CompressFormat.valueOf(extension.toUpperCase()), 90, new FileOutputStream(tempFile));

//And  finally set the bitmap to ImageView
imgPicture.setImageBitmap(mutuableBitMap);

在上述之后,图像视图似乎没有对位图所做的更改。当我调试图像时似乎有更改,但是当我将它们设置为Imageview时。我看不到它。任何帮助将不胜感激。

0 个答案:

没有答案