In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
< 0) mRect.left = 0; if (mRect.right < 0) mRect.right = 0; if (mRect.top < 0) mRect.top = 0; if (mRect.bottom < 0) mRect.bottom = 0; int cut_width = Math.abs(mRect.left - mRect.right); int cut_height = Math.abs(mRect.top - mRect.bottom); if (cut_width >0 & & cut_height > 0) {Bitmap cutBitmap = Bitmap.createBitmap (bitmap, mRect.left, mRect.top, cut_width, cut_height);}
It should be noted that when calling the system screenshot feature, if the phone has NavigationBar (virtual navigation bar), the value of windowHeight does not include the height of NavigationBar. If it is not adjusted, it will cause the screenshot to be compressed. How to get the true height of the screen, you can refer to Android how to determine whether the NavigationBar is displayed (get the true height of the screen).
In addition, NavigationBar will also cause a border in the result of the screenshot, and the color of the frame is transparent. This is due to the rowPaddingscreenshot 0 in the code in step 2. The screenshot is shown below:
Result of screenshot of using system with NavigationBar
So if we want to save or crop the results of the screenshot, we must remove the border and find out the real content area, that is, the content between * opaque pixels and * one opaque pixel. Then we can crop the resulting area in step 3. The code is as follows:
Int [] pixel=new int [width]; bitmap.getPixels (pixel,0,width, 0Widthjee 1); int leftPadding=0;int rightPadding=width;for (int ionomy 0 / 0 / 0 / 10 / 10 / 2) {if (pixel [I]! = 0) {rightPadding=i; break;}} bitmap=Bitmap.createBitmap (bitmap,leftPadding, 0, rightPadding-leftPadding, height)
The screenshot after processing is as follows:
Get the content part of the screenshot result
You might think that since rowPaddingwidth 0 caused the border to appear, and the border is only on the right, why not just truncate the width of the rowPadding on the right? In fact, it is because if you do not adjust the windowHeight, there will be a box on the left, so the above method is used.
This is the end of the introduction on "how to achieve screenshots of rectangular areas in Android". Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
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.