resize - Android: resizing a surface from a surfaceview -


i using tutorial camera2 api android , 1 of steps resize textureview's surface acceptable format doing following:

 surfacetexture surfacetexture = mtextureview.getsurfacetexture();  surfacetecture.setdefaultbuffersize(mpreviewsize.getwidth(), mpreviewsize.getheight();  surface previewsurface = new surface(surfacetexture);  previewbuilder = cd.createcapturerequest(cameradevice.template_preview);  previewbuilder.addtarget(previewsurface); 

so mpreviewsize variable of type size , determined beforehand cycles through acceptable formats , selects optimal 1 according screen size. problem i'm using surfaceview , i'm trying resize surface object in surfaceview tried didn't work:

            surfaceholder sh= gamesurface.getholder();             sh.setfixedsize(mpreviewsize.getwidth(), mpreviewsize.getheight());             surface sur = sh.getsurface();             previewbuilder = cd.createcapturerequest(cameradevice.template_preview);             previewbuilder.addtarget(sur); 

so in debug mode see mpreviewsize correct (as in set acceptable format) error saying i'm trying use unacceptable format size, shows size , it's not same mpreviewsize means resizing isn't working. ideas?

you need wait receive surfacechanged callback surfaceview, before trying use surface create camera capture session.

setfixedsize doesn't take effect immediately.


Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -