我在那里看过很多帖子?但我找不到正确答案.
我尝试做一些事情:
@OverrIDepublic voID onPictureTaken(byte[] paramArrayOfByte,Camera paramCamera) { try { Bitmap bitmap = BitmapFactory.decodeByteArray(paramArrayOfByte,paramArrayOfByte.length); int wIDth = bitmap.getWIDth(); int height = bitmap.getHeight(); fileOutputStream os = new ileOutputStream(Singleton.mpushfilePath); Matrix matrix = new Matrix(); matrix.postRotate(90); Bitmap resizedBitmap = Bitmap.createBitmap(bitmap,wIDth,height,matrix,false); resizedBitmap.compress(Bitmap.CompressFormat.JPEG,95,os); os.close(); ...
有没有办法旋转图片,而不使用BitmapFactory?我想要旋转图片而不会损失质量!最佳答案也许您可以根据需要使用Camera.setdisplayOrIEntation拍摄已旋转的照片?检查Android camera rotate.此外,调查Camera.Parameters.setRotation().其中一种技术应该适合你.
否则你的代码看起来很好,除了在Bitmap.compress上使用参数95,你需要使用100进行无损压缩.
为避免内存不足异常,请使用Camera.Parameters.setPictureSize()获取较低分辨率的图片(例如3Mpx).即你真的需要8Mpx照片吗?确保使用Camera.Parameters.getSupportedPictureSizes()来确定设备支持的大小.
总结以上是内存溢出为你收集整理的android – 如何在没有内存异常的情况下从“onPictureTaken”旋转图片?全部内容,希望文章能够帮你解决android – 如何在没有内存异常的情况下从“onPictureTaken”旋转图片?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)