網路城邦
上一篇 回創作列表 下一篇   字體:
夏肇毅知識運算網-如何調整Android 裡Camera Preview 在銀幕的輸出大小
2016/04/16 00:06:49瀏覽1306|回應0|推薦1

[夏肇毅知識運算網 Mark Hsia's Knowledge Computing Web]

在Android Camera test中,我們會看到全銀幕的輸出. 但是我們並不能隨意調整Camera Preview的大小, 只能從getSupportedPreviewSizes的輸出中挑出一個來使用.

2016-04-15

How can we adjust the size of Android Camera Preview on the Screen

In this Android Camera test example, we will see the full screen preview view on the screen.
However, we can not set arbitrary camera size we want. We can only select one of the sizes returned from getSupportedPreviewSizes call, like:

    mSupportedPreviewSizes = mCamera.getParameters().getSupportedPreviewSizes();

And later we set the Preview size with the call setPreviewSize() in the surfaceChanged method:
    parameters.setPreviewSize(mPreviewSize.width, mPreviewSize.height);

我們不能用其他值,否則程式會產生錯誤.
We can not set any other values. Otherwise the app will generate error.


Then, How can we adjust the size of Camera Preview on the Screen if we don't any of the Supported Preview Sizes?

簡單! 我們不能改變 surface View 的輸入, 但我們可以改變 surface View輸出. 直接 surface View調整大小即可.
Simple! Since we cannot change the input of the surface View, but we change the
surface View output. We can adjust  the size of the surface View to any value as we wish.


Reference:
josnidhin/Android-Camera-Example

( 知識學習隨堂筆記 )
回應 推薦文章 列印 加入我的文摘
上一篇 回創作列表 下一篇

引用
引用網址:https://classic-blog.udn.com/article/trackback.jsp?uid=markhsia&aid=53584258