gpt4 book ai didi

android - 设置图像位图在 android marshmallow 中不起作用

转载 作者:行者123 更新时间:2023-11-30 00:48:03 24 4
gpt4 key购买 nike

当我使用设置图像 Bitmap 方法在 ImageView 中设置 Bitmap 时,它在 android kitkat 中工作正常> 但在 Marshmallow 中它不起作用,我尝试通过复制图像 Bitmap 但没有成功,请帮助我解决这个问题,我们将不胜感激

 PictureCallback cameraPictureCallbackJpeg = new PictureCallback() 
{
@Override
public void onPictureTaken(byte[] data, Camera camera)
{
// TODO Auto-generated method stub
Bitmap cameraBitmap = BitmapFactory.decodeByteArray(data, 0, data.length);

int wid = cameraBitmap.getWidth();
int hgt = cameraBitmap.getHeight();

// Toast.makeText(getApplicationContext(), wid+""+hgt, Toast.LENGTH_SHORT).show();
newImage = Bitmap.createBitmap
(wid, hgt, Bitmap.Config.ARGB_8888);

Canvas canvas = new Canvas(newImage);

canvas.drawBitmap(cameraBitmap, 0f, 0f, null);

Drawable drawable = getResources().getDrawable(R.drawable.mark3);
drawable.setBounds(20, 30, drawable.getIntrinsicWidth()+20, drawable.getIntrinsicHeight()+30);
drawable.draw(canvas);


lastimage = newImage.copy(newImage.getConfig(), true);


if (newImage != null && !newImage.isRecycled()) {
newImage.recycle();
newImage = null;
}

imageview_visinon.setVisibility(View.VISIBLE);
imageview_visinon.setImageBitmap(newImage);





linear_capture.setVisibility(View.GONE);

linear_okcancelpic.setVisibility(View.VISIBLE);

}
};

最佳答案

有时位图太大。这就是为什么 imageview 变成空白的原因!我想在这里你可以找到你需要的东西:http://developer.android.com/training/displaying-bitmaps/load-bitmap.html

关于android - 设置图像位图在 android marshmallow 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41502495/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com