Android with bitmap drawing preview, video image resolution is 4:3, phone resolution is 540x960 (9:16), image is stretched how to do?

Source: Internet
Author: User

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?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.