Problem description
Video capture using V4L2, capturing video data with a resolution of (4:3) and previewing the image on an Android device using the Canvas,drawbitmap method
Android Device resolution is 540x960 (9:16), so the full screen preview when the image is stretched, how to solve this problem?
No train of thought Ah, which great God Guide!!
Here is the code of the picture, the gods help to see
Public void run () {//Get screen information displaymetrics dm = new displaymetrics (); Getwindowmanager (). Getdefaultdisplay (). Getmetrics (DM); int screenwidth = dm.widthpixels;int screenHeigh = dm.heightPixels; LOG.I (tag, "------------into DrawImage---------------"); LOG.I (tag, "Current screen width:" + screenWidth + ", current screen height is: " + screenheigh); LOG.I (tag, "into DRAWIMAGE USB camera current status is" + cameraexists ";while (cameraexists) {// Rect = new rect (0, 0, SCREENWIDTH/2, SCREENHEIGH/2);rectF = new RECTF (0, 0, screenwidth, screenheigh), //w and H are screen width and height, which is the width and height of the image you want to display  //LOG.I (tag, "------------USB camera start Drawing---------------");if (bmp != null) {canvas canvas = holder.lockcanvas ();if (canvas != null) {//canvas.drawBitmap (BMP, null, rect, null); canVas.drawbitmap (Bmp, null, rectf, null); Holder.unlockcanvasandpost (canvas);}} LOG.I (tag, "thread exits DrawImage");}
Solutions 1
Canvas.drawbitmap (srcbitmap, matrix, NULL); Scale with the matrix and try it.
Android with bitmap drawing preview, video image resolution is 4:3, phone resolution is 540x960 (9:16), image is stretched how to do?