Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the combined drawing process of Android Canvas and Bitmap?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "what is the combined drawing process of Android Canvas and Bitmap". In daily operation, I believe that many people have doubts about the combined drawing process of Android Canvas and Bitmap. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "what is the combined drawing process of Android Canvas and Bitmap?" Next, please follow the editor to study!

Rect/RectF

A rectangular class that stores four values: left, top, right, and bottom. Can be used to paint directly on the canvas or only to store the size of the object you want to paint. The difference between the Rect and RectF classes is that RectF stores floating-point values, while the Rect class stores integers.

Private static Bitmap createDrawableBitmap (Drawable drawable) {int width = drawable.getIntrinsicWidth (); int height = drawable.getIntrinsicHeight (); if (width reqWidth) {/ / Calculate ratios of height and width to requested height and width final int heightRatio = Math.round ((float) height / (float) reqHeight); final int widthRatio = Math.round ((float) width / (float) reqWidth) / / Choose the smallest ratio as inSampleSize value, this will guarantee / / a final image with both dimensions larger than or equal to the / / requested height and width. InSampleSize = heightRatio < widthRatio? HeightRatio: widthRatio;} return inSampleSize;}

Note: the Bitmap object generated by Bitmap.createBitmap is mutable and can be drawn to Bitmap, while the Bitmap object generated by BitmapFactory must specify BitmapFactory.Options.inMutable = true, otherwise it is immutable and cannot be drawn to it.

At this point, the study of "what is the combined drawing process of Android Canvas and Bitmap" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report