草庐IT

getBitmap

全部标签

android - TextureView getBitmap() 忽略 setTransform

我正在为CameraPreview使用TextureView。由于显示比例和预览比例之间的差异,我在onSurfaceTextureAvailable()中使用textureView.setTransform(matrix)来缩放预览。当我需要textureView的屏幕截图时,我使用textureView.getBitmap(),但在某些型号的智能手机中,getBitmap()会忽略预览的缩放。为什么会这样? 最佳答案 当我需要在显示相机预览之前对其进行后处理时,我发现了同样的问题。看起来原始相机捕获是在getBitmap()中产

java - API 29 java android 中不推荐使用 getBitmap

我正在开发一个android应用程序,我希望用户从图库中选择一个图像。但我已经看到getBitmap在API29上已被弃用我试过ImageDecoder.decodeBitmap(Imagedecoder.createSource())但它使应用程序崩溃if(requestCode==GALLERY){if(data!=null){UricontentURI=data.getData();try{if(contentURI!=null){bitmap=ImageDecoder.decodeBitmap(ImageDecoder.createSource(getContentResolv

Android TextureView.getBitmap() 很慢

我有一个Android应用程序,其相机配置为将其预览发送到TextureView。在我的SurfaceTextureListener的onSurfaceTextureUpdated方法中,我使用以下方法将预览帧作为位图拉出:textureView.getBitmap(existingBitmap);它工作正常,但需要很长时间(对于720x1280图像大约需要200-250毫秒)。看起来这应该要快得多。关于如何提高此操作的性能有什么想法吗? 最佳答案 使用此命令获取预览会从预览生成新的位图,这就是应用程序花费这么长时间的原因。我的建议

android - MediaStore.Images.Media.getBitmap 和内存不足错误

我的代码代码是:publicBitmaploadPhoto(Uriuri){Bitmapscaled=null;try{scalled=Bitmap.createBitmap(MediaStore.Images.Media.getBitmap(getContentResolver(),uri),0,0,90,90);if(scaled==null){returnnull;}}catch(Exceptione){}returnscaled;}在此之后。我在ImageView中显示缩放。每张图片都来自设备相机。每次显示相机中的三张照片后,我都会收到错误消息:内存不足。如何解决?