canvas教程

android二维码扫描(zxing使用小结)(2)

字号+ 作者:H5之家 来源:H5之家 2015-10-27 08:33 我要评论( )

/** * Sets the camera up to take preview images which are used for both preview * and decoding. We detect the preview format here so that * buildLuminanceSource() can build an appropriate LuminanceSo

/** * Sets the camera up to take preview images which are used for both preview * and decoding. We detect the preview format here so that * buildLuminanceSource() can build an appropriate LuminanceSource subclass. * In the future we may want to force YUV420SP as it's the smallest, and the * planar Y can be used for barcode scanning without a copy in some cases. */ void setDesiredCameraParameters(Camera camera) { // Camera.Parameters parameters = camera.getParameters(); // Log.d(TAG, "Setting preview size: " + cameraResolution); // parameters.setPreviewSize(cameraResolution.x, cameraResolution.y); // setFlash(parameters); // setZoom(parameters); // //setSharpness(parameters); // //modify here // camera.setDisplayOrientation(90); // camera.setParameters(parameters); Camera.Parameters parameters = camera.getParameters(); List<Size> supportedPreviewSizes = parameters .getSupportedPreviewSizes(); int position = 0; if (supportedPreviewSizes.size() > 2) { position = supportedPreviewSizes.size() / 2 + 1;// supportedPreviewSizes.get(); } else { position = supportedPreviewSizes.size() / 2; } int width = supportedPreviewSizes.get(position).width; int height = supportedPreviewSizes.get(position).height; Log.d(TAG, "Setting preview size: " + cameraResolution); camera.setDisplayOrientation(90); cameraResolution.x = width; cameraResolution.y = height; parameters.setPreviewSize(width, height); setFlash(parameters); setZoom(parameters); // setSharpness(parameters); camera.setParameters(parameters); }

最后大喊一声:开源万岁!!!


转载请注明原文链接。 文中有不妥或者错误的地方还望指出,以免误人子弟。 再次感谢您耐心的读完本篇文章。

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • Canvas与ValueAnimator

    Canvas与ValueAnimator

    2017-04-28 18:00

  • 21天学习android开发教程之SurfaceView与多线程的混搭

    21天学习android开发教程之SurfaceView与多线程的混搭

    2017-04-27 12:00

  • PolygonDrawingUtil

    PolygonDrawingUtil

    2017-04-26 18:02

  • Android开发基本常识及技巧

    Android开发基本常识及技巧

    2017-04-13 16:02

网友点评
/