In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Today, I will talk to you about how to use SurfaceView to display Camera images in Android, many people may not know much about it. In order to make you understand better, the editor summed up the following content for you. I hope you can get something according to this article.
Full screen mode
Here first directly say the result, want to full screen display is two sentences, directly in the canvas drawing when drawing a target box size can be.
RectF rectF=new RectF (0,0, canvas.getWidth (), canvas.getHeight ()); canvas.drawBitmap (cacheBitmap, null, rectF, null)
Mental process
Those who directly want to achieve the above results do not have to look at this, here is mainly I recorded the process of implementation, wasted more than an hour.
At first, if I thought that the full screen was displayed, I would directly get the width and height of the screen, and redefine the width and height of the picture in the method of generating the picture. Then I first defined the two parameters of the width and height of the screen.
Then add a method to get the width and height of the screen in the constructor
We passed the width and height of the canvas in the parameter of the method for generating the nv21ToBitmap of the image.
And then the result of the run directly becomes like this.
From our output log, the width and height of PreviewSize are not the same as those of canvas, as shown in the following figure.
So I tried the width and height output upside down, and the result was still the same, so this method was abandoned.
Later, I looked for all kinds of materials on the Internet, and most of them talked about the method of setting up setPreviewSize, as shown in the figure.
And the following.
And I thought of this.
Tried several, basically not open Camera directly after the white screen, is this zoom ratio is also strange, everything is not the result I want, once speechless.
Finally, I was thinking, even if my picture has been generated, whether it is the canvas size of the painting, the initial idea should be wrong, so all kinds of search, and finally found an article, as follows
After reading the above, do you have any further understanding of how to use SurfaceView to display Camera images in Android? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.