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
Post a Comment