java - How to mirror a rear camera preview? -


i trying preview of rear camera mirrored... mean preview should mirror images vertically; should swap right-to-left front camera... don't need normal preview need th image if it's seen front camera , i'm trying surfacetexture. there knows it? type of appreciated!

this did. converted array of pixels bitmap , flipped it. noticed had rotate image. if need can rotatebitmap method below. rotated before flipping it. since application uses both cameras, first check see if using front facing camera.

public bitmap flip(bitmap d) {     matrix m = new matrix();     m.prescale(-1, 1);     bitmap dst = bitmap.createbitmap(d, 0, 0, d.getwidth(), d.getheight(), m, false);     dst.setdensity(displaymetrics.density_default);     return dst; }  public bitmap rotatebitmap(bitmap source, float angle) {     //rotates bitmap     matrix matrix = new matrix();     matrix.postrotate(angle);     return bitmap.createbitmap(source, 0, 0, source.getwidth(), source.getheight(), matrix, true); } 

so this.

if(orienation == orienation.selfie) {                 bmap = rotatebitmap(bmap, 270);     bmap = flip(bmap); } 

those custom fields used in application. think idea , can cater need.

private camera.picturecallback mpicture = new camera.picturecallback() {     @override     public void onpicturetaken(byte[] data, camera camera) {         bitmap bmap = bitmapfactory.decodebytearray(data, 0, data.length);         if (currentcameraid == camera.camerainfo.camera_facing_front) {             frontfacing = true;         }     } }; 

you can create bitmap in picturecallback. convert pixel array bitmap. if use both cameras in application can check see if used front 1 did in example above.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -