ocrsearch的横屏转竖屏的解决方案

Posted ぶ会编程的狗子进阶史

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ocrsearch的横屏转竖屏的解决方案相关的知识,希望对你有一定的参考价值。


//这是其中解决预览图的一部分(坑了好久的)
@Override public void onPreviewFrame(byte[] data, Camera camera) { Size previewSize = camera.getParameters().getPreviewSize(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] rawImage = null; // Decode image from the retrieved buffer to JPEG YuvImage yuv = new YuvImage(data, ImageFormat.NV21, previewSize.width, previewSize.height, null); yuv.compressToJpeg(new Rect(0, 0, previewSize.width, previewSize.height), YOUR_JPEG_COMPRESSION, baos); rawImage = baos.toByteArray(); // This is the same image as the preview but in JPEG and not rotated Bitmap bitmap = BitmapFactory.decodeByteArray(rawImage, 0, rawImage.length); ByteArrayOutputStream rotatedStream = new ByteArrayOutputStream(); // Rotate the Bitmap Matrix matrix = new Matrix(); matrix.postRotate(YOUR_DEFAULT_ROTATION); // We rotate the same Bitmap bitmap = Bitmap.createBitmap(bitmap, 0, 0, previewSize.width, previewSize.height, matrix, false); // We dump the rotated Bitmap to the stream bitmap.compress(CompressFormat.JPEG, YOUR_JPEG_COMPRESSION, rotatedStream); rawImage = rotatedStream.toByteArray(); // Do something we this byte array }

  转自:http://stackoverflow.com/questions/15131663/how-to-change-orientation-of-captured-byte-frames-through-onpreviewframe-callb

以上是关于ocrsearch的横屏转竖屏的解决方案的主要内容,如果未能解决你的问题,请参考以下文章

quick-cocos2d 设置横屏

移动端如何让页面强制横屏

横屏页面present一个竖屏VC

横屏页面present一个竖屏VC

横屏页面present一个竖屏VC

android 转屏触发了两次onConfigurationChanged()方法,很诡异,不知道有人遇到过吗?