CN116107743A - Bitmap scaling rendering optimization method based on object dynamic migration - Google Patents
Bitmap scaling rendering optimization method based on object dynamic migration Download PDFInfo
- Publication number
- CN116107743A CN116107743A CN202310038619.0A CN202310038619A CN116107743A CN 116107743 A CN116107743 A CN 116107743A CN 202310038619 A CN202310038619 A CN 202310038619A CN 116107743 A CN116107743 A CN 116107743A
- Authority
- CN
- China
- Prior art keywords
- bitmap
- bitmap object
- scaling
- memory space
- proxy
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000009877 rendering Methods 0.000 title claims abstract description 52
- 238000000034 method Methods 0.000 title claims abstract description 43
- 238000005457 optimization Methods 0.000 title claims abstract description 16
- 230000005012 migration Effects 0.000 title claims abstract description 10
- 238000013508 migration Methods 0.000 title claims abstract description 10
- 230000008569 process Effects 0.000 claims abstract description 11
- 238000012545 processing Methods 0.000 claims description 6
- 230000006378 damage Effects 0.000 abstract description 3
- 239000012634 fragment Substances 0.000 abstract description 2
- 238000004064 recycling Methods 0.000 abstract description 2
- 239000000872 buffer Substances 0.000 description 2
- 239000011159 matrix material Substances 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 238000011282 treatment Methods 0.000 description 1
- 239000002699 waste material Substances 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5011—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
- G06F9/5016—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/29—Geographical information databases
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5011—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
- G06F9/5022—Mechanisms to release resources
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T15/00—3D [Three Dimensional] image rendering
- G06T15/005—General purpose rendering architectures
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T17/00—Three dimensional [3D] modelling, e.g. data description of 3D objects
- G06T17/05—Geographic models
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T3/00—Geometric image transformations in the plane of the image
- G06T3/40—Scaling of whole images or parts thereof, e.g. expanding or contracting
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Software Systems (AREA)
- General Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- Computer Graphics (AREA)
- Geometry (AREA)
- Remote Sensing (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Image Generation (AREA)
- Devices For Executing Special Programs (AREA)
Abstract
The invention discloses a Bitmap scaling rendering optimization method based on object dynamic migration, which reduces the creation and destruction operations of Bitmap objects in the process of completing rendering by loading a large number of Bitmap fragments on the premise of not modifying mobile application, obviously reduces unnecessary scaling and garbage recycling operations in a system, effectively reduces CPU overhead and memory overhead of the system, and improves the fluency of the operation process of the mobile application.
Description
Technical Field
The invention belongs to the technical field of mobile application development, and particularly relates to a Bitmap scaling rendering optimization method based on object dynamic migration.
Background
Currently, some mobile applications, such as navigation applications and map applications, generally adopt a slice rendering mode to complete image rendering, that is, a large number of pictures are loaded at the same time and subjected to corresponding scaling and other treatments, and then the pictures are spliced and then rendered to one or more layers to complete image rendering. The process of loading the picture and carrying out corresponding processing comprises the following steps: creating a Bitmap object by using a Bitmap field, a Bitmap resource, bitmap field, a decodeFiles, a Bitmap field, a decodeStream or a Bitmap ByteArray and other methods for loading an original Bitmap, and naming the original Bitmap object; creating a Matrix class object for setting a scaling; creating a Bitmap object for loading the scaled Bitmap by using a bitmap.createbitmap method based on the original Bitmap object and Matrix class object, and naming the Bitmap object after scaling; and finally, calling a drawBitmap method of the Canvas to render the scaled Bitmap object, and completing the processing process. The android system provides Bitmap class and Bitmap factor class, the Bitmap class can acquire image file information, perform operations such as image cutting, rotation and scaling, and can store image files in a specified format; the Bitmap factor class serves as a tool class for parsing and creating Bitmap objects from different data sources. It follows that in order to display a scaled picture, two Bitmap class objects need to be created.
For mobile applications requiring loading a large number of Bitmap pictures to complete rendering, the number of Bitmap objects actually created by adopting the rendering mode is twice that of Bitmap objects displayed, so that great waste of system memory is caused, and meanwhile, system operations such as object destruction, garbage collection and the like are frequently executed, so that the occupancy rate of a CPU is improved, and the consumption of system resources is increased.
Disclosure of Invention
In view of the above, the invention provides a Bitmap scaling rendering optimization method based on object dynamic migration, which can realize Bitmap scaling rendering of mobile application with high-efficiency flow.
The invention provides a Bitmap scaling rendering optimization method based on object dynamic migration, which specifically comprises the following steps:
when creating a Bitmap object by using a Bitmap factor class, judging whether the memory space occupied by the decoded image to be loaded can be calculated, and if the memory space cannot be calculated, executing a standard flow to create the Bitmap object as a source Bitmap object; otherwise, taking the calculated memory space as a target memory space, and if the memory space of all Bitmap objects in the Bitmap object pool is smaller than the target memory space, executing a standard flow to create a Bitmap object as a source Bitmap object; if a Bitmap object with a memory space not smaller than a target memory space exists in the Bitmap object pool, selecting a Bitmap object which meets the condition that the memory space is not smaller than the target memory space and has the smallest difference value with the target memory space as a reused Bitmap object, adopting the memory space of the reused Bitmap object to decode an image to be loaded to form a source Bitmap object, and deleting the reused Bitmap object from the Bitmap object pool; creating a reference object list record in a source Bitmap object to reference a proxy Bitmap object of the object;
when creating a Bitmap object by using a Bitmap class, if the set width and height are the same as those of the source Bitmap object, the source Bitmap object is adopted; otherwise, creating a Bitmap object as a proxy Bitmap object, recording a wide scaling ratio, a high scaling ratio and a referenced source Bitmap object in the proxy Bitmap object, and adding the proxy Bitmap object into a referenced object list of the source Bitmap object, wherein the wide scaling ratio is a ratio of a set width to the width of the source Bitmap object, and the high scaling ratio is a ratio of a set height to the height of the source Bitmap object;
when the Bitmap object is rendered, judging whether the Bitmap object is rendered for the first time, and if the Bitmap object is rendered for the first time and the proxy Bitmap object does not exist, executing a standard rendering flow; if the Bitmap object exists for the first time and the proxy Bitmap object exists, calculating to obtain the width and the height of the image to be rendered, and executing the scaling and the standard rendering flow of the image to be rendered after taking the proxy Bitmap object as the rendering object; if not, taking the proxy Bitmap object as a rendering object and then executing a standard rendering flow;
when destroying the Bitmap object, if the Bitmap object is not allocated with the memory space, executing a standard destroying flow to destroy; otherwise, adding the Bitmap object into the Bitmap object pool.
Further, the process of adding the Bitmap object to the Bitmap object pool when destroying the Bitmap object further comprises: if the number of the Bitmap objects in the Bitmap object pool is larger than the threshold value at this time, removing N Bitmap objects with smaller memory space allocated in the Bitmap object pool, wherein N is a numerical value that the number of the Bitmap objects is larger than the threshold value; for N removed Bitmap objects, if a reference object list exists in the Bitmap objects and the reference object list is not empty, performing scaling processing on the source Bitmap object according to information recorded by the proxy Bitmap object in the reference object list, storing the processed Bitmap in the proxy Bitmap object, and setting the source Bitmap object of the proxy Bitmap object to be empty; if the Bitmap object does not have the reference object list, removing the Bitmap object from the reference object list of the source Bitmap object, and destroying the Bitmap object; if the reference object list of the Bitmap object is empty, destroying the Bitmap object.
Further, the calculated memory space is: and calculating according to the meta information, the image format and the image size of the image to be loaded to obtain the memory space required by storing the decoded image to be loaded.
Further, the meta information includes a color depth and a palette.
Further, if the Bitmap object is the first time and the proxy Bitmap object exists, the method for calculating the width and height of the image to be rendered is as follows: and calculating the width and height of the image to be rendered according to the width scaling, the high scaling and the width and height of the source Bitmap object recorded in the proxy Bitmap object.
Further, the method for creating the Bitmap object by using the Bitmap factor class comprises the following steps: the Bitmap object is created by adopting decodeResource, decodeFiles, decodeStream or decodeByteArray method of Bitmap factor class.
Further, the method for creating the Bitmap object by using the Bitmap class comprises the following steps: a createBitmap method of a Bitmap class is adopted to create a Bitmap object.
The beneficial effects are that:
on the premise of not modifying the mobile application, the method reduces the creation and destruction operations of the Bitmap object in the process of loading a large number of Bitmap fragments to complete rendering by the application, obviously reduces unnecessary scaling and garbage recycling operations in the system, effectively reduces CPU overhead and memory overhead of the system, and improves the fluency of the operation process of the mobile application.
Detailed Description
The present invention will be described in detail with reference to the following examples.
The invention provides a Bitmap scaling rendering optimization method based on object dynamic migration, which has the following core ideas: when creating a Bitmap object by using a Bitmap factor class, if a Bitmap object with matched attribute exists in a Bitmap object pool, using the matched Bitmap object, otherwise, creating a new Bitmap object; creating a proxy Bitmap object containing references and scaling parameters of an original Bitmap related source Bitmap object when creating a Bitmap object for storing a scaled Bitmap by adopting a Bitmap class; determining a rendering mode to complete rendering according to whether the Bitmap object is rendered for the first time or not and whether the Bitmap object is a proxy Bitmap object or not when the Bitmap object is rendered; when processing the Bitmap object destroying operation, judging whether the Bitmap object has the allocated memory space, if not, directly destroying, otherwise, adding the Bitmap object to be destroyed into a Bitmap object pool.
The invention provides a Bitmap scaling rendering optimization method based on object dynamic migration, which specifically comprises the following steps:
when creating a Bitmap object by using a Bitmap factor class, acquiring meta information, an image format and an image size of an image to be loaded, judging whether a memory space required for storing the decoded image to be loaded can be calculated, and if the memory space cannot be calculated, executing a standard flow to create the Bitmap object as a source Bitmap object; otherwise, according to the meta information, the image format and the image size of the image to be loaded, calculating to obtain a memory space required for storing the decoded image to be loaded, and taking the memory space as a target memory space; if the related memory space of all Bitmap objects in the Bitmap object pool is smaller than the target memory space, executing a standard flow to create a Bitmap object as a source Bitmap object; if a Bitmap object with a memory space not smaller than a target memory space exists in the Bitmap object pool, selecting a Bitmap object which meets the condition that the memory space is not smaller than the target memory space and has the smallest difference value with the target memory space as a reused Bitmap object, adopting the memory space of the reused Bitmap object to decode an image to be loaded to form a source Bitmap object, and deleting the reused Bitmap object from the Bitmap object pool; the source Bitmap object creates a reference object list for recording proxy Bitmap objects referencing the object.
When a Bitmap object is created by using a Bitmap class, if the width and the height set in the creation process are the same as those of the source Bitmap object, a new Bitmap object is not created any more and the source Bitmap object is directly used; otherwise, creating a new Bitmap object as a proxy Bitmap object, recording a wide scaling ratio, a high scaling ratio and a referenced Bitmap object in the proxy Bitmap object, and adding the proxy Bitmap object into a reference object list of a source Bitmap object, wherein the wide scaling ratio is a ratio of a set width to the width of the source Bitmap object, the high scaling ratio is a ratio of the set height to the height of the source Bitmap object, and the referenced Bitmap object is the source Bitmap object.
When a Bitmap object is rendered, judging whether the Bitmap object is rendered for the first time, and if the Bitmap object is rendered for the first time and the proxy Bitmap object does not exist, executing a standard rendering flow to complete the rendering of the Bitmap object; if the proxy Bitmap object exists for the first time and the Bitmap object exists, calculating to obtain the width and the height of the image to be rendered according to the width scaling, the high scaling and the width and the height of the source Bitmap object recorded in the proxy Bitmap object, performing image scaling operation of the Bitmap class after the proxy Bitmap object is used as the rendering object to finish scaling of the image to be rendered, and performing a standard rendering flow to finish rendering of the Bitmap object; if not, taking the proxy Bitmap object as a rendering object, and executing a standard rendering flow to complete the rendering of the Bitmap object.
When destroying the Bitmap object, if the Bitmap object is not allocated to the memory space for storing the Bitmap, executing a standard destroying flow to destroy the Bitmap object; otherwise, adding the Bitmap objects into a Bitmap object pool, and if the number of the Bitmap objects in the Bitmap object pool is larger than a threshold value at the moment, removing N Bitmap objects with smaller memory space allocated in the Bitmap object pool, wherein N is the number of the Bitmap objects larger than the threshold value in the Bitmap object pool; for N removed Bitmap objects, if a reference object list exists in the Bitmap objects and the reference object list is not empty, performing scaling processing on bitmaps corresponding to the source Bitmap objects according to the wide scaling, the high scaling and the size of the source Bitmap objects recorded by the proxy Bitmap objects in the reference object list, storing the processed bitmaps in the proxy Bitmap objects, and setting the source Bitmap objects of the proxy Bitmap objects to be empty; if the Bitmap object does not have the reference object list, the Bitmap object is indicated to be a proxy Bitmap object, and the Bitmap object is destroyed after being removed from the reference object list of the source Bitmap object recorded by the Bitmap object; if the reference object list of the Bitmap object is empty, destroying the Bitmap object.
Examples:
the embodiment realizes the Bitmap scaling rendering optimization method based on the object dynamic migration by modifying the related methods of the Bitmap class and the Bitmap factor class in the security Zhuo Kuangjia, and specifically comprises the following steps:
s1, modifying the building process of the Bitmap of the android frame, preferentially selecting available existing objects with Bitmap sizes meeting requirements from a Bitmap object pool usenbitmap pool, if the available Bitmap objects are available, not creating new, and using the existing available Bitmap objects, so that the creating operation of the Bitmap objects and the destroying operation of the Bitmap objects can be reduced, and the allocation and release operation of a Bitmap buffer area in the Bitmap objects can be reduced.
Modifying the Bitmap constructor of the Bitmap factor of the android framework, for example: decodeResource, decodeFiles, decodeStream and decodeByteArray, etc., when creating a Bitmap object using the above constructor, selecting an available Bitmap object from the userobitmap pool, specifically:
if the image to be loaded cannot calculate the required memory space before being completely decoded, for example, the image in the vector diagram format, directly creating a Bitmap object according to the standard flow of the android frame, and returning to the newly created Bitmap object; otherwise, calculating the memory space size bitmapBuffersize required after decoding according to the meta information of the image to be loaded (i.e. the meta information of the image format including color depth, palette, etc.), the image format and the image size, traversing all Bitmap objects in the userobicbitmap pool, if the userobicmap pool is empty or the Bitmap memory size of all Bitmap objects in the userobicmap pool is smaller than bitmapBuffersize, creating Bitmap objects according to the standard flow of the android frame, and returning to the newly created Bitmap objects; otherwise, selecting a Bitmap object with the smallest difference value between the memory size of the Bitmap in the usenbicbitmap pool and the bitmapBuffersize, and marking the Bitmap object as a reusabitmap; the existing bitmapBuffer of the reusabbeside map is used for decoding the image to be loaded, and after the reusabbeside map is removed from the usebbitmap pool, the reusabbeside map is returned.
S2, modifying a destroying process of the Bitmap, namely, modifying an object destroying function (ART) in An Zhuoyun rows, destroying the Bitmap object which is not allocated with the memory space for storing the Bitmap, and for the Bitmap object which is allocated with the memory space for storing the Bitmap, not destroying, adding the Bitmap object into a usenbitmap pool, and recording that the Bitmap object to be destroyed is bitmapto destroyy, wherein the method specifically comprises the following steps:
s2.1, adding bitmapto de-stroy into uselebitmapool;
s2.2, judging whether the number of Bitmap objects in the usenbitmap pool exceeds a threshold, if so, selecting the N smallest Bitmap buffers from the usenbitmap pool, removing the N objects from the usenbitmap pool, and executing the following operations on the N objects:
if the bitmapUsedThisbitmap of the Bitmap object is not empty, performing scaling operation on the Bitmap object according to refBitmap, widthScaleRatio, heightScaleRatio in the bitmapUsedThisbitmap for each object bitmapUsedThisbitmap, storing the scaling result in the bitmapraises Thisbitmap, and then setting the refBitmap of the bitmapraises Thisbitmap to be empty;
if the Bitmap object is empty, destroying the Bitmap object.
S3, modifying a createBitmap method of the Bitmap class of the android frame so as to realize that real scaling operation is not executed in the method, wherein the method specifically comprises the following steps: four member variables are added in the Bitmap class, including Bitmap refBitmap, float widthScaleRatio, float heightScaleRatio and List < Bitmap > bitmapUsedThisbitmap; if the zoom height and width in the createBitmap parameter are consistent with the size of the source Bitmap object, returning to the source Bitmap object; otherwise, creating a new Bitmap object as a proxy Bitmap object, marking the new Bitmap object as a proxyBitmap, setting a refBitmap of the proxyBitmap as a source Bitmap object, setting widthScaleRatio as a ratio of a width parameter to the width of the source Bitmap object, setting height ScaleRatio as a ratio of a height parameter to the height of the source Bitmap object, and adding the proxyBitmap into a bitpepusedthibitmap list of the source Bitmap object; no further standard operations are performed, and the proxyBitmap is returned directly.
S4, modifying Bitmap rendering operation of the android frame, such as a canvas. Judging whether scaling is needed when the Bitmap object is rendered for the first time, if so, scaling and storing a scaling result in the proxy Bitmap object, otherwise, adopting a source Bitmap object to reduce unnecessary scaling operation, wherein the scaling operation specifically comprises the following steps:
judging whether the proxyBitmap of the Bitmap object is empty or not, if so, executing standard rendering operation, otherwise, judging whether the rendering operation needs to execute scaling operation or not, and if not, executing subsequent standard rendering operation, namely executing rendering by using an OpenGL graphical interface or executing rendering by using a Vulkan graphical interface, wherein the scaling scale of the width and the height of the Bitmap object is 1.0; if the scaling operation is needed, multiplying the width and the height by widthScaalRatio and the height ScaalRatio respectively, modifying the rendering object into proxyBitmap, and executing the subsequent standard rendering operation.
In summary, the above embodiments are only preferred embodiments of the present invention, and are not intended to limit the scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims (7)
1. The Bitmap scaling rendering optimization method based on the object dynamic migration is characterized by comprising the following steps of:
when creating a Bitmap object by using a Bitmap factor class, judging whether the memory space occupied by the decoded image to be loaded can be calculated, and if the memory space cannot be calculated, executing a standard flow to create the Bitmap object as a source Bitmap object; otherwise, taking the calculated memory space as a target memory space, and if the memory space of all Bitmap objects in the Bitmap object pool is smaller than the target memory space, executing a standard flow to create a Bitmap object as a source Bitmap object; if a Bitmap object with a memory space not smaller than a target memory space exists in the Bitmap object pool, selecting a Bitmap object which meets the condition that the memory space is not smaller than the target memory space and has the smallest difference value with the target memory space as a reused Bitmap object, adopting the memory space of the reused Bitmap object to decode an image to be loaded to form a source Bitmap object, and deleting the reused Bitmap object from the Bitmap object pool; creating a reference object list record in a source Bitmap object to reference a proxy Bitmap object of the object;
when creating a Bitmap object by using a Bitmap class, if the set width and height are the same as those of the source Bitmap object, the source Bitmap object is adopted; otherwise, creating a Bitmap object as a proxy Bitmap object, recording a wide scaling ratio, a high scaling ratio and a referenced source Bitmap object in the proxy Bitmap object, and adding the proxy Bitmap object into a referenced object list of the source Bitmap object, wherein the wide scaling ratio is a ratio of a set width to the width of the source Bitmap object, and the high scaling ratio is a ratio of a set height to the height of the source Bitmap object;
when the Bitmap object is rendered, judging whether the Bitmap object is rendered for the first time, and if the Bitmap object is rendered for the first time and the proxy Bitmap object does not exist, executing a standard rendering flow; if the Bitmap object exists for the first time and the proxy Bitmap object exists, calculating to obtain the width and the height of the image to be rendered, and executing the scaling and the standard rendering flow of the image to be rendered after taking the proxy Bitmap object as the rendering object; if not, taking the proxy Bitmap object as a rendering object and then executing a standard rendering flow;
when destroying the Bitmap object, if the Bitmap object is not allocated with the memory space, executing a standard destroying flow to destroy; otherwise, adding the Bitmap object into the Bitmap object pool.
2. The Bitmap scaling rendering optimization method according to claim 1, wherein the process of adding a Bitmap object to a Bitmap object pool when destroying the Bitmap object further comprises: if the number of the Bitmap objects in the Bitmap object pool is larger than the threshold value at this time, removing N Bitmap objects with smaller memory space allocated in the Bitmap object pool, wherein N is a numerical value that the number of the Bitmap objects is larger than the threshold value; for N removed Bitmap objects, if a reference object list exists in the Bitmap objects and the reference object list is not empty, performing scaling processing on the source Bitmap object according to information recorded by the proxy Bitmap object in the reference object list, storing the processed Bitmap in the proxy Bitmap object, and setting the source Bitmap object of the proxy Bitmap object to be empty; if the Bitmap object does not have the reference object list, removing the Bitmap object from the reference object list of the source Bitmap object, and destroying the Bitmap object; if the reference object list of the Bitmap object is empty, destroying the Bitmap object.
3. The Bitmap scaling rendering optimization method according to claim 1, wherein the calculated memory space is: and calculating according to the meta information, the image format and the image size of the image to be loaded to obtain the memory space required by storing the decoded image to be loaded.
4. The Bitmap scaling rendering optimization method according to claim 3, wherein the meta information includes color depth and palette.
5. The Bitmap scaling rendering optimization method according to claim 1, wherein if the Bitmap object is the first time and there is a proxy Bitmap object, the manner of calculating the width and height of the image to be rendered is: and calculating the width and height of the image to be rendered according to the width scaling, the high scaling and the width and height of the source Bitmap object recorded in the proxy Bitmap object.
6. The Bitmap scaling rendering optimization method according to claim 1, wherein the creating a Bitmap object using a Bitmap factor class includes: the Bitmap object is created by adopting decodeResource, decodeFiles, decodeStream or decodeByteArray method of Bitmap factor class.
7. The Bitmap scaling rendering optimization method according to claim 1, wherein the creating a Bitmap object by using a Bitmap class includes: a createBitmap method of a Bitmap class is adopted to create a Bitmap object.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310038619.0A CN116107743A (en) | 2023-01-12 | 2023-01-12 | Bitmap scaling rendering optimization method based on object dynamic migration |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310038619.0A CN116107743A (en) | 2023-01-12 | 2023-01-12 | Bitmap scaling rendering optimization method based on object dynamic migration |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116107743A true CN116107743A (en) | 2023-05-12 |
Family
ID=86261028
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310038619.0A Pending CN116107743A (en) | 2023-01-12 | 2023-01-12 | Bitmap scaling rendering optimization method based on object dynamic migration |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116107743A (en) |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106056530A (en) * | 2016-06-01 | 2016-10-26 | 腾讯科技(深圳)有限公司 | Method and device for displaying picture content in application |
CN106445502A (en) * | 2016-08-30 | 2017-02-22 | 北京小米移动软件有限公司 | Image display method and apparatus |
CN107239247A (en) * | 2017-05-27 | 2017-10-10 | 广州阿里巴巴文学信息技术有限公司 | Electronic equipment and its content display method, device and storage medium |
-
2023
- 2023-01-12 CN CN202310038619.0A patent/CN116107743A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106056530A (en) * | 2016-06-01 | 2016-10-26 | 腾讯科技(深圳)有限公司 | Method and device for displaying picture content in application |
CN106445502A (en) * | 2016-08-30 | 2017-02-22 | 北京小米移动软件有限公司 | Image display method and apparatus |
CN107239247A (en) * | 2017-05-27 | 2017-10-10 | 广州阿里巴巴文学信息技术有限公司 | Electronic equipment and its content display method, device and storage medium |
Non-Patent Citations (5)
Title |
---|
WEIXIN_34275734: "Glide自我解惑(一)", Retrieved from the Internet <URL:https://blog.csdn.net/shulianghan/article/details/107082617> * |
业志陈: "Coil 和 Glide 的 Bitmap 缓存复用机制", Retrieved from the Internet <URL:https://juejin.cn/post/6956090846470995975> * |
人生代码_公众号: "Bitmap的复制和软引用", Retrieved from the Internet <URL:https://blog.51cto.com/u_13721123/3144857> * |
张旸: "收拢图片,可以优化内存避免 OOM,但是收拢不是说说而已!(以Glide举例)", Retrieved from the Internet <URL:https://www.sohu.com/a/367689275_185201> * |
韩曙亮: "【Android 内存优化】Bitmap 内存缓存", pages 22 - 56, Retrieved from the Internet <URL:https://blog.csdn.net/shulianghan/article/details/107082617> * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
TWI279737B (en) | Automatic memory management for zone rendering | |
TWI691931B (en) | Picture loading method and device | |
WO2021248705A1 (en) | Image rendering method and apparatus, computer program and readable medium | |
CN1287330C (en) | Eeficient graphics state management for zone rendering | |
US20020154122A1 (en) | Generating three dimensional text | |
US20080036763A1 (en) | Method and system for computer graphics with out-of-band (oob) background | |
US20070171222A1 (en) | Application-independent method for capturing three-dimensional model data and structure for viewing and manipulation | |
CN1291355C (en) | Depth write disable for zone rendering | |
JPH10105361A (en) | Method and system for specifying object | |
US9275492B2 (en) | Method and system for multisample antialiasing | |
WO2017052746A1 (en) | Efficient saving and restoring of context information for context switches | |
CN111951356B (en) | Animation rendering method based on JSON data format | |
US20150348280A1 (en) | Dynamic Generation Of Texture Atlases | |
US12014103B2 (en) | Method and system for game screen rendering based on multiple graphics cards | |
US7027071B2 (en) | Selecting elements from an electronic document | |
CN112489180B (en) | Data processing method, system, electronic device and computer readable medium | |
CN116595104A (en) | Visual processing method of mine safety monitoring system | |
CN116107743A (en) | Bitmap scaling rendering optimization method based on object dynamic migration | |
US20180088938A1 (en) | In-Editor Spritesheeting | |
JPS62231382A (en) | Image processing method and apparatus | |
EP0825557A2 (en) | Maintaining invalidation information for tiled images | |
CN112604293A (en) | Data processing method and device, electronic equipment and readable medium | |
JP4911585B2 (en) | Image processing apparatus, image processing method, program, and information recording medium | |
CN114092311A (en) | IOS picture loading performance optimization method | |
JP2825273B2 (en) | Drawing management method and apparatus |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |