camera preview on android - strange lines on 1.5 v

2019-07-27 00:38发布

问题:

I am developing the camera module for an android application. In main application when user clicks on 'take picture' button, new view with SurfaceView control is opened and camera preview is shown. When users click on dpad center, camera takes picture and save it to the disc. Pretty simple and straightforward.

Everything works fine on my device - HTC Tattoo, minsdkversion 1.6

...but when I tested application on HTC Hero minsdkversion 1.5, when camera preview is shown,some strange lines occur.

Anyone has idea what is going on?

p.s. altough preview is crashed, taking of pictures works fine

here is the picturealt text http://img163.imageshack.us/img163/4088/camerademo.jpg:

Thanx Marko

回答1:

Apparently this is hero bug, in function surfaceChanged switch width and height parameters:

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) 
    { 
        parameters.setPreviewSize(h, w); //instead of w,h
    }