Picture display method and device, memory optimization method and device, storage medium and electronic equipment
By setting the memory cache threshold and the least recently used algorithm in the whiteboard software, the problem of excessive memory usage caused by image insertion by the whiteboard software is solved, ensuring the stable operation and efficient display of the system.
Patent Information
- Application Number
- CN202310756129.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-25
- Publication Date
- 2024-12-27
AI Technical Summary
When a large number of pictures are inserted into the whiteboard software, it will cause excessive memory usage, resulting in abnormalities in the software and operating system, causing problems such as jamming and system failure.
By determining the storage space threshold of the memory cache in the application, determining the storage status of the inserted picture, and processing it as picture data when it is not stored, and storing it in the memory cache, controlling the storage space of the memory cache does not exceed the threshold, and using the recent Use algorithms at least to eliminate infrequently used data to ensure that memory usage is in a stable state.
It effectively avoids the increase in memory footprint caused by image insertion, ensures the normal operation of applications and operating systems, and realizes inserting and displaying pictures as many as possible in limited storage space.
Smart Images

Figure CN119201299A_ABST
Abstract
Description
Background Art
[0002] With the popularization of smart devices, the writing function of large-screen smart devices has gradually entered our lives. Pictures are also an indispensable part of life and work.
[0003] When a large number of pictures are inserted into the whiteboard software, the memory occupied by the whiteboard software will gradually increase. When the memory occupied by the whiteboard software is too high, it will cause abnormalities in the whiteboard software and the operating system, causing the whiteboard software to freeze and the system to be unable to run.
[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0005] The present disclosure provides a method, device, storage medium and electronic device for image display and memory optimization, which at least to some extent overcome the problem of software and system abnormalities caused by excessive memory usage in related technologies.
[0006] Other features and advantages of the present disclosure will become apparent from the following detailed description, or may be learned in part by the practice of the present disclosure.
[0007] According to one aspect of the present disclosure, there is provided a method for displaying an image, comprising:
[0008] Determining a memory cache according to available memory of the application; the memory cache is configured with a storage space threshold;
[0009] Obtain an inserted picture, and determine a storage status of the inserted picture in the memory cache;
[0010] If the storage state of the inserted image in the memory cache is not stored, the inserted image is processed into image data and then stored in the memory cache; the storage space of the memory cache storing the image data does not exceed the storage space threshold;
[0011] The image data is called from the memory cache and rendered and displayed in the display interface of the application.
[0012] In some embodiments, determining the memory cache based on available memory of the application includes:
[0013] According to the available memory of the application, a memory cache with a set memory space is determined in the memory where the application is running, and a storage space threshold is configured for the memory cache.
[0014] In some embodiments, the memory cache stores a key-value pair; the key-value pair is a data storage structure composed of a picture key as a key object and picture data as a value object;
[0015] Determining the storage status of the inserted picture in the memory cache includes:
[0016] Determining the image attributes of the inserted image;
[0017] Determine a picture key according to the picture attributes;
[0018] Match the image key with the key-value pair in the memory cache to determine the storage status of the inserted image in the memory cache; wherein; if the image key matches the image key of the key-value pair in the memory cache successfully, then determine that the storage status of the inserted image in the memory cache is stored; if the image key matches the image key of the key-value pair in the memory cache unsuccessfully, then determine that the storage status of the inserted image in the memory cache is not stored.
[0019] In some embodiments, the image attributes include: file path, the last modification time of the file, and file size;
[0020] Determining a picture key according to the picture attribute includes:
[0021] Determine file parameters according to the file path, the last modification time of the file and the file size;
[0022] The MD5 value obtained by calculating the file parameters using the information digest MD5 algorithm is determined as the image key.
[0023] In some embodiments, storing the image data into the memory cache includes:
[0024] Determine a key-value pair corresponding to the inserted picture according to the picture key and the corresponding picture data of the inserted picture;
[0025] The key-value pair is stored in the memory cache.
[0026] In some embodiments, storing the key-value pair into the memory cache includes:
[0027] Obtaining the storage space of the current memory cache; the storage space of the current memory cache is the sum of the storage space occupied by all key-value pairs stored in the current memory cache;
[0028] When the storage space of the current memory cache does not exceed the storage space threshold, storing the key-value pair in the memory cache;
[0029] When the storage space of the current memory cache exceeds the storage space threshold, a least recently used key-value pair is determined from all key-value pairs stored in the current memory cache using a least recently used algorithm, the least recently used key-value pair is deleted from the memory cache, and the key-value pair is stored in the memory cache.
[0030] In some embodiments, it also includes:
[0031] If the storage status of the inserted picture in the memory cache is stored, the picture data corresponding to the inserted picture in the memory cache is determined.
[0032] In some embodiments, determining the picture data corresponding to the inserted picture in the memory cache includes:
[0033] According to the picture key corresponding to the inserted picture, a corresponding key-value pair is determined from the memory cache to obtain the picture data in the corresponding key-value pair.
[0034] In some embodiments, calling the image data from the memory cache and rendering and displaying it in the display interface of the application program includes:
[0035] According to the image key, a corresponding key-value pair is found from the memory cache, the image data of the found corresponding key-value pair is called, and the image data is rendered in the application display interface to display the inserted image.
[0036] In some embodiments, it also includes:
[0037] After the key-value pair is stored in the memory cache, the image data of the key-value pair is stored in the local disk using the image key of the key-value pair as the file name.
[0038] In some embodiments, it also includes:
[0039] When re-rendering the inserted image, searching the memory cache for a corresponding key-value pair according to the image key of the inserted image;
[0040] If a key-value pair corresponding to the picture key of the inserted picture is found in the memory cache, the picture data in the key-value pair is called to be rendered and displayed in the application display interface;
[0041] If the key-value pair corresponding to the picture key of the inserted picture is not found in the memory cache, the picture key of the inserted picture is used to search the corresponding file name in the local disk, the picture data corresponding to the file name is loaded into the memory cache, and the picture data in the memory cache is called to render and display in the application display interface.
[0042] In some embodiments, it also includes:
[0043] When the display interface of the application is switched, the key-value pairs stored in the memory cache are cleared to release the storage space of the memory cache.
[0044] In some embodiments, before determining the storage status of the inserted picture in the memory cache, the method further includes:
[0045] Determining a picture insertion threshold according to the available memory of the application, the cache coefficient of the memory cache, and the memory space occupied by the picture with a set resolution;
[0046] Obtaining the number of images inserted into the display interface of the application, and determining whether the number of images inserted exceeds the image insertion threshold;
[0047] If the number of inserted pictures does not exceed the picture insertion threshold, performing the insertion operation of the inserted picture, and determining the storage status of the inserted picture in the memory cache;
[0048] If the number of inserted pictures exceeds the picture insertion threshold, the insertion operation of the inserted pictures is canceled.
[0049] In some embodiments, processing the inserted picture into picture data includes:
[0050] Obtaining the resolution of the display device running the application;
[0051] Determining the resolution of the inserted picture;
[0052] According to the resolution of the display device and the resolution of the inserted picture, the inserted picture is compressed to obtain picture data.
[0053] In some embodiments, the resolution of the display device includes: a first horizontal size and a first vertical size; the resolution of the inserted picture includes: a second horizontal size and a second vertical size;
[0054] According to the resolution of the display device and the resolution of the inserted picture, compressing the inserted picture to obtain picture data includes:
[0055] If the second horizontal dimension is larger than the first horizontal dimension or the second vertical dimension is larger than the first vertical dimension, the inserted picture is compressed in size and quality to determine the picture data; the size compression is used to sample the inserted picture to reduce it to the target resolution; the quality compression is used to convert the encoding format of the inserted picture to reduce it to the target storage space.
[0056] In some embodiments, it also includes:
[0057] Determine whiteboard data according to the display interface of the application; the whiteboard data includes: picture description data and handwriting description data; the picture description data includes: coordinate information of the picture key and the picture on the display interface of the application; the handwriting description data includes: touch data points corresponding to the handwriting generated by the user when writing on the display interface of the application;
[0058] The image data and the whiteboard data are written into the whiteboard file in the form of a file read and write stream, and a binary file is generated and stored in a local disk.
[0059] In some embodiments, it also includes:
[0060] Load the binary file from the local disk into the memory, and parse the image data and the whiteboard data;
[0061] According to the image data and the whiteboard data, the corresponding image and handwriting are rendered and displayed in the application display interface.
[0062] According to another aspect of the present disclosure, there is also provided a picture display device, comprising:
[0063] A memory cache determination module, used to determine a memory cache according to the available memory of the application; the memory cache is configured with a storage space threshold;
[0064] An inserted picture storage status determination module, used to obtain an inserted picture and determine the storage status of the inserted picture in the memory cache;
[0065] A picture data storage module, configured to process the inserted picture into picture data and store it in the memory cache if the storage state of the inserted picture in the memory cache is not stored; the storage space of the memory cache storing the picture data does not exceed the storage space threshold;
[0066] A rendering and display module is used to call the image data from the memory cache and render and display it in the display interface of the application.
[0067] According to another aspect of the present disclosure, a memory optimization method is also provided, comprising:
[0068] Determining, according to the inserted picture, a storage state of the inserted picture in the memory cache; the memory cache is configured with a storage space threshold;
[0069] If the storage state of the inserted image in the memory cache is not stored, the inserted image is processed into image data and then stored in the memory cache; the storage space of the memory cache storing the image data does not exceed the storage space threshold;
[0070] According to rendering requirements, the image data is called from the memory cache.
[0071] According to another aspect of the present disclosure, a memory optimization device is also provided, including:
[0072] An inserted picture storage state determination module, used to determine the storage state of the inserted picture in the memory cache according to the inserted picture; the memory cache is configured with a storage space threshold;
[0073] A picture data storage module, configured to process the inserted picture into picture data and store it in the memory cache if the storage state of the inserted picture in the memory cache is not stored; the storage space of the memory cache storing the picture data does not exceed the storage space threshold;
[0074] The image data calls the rendering module, which is used to call the image data from the memory cache according to rendering requirements.
[0075] According to another aspect of the present disclosure, an electronic device is also provided, which includes: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute any one of the above-mentioned image display methods or memory optimization methods by executing the executable instructions.
[0076] According to another aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the image display method or memory optimization method described above is implemented.
[0077] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the computer program implements any one of the above-mentioned image display methods or memory optimization methods.
[0078] The picture display and memory optimization methods, devices, storage media and electronic devices provided in the embodiments of the present invention first determine a memory cache configured with a storage space threshold based on the available memory of the application. When inserting an inserted picture, first determine the storage status of the inserted picture in the memory cache. If the storage status is not stored, the inserted picture is processed into picture data and then stored in the memory cache. Through the storage space threshold configured by the memory cache, the storage space of the memory cache is controlled not to exceed the storage space threshold when the picture data is stored in the memory cache. This can keep the actual storage space occupied by the application in the memory in a stable state, and will not cause an increase in the actual storage space occupied by the application due to an increase in the number of inserted pictures, thereby ensuring the normal operation of the application and the operating system.
[0079] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0080] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.
[0081] Figure 1 A schematic diagram showing an exemplary system architecture of a method for displaying an image in an embodiment of the present disclosure.
[0082] Figure 2 A schematic diagram of picture insertion is shown in a picture display method in an embodiment of the present disclosure.
[0083] Figure 3 A schematic diagram showing a method for displaying an image in an embodiment of the present disclosure is shown.
[0084] Figure 4 A schematic diagram showing a picture quantity limiting process of a picture display method in an embodiment of the present disclosure is shown.
[0085] Figure 5 A schematic diagram of a quantity limitation strategy for a picture display method in an embodiment of the present disclosure is shown.
[0086] Figure 6 A schematic diagram showing another implementation method of a picture quantity limitation process of a picture display method in an embodiment of the present disclosure.
[0087] Figure 7 A schematic diagram of a storage status determination process of a picture display method in an embodiment of the present disclosure is shown.
[0088] Figure 8 A schematic diagram showing a picture compression process of a picture display method in an embodiment of the present disclosure is shown.
[0089] Fig. 9 A schematic diagram of a picture compression strategy of a picture display method in an embodiment of the present disclosure is shown.
[0090] Fig.10 A schematic diagram showing a process of storing key-value pairs into a memory cache in a method for displaying images in an embodiment of the present disclosure.
[0091] Fig.11 A schematic diagram of the LRU mechanism process of a memory cache of a picture display method in an embodiment of the present disclosure is shown.
[0092] Fig.12 An LRU principle diagram of a picture display method in an embodiment of the present disclosure is shown.
[0093] Fig.13 A schematic diagram showing a process of re-rendering an inserted image in a method for displaying an image in an embodiment of the present disclosure is shown.
[0094] Fig.14 A schematic diagram showing a display interface saving process of a picture display method in an embodiment of the present disclosure is shown.
[0095] Fig.15 A flow chart of a method for displaying an image in an embodiment of the present disclosure is shown.
[0096] Fig.16 Another flow chart of a picture display method in an embodiment of the present disclosure is shown.
[0097] Fig.17 A schematic diagram showing a memory optimization method in an embodiment of the present disclosure.
[0098] Fig.18 A schematic diagram of a picture display device in an embodiment of the present disclosure is shown.
[0099] Fig.19 A schematic diagram of a memory optimization device in an embodiment of the present disclosure is shown.
[0100] Fig. 20 A structural block diagram of a computer device showing a method for displaying an image or a method for optimizing a memory in an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0101] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that the disclosure will be more comprehensive and complete and to fully convey the concepts of the example embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
[0102] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.
[0103] For ease of understanding, before introducing the embodiments of the present disclosure, several terms involved in the embodiments of the present disclosure are first explained as follows:
[0104] Whiteboard handwriting software, Write Board Program, is an application program that runs on large-screen all-in-one devices, mobile terminals, classroom teaching terminals and other devices. It has the function of inserting pictures and can also write descriptive handwriting on the inserted pictures.
[0105] Page, Page, Whiteboard handwriting software can contain many pages. For example: it is equivalent to a paper notebook, each page is a "page", and the entire notebook is a Write Board File (whiteboard folder).
[0106] The whiteboard folder, Write Board File, is used to store image data, and includes multiple pages in the whiteboard folder.
[0107] Image memory cache strategy, Bitmap Memory Policy, mainly includes image compression, LRU (Least recently used) algorithm, image reuse, image quantity limit and other methods.
[0108] Image storage policy, Bitmap Storage Policy, mainly includes temporary cache files and image packaging strategy (that is, saving image file data in Write Board File).
[0109] The specific implementation of the embodiment of the present disclosure is described in detail below with reference to the accompanying drawings.
[0110] Figure 1 FIG. 1 is a schematic diagram showing an exemplary application system architecture to which the picture display method in the embodiment of the present disclosure can be applied. Figure 1 As shown, the system architecture may include a display device 101 , a communication connection 102 and a server 103 .
[0111] The communication connection 102 is used to provide a medium for a communication link between the display device 101 and the server 103 , and may be a wired network or a wireless network.
[0112] Optionally, the wireless network or wired network described above uses standard communication technology and / or protocol. The network is usually the Internet, but it can also be any network, including but not limited to a local area network (LAN), a metropolitan area network (MAN), a wide area network (WAN), a mobile, wired or wireless network, a dedicated network or any combination of a virtual private network). In some embodiments, technologies and / or formats including Hyper Text Mark-up Language (HTML), Extensible Markup Language (XML), etc. are used to represent data exchanged through the network. In addition, conventional encryption technologies such as Secure Socket Layer (SSL), Transport Layer Security (TLS), Virtual Private Network (VPN), Internet Protocol Security (IPsec) can also be used to encrypt all or some links. In other embodiments, customized and / or dedicated data communication technologies can also be used to replace or supplement the above data communication technologies.
[0113] The display device 101 may be any electronic device, including but not limited to a large-screen all-in-one device, a mobile terminal, a classroom teaching terminal, a smart phone, a tablet computer, a laptop computer, a desktop computer, a wearable device, an augmented reality device, a virtual reality device, etc. The display device 101 should have a touch function, and can be touched or written by a user.
[0114] Optionally, the client of the application installed in different display devices 101 is the same, or the client of the same type of application based on different operating systems. Based on the different terminal platforms, the specific form of the client of the application can also be different, for example, the application client can be a mobile client, a PC client, etc.
[0115] The server 103 may be a server that provides various services, such as a background management server that provides support for the device operated by the user using the display device 101. The background management server may analyze and process the received request and other data, and feed back the processing results to the display device.
[0116] Optionally, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. The terminal can be a smart phone, tablet computer, laptop computer, desktop computer, smart speaker, smart watch, etc., but is not limited to this. The terminal and the server can be directly or indirectly connected via wired or wireless communication, which is not limited in this application.
[0117] Those skilled in the art will know that Figure 1 The number of display devices, communication connections, and service terminals in the embodiment is only illustrative, and any number of display devices, communication connections, and service terminals may be provided according to actual needs. The embodiments of the present disclosure are not limited to this.
[0118] Under the above system architecture, an image display method is provided in an embodiment of the present disclosure, and the method can be executed by any electronic device with computing and processing capabilities.
[0119] In some embodiments, the image display method provided in the embodiments of the present disclosure can be executed by the display device of the above-mentioned system architecture; in other embodiments, the image display method provided in the embodiments of the present disclosure can be executed by the server in the above-mentioned system architecture; in other embodiments, the image display method provided in the embodiments of the present disclosure can be implemented by the display device and the server in the above-mentioned system architecture through interaction.
[0120] like Figure 2 As shown, pictures 1, 2 and 3 have been inserted into the whiteboard software running in the display device, and picture 4 needs to be inserted into the display device; Figure 2The picture insertion scenarios can include many situations. For example, in a conference and office scenario, the display device uses a large-screen all-in-one device. Through the insert picture function, some conference materials, such as data report charts, screenshots, market research material pictures, etc., can be inserted into the whiteboard software; for another example, it can be a classroom education scenario. The display device uses a classroom teaching terminal device. Through the insert picture function, the teacher can insert the picture materials for lesson preparation into the workbench to make the teaching more vivid and intuitive; for another example, it can be a life handheld scenario. The display device uses a mobile terminal, such as a smart phone or a tablet. Through the insert picture function, the materials in the device, such as life photos, work materials, etc., can be inserted into the whiteboard, and descriptive handwriting can be written for the pictures.
[0121] When inserting pictures into applications such as whiteboard software, since the memory of the display device has an upper limit, as the number of inserted pictures increases, the storage space occupied by the application in the memory will continue to increase. On the one hand, it will occupy the usage space of the operating system running the application, causing problems such as the operating system freezing. On the other hand, the increase in space occupied by the application will also cause the program itself to run unstable.
[0122] Figure 3 A schematic diagram of a method for displaying an image in an embodiment of the present disclosure is shown. Figure 3 As shown, the picture display method provided in the embodiment of the present disclosure includes the following steps:
[0123] Step 302, determining a memory cache according to the available memory of the application; the memory cache is configured with a storage space threshold;
[0124] Step 304, obtaining an inserted picture, and determining a storage status of the inserted picture in the memory cache;
[0125] Step 306: If the storage state of the inserted image in the memory cache is not stored, the inserted image is processed into image data and then stored in the memory cache; the storage space of the memory cache storing the image data does not exceed the storage space threshold;
[0126] Step 308: call the image data from the memory cache and render and display it in the display interface of the application.
[0127] The present disclosure limits the actual storage space occupied by the application by configuring a storage space threshold for the memory cache; through the storage space threshold configured for the memory cache, the storage space of the memory cache is controlled not to exceed the storage space threshold when image data is stored in the memory cache, so that the actual storage space occupied by the application in the memory can be kept in a stable state, and the actual storage space occupied by the application will not increase due to the increase in the number of inserted images, thereby ensuring the normal operation of the application and the operating system.
[0128] In the embodiment, between the above step 306 and step 308, there is also a case where if the storage status of the inserted picture in the memory cache is stored, the picture data corresponding to the inserted picture in the memory cache is determined. This case will be specifically described in the subsequent embodiments.
[0129] In specific implementation, determining the memory cache according to the available memory of the application in the above step 302 may include:
[0130] According to the available memory of the application, a memory cache with a set memory space is determined in the memory where the application is running, and a storage space threshold is configured for the memory cache.
[0131] The available memory of the application is dynamically configured by the operating system running the application, and the basis for the dynamic configuration is the type of the application; the operating system can be one of the Android system, iOS system, Linux system or Windows system, or other systems can be used, all of which are within the scope of protection of the present disclosure. For example, when the application is whiteboard software, the type of the application is image processing, then the memory running by the operating system is 4GB, and the available memory allocated by the operating system to the application is 500MB. Since the application itself needs to occupy a certain space, such as 50MB-100MB, according to the available memory of the above application, 400MB of space is applied from the memory as a memory cache, and further, a storage space threshold is configured for the memory cache, for example, the storage space threshold is configured to 380MB. The storage space threshold limits the space of the memory cache, and further controls the available memory of the application to be kept within a certain range, so that the memory occupied by the application is kept in a stable state.
[0132] like Figure 4 As shown, in a specific implementation, before the above step 304 determines the storage status of the inserted picture in the memory cache, it also includes:
[0133] Step 402, determining a picture insertion threshold according to the available memory of the application, the cache coefficient of the memory cache, and the memory space occupied by the picture with a set resolution;
[0134] Step 404, obtaining the number of images inserted into the display interface of the application, and determining whether the number of images inserted exceeds the image insertion threshold;
[0135] Step 406: If the number of inserted pictures does not exceed the picture insertion threshold, then the insertion operation of the inserted picture is performed to determine the storage status of the inserted picture in the memory cache;
[0136] Step 408: If the number of inserted pictures exceeds the picture insertion threshold, the insertion operation of the inserted pictures is canceled.
[0137] In the embodiment, in order to further limit the space occupied by the application in the memory, the present disclosure also provides a quantity restriction strategy for limiting the number of pictures inserted, such as Figure 5 Specifically, step 501 first determines a picture insertion threshold, and step 502 inserts the picture; the picture insertion threshold can be calculated based on the available memory of the application, the cache coefficient of the memory cache and the memory space occupied by the set resolution picture. For example, it can be calculated as follows: picture insertion threshold = (available memory of the application × cache coefficient of the memory cache) / (memory space occupied by the set resolution picture); wherein the cache coefficient of the memory cache is determined by the number of insertable pictures in the application type. When there are many insertable pictures, the cache coefficient of the memory cache is adjusted accordingly. When there are few insertable pictures, the cache coefficient of the memory cache is adjusted accordingly. For example, the available memory of the application is 500MB, the cache coefficient of the memory cache is set to 3, and the calculation is performed with a 2K resolution picture, then the picture insertion threshold = (500MB×3) / (memory space occupied by the 2K resolution picture); the above setting of 2K resolution mainly considers the fact that the resolution of the display device is 2K. Generally, the resolution setting does not exceed the resolution of the display device. In addition, the image insertion threshold is set according to the empirical value. For example, the image insertion threshold is set to 6, and the maximum number of insertions of the application is 6. After the image insertion threshold is set, step 503 checks to obtain the number of inserted images in the display interface of the application. Step 504 determines whether the number of inserted images exceeds the image insertion threshold. If the number of inserted images does not exceed the image insertion threshold, the subsequent insertion operation of inserting the images in step 505 is executed to determine the storage status of the inserted images in the memory cache. Step 506 cancels the insertion operation of inserting the images if the number of inserted images exceeds the image insertion threshold.
[0138] By setting the image insertion threshold, you can directly limit the maximum amount of space that an application takes up in memory, and keep the memory space occupied by the application in a stable state, which is beneficial to the stable operation of the application and the operating system.
[0139] like Figure 6 As shown, in another embodiment, the above-mentioned quantity limiting strategy for limiting the number of inserted pictures may further include, after determining that the storage status of the inserted picture in the memory cache is not stored, specifically:
[0140] Step 602, determining a picture insertion threshold according to the available memory of the application, the cache coefficient of the memory cache, and the memory space occupied by the set resolution picture;
[0141] Step 604, obtaining the number of images inserted into the display interface of the application, and determining whether the number of images inserted exceeds the image insertion threshold;
[0142] Step 606: If the number of inserted pictures does not exceed the picture insertion threshold, the insertion operation of the inserted picture is performed, and the inserted picture is processed into picture data and then stored in the memory cache;
[0143] Step 608: If the number of inserted pictures exceeds the picture insertion threshold, the insertion operation of the inserted pictures is canceled.
[0144] In an embodiment, before executing the quantity limitation strategy, it has been determined that the image data corresponding to the inserted image is not stored in the memory cache, similar to the aforementioned steps 402-408, then the image insertion threshold can be determined based on the available memory of the application, the cache coefficient of the memory cache, and the memory space occupied by the set resolution image, and the number of inserted images in the display interface of the application is obtained to determine whether the number of inserted images exceeds the image insertion threshold; if the number of inserted images does not exceed the image insertion threshold, the insertion operation of the inserted image is executed, and the inserted image is processed into image data and stored in the memory cache; if the number of inserted images has exceeded the image insertion threshold, the insertion operation of the inserted image is canceled.
[0145] By limiting the insertion of images after determining that the storage status of the inserted images in the memory cache is not stored, it is also possible to limit the maximum space occupied by the application in the memory, control the memory space occupied by the application in a stable state, and facilitate the stable operation of the application and the operating system.
[0146] like Figure 7 As shown, in the specific implementation, the above memory cache stores key-value pairs; the key-value pairs are a data storage structure composed of a picture key as a key object and picture data as a value object; the key-value pairs are<key,value> The storage method is as follows, where key is the key object and value is the value object.
[0147] Determining the storage status of the inserted image in the memory cache in the above step 304 may include:
[0148] Step 702, determining the image attributes of the inserted image;
[0149] Step 704, determining a picture key according to the picture attributes;
[0150] Step 706, matching the image key with the key-value pair in the memory cache, and determining the storage status of the inserted image in the memory cache; wherein; if the image key matches the image key of the key-value pair in the memory cache successfully, then determining that the storage status of the inserted image in the memory cache is stored; if the image key matches the image key of the key-value pair in the memory cache unsuccessfully, then determining that the storage status of the inserted image in the memory cache is not stored.
[0151] In the embodiment, first, it is necessary to determine the image attributes of the inserted image; the image attributes include: file path, the last modification time of the file, and the file size; the next step is to calculate the image key (image key) according to the image attributes, and the specific calculation process is: determine the file parameters according to the file path, the last modification time of the file and the file size; and determine the MD5 value obtained by calculating the file parameters (FileParam) using the information digest MD5 algorithm as the image key. The MD5 algorithm is used in the present disclosure to calculate the MD5 value of the file parameters. Compared with calculating the MD5 value of the entire inserted image, the calculation speed will be faster, thereby reducing the amount of calculation when inserting the image, making the image insertion process faster. For example, the image key can be calculated in the following way: image key = MD5 (File Path + File Last Modified Time + File Size); wherein File Path is the file path, File Last Modified Time is the last modification time of the file, and File Size is the file size. After the image key is calculated, the image key is matched with the key-value pair stored in the memory cache to determine the storage status of the inserted image in the memory cache; if the image key matches the image key of the key-value pair in the memory cache successfully, the storage status of the inserted image in the memory cache is determined to be stored, indicating that the inserted image has been inserted into the current device before the current moment and the image data is left in the memory cache; if the image key fails to match the image key of the key-value pair in the memory cache, the storage status of the inserted image in the memory cache is determined to be not stored, indicating that the inserted image has not been inserted into the current device before the current moment.
[0152] like Figure 8 As shown, when it is determined that the storage state of the inserted picture in the memory cache is not stored, processing the inserted picture into picture data in step 306 may include:
[0153] Step 802, obtaining the resolution of the display device running the application;
[0154] Step 804, determining the resolution of the inserted picture;
[0155] Step 806: compress the inserted picture to obtain picture data according to the resolution of the display device and the resolution of the inserted picture.
[0156] By compressing the inserted pictures to obtain picture data, the space occupied by the inserted pictures in the memory cache can be reduced, and as many pictures as possible can be inserted and displayed within the limited storage space.
[0157] In the embodiment, in order to insert as many pictures as possible within the limited storage space, the pictures need to be compressed. After compression, the pictures can reduce the resolution, thereby reducing the storage space occupied; Fig. 9 As shown, the present disclosure provides a picture compression strategy, first of all, it is necessary to obtain the resolution of the display device running the application, the resolution of the display device, including: executing step 901 picture compression strategy, step 902 obtaining the first horizontal size DHpx and the first vertical size DWpx; then, step 903 obtaining the resolution of the inserted picture, the resolution of the inserted picture including: the second horizontal size Ihpx and the second vertical size Iwpx; next, according to the resolution of the display device and the resolution of the inserted picture, compressing the inserted picture to obtain picture data, step 904 specific process includes: judging the size of the second horizontal size Ihpx and the first horizontal size DHpx, and judging The second longitudinal dimension Iwpx is equal to the first longitudinal dimension DWpx; if the second transverse dimension Ihpx is greater than the first transverse dimension DHpx or the second longitudinal dimension Iwpx is greater than the first longitudinal dimension DWpx, it means that the size of the inserted image in one direction is greater than the size of the display device, and the image compression condition is met (step 905), and the image compression process is executed to compress the size and quality of the inserted image (step 906), and the image data is determined (step 907); size compression is used to sample the inserted image to reduce it to the target resolution, for example, converting a 4K resolution image to a 2K resolution image; quality compression is used to convert the encoding format of the inserted image to reduce it to the target storage space.
[0158] Regarding quality compression, for example, in Android's RGB encoding format, ARGB8888 (int): A, R, G, B components each occupy 8 bits, ARGB8888 (int): A, R, G, B components each occupy 8 bits, for a 1920×1200 picture, when using the ARGB_8888 encoding format, the storage space = 1920*1200*4 / 1024 / 1024 = 8.79MB; when using the ARGB_4444 encoding format, the storage space = 1920*1200*2 / 1024 / 1024 = 4.39MB; therefore, the ARGB_8888 encoding format can be converted to the ARGB_4444 encoding format to reduce the storage space to reach the target storage space, so that the space originally used to store one picture can store two pictures, thereby improving the storage space utilization.
[0159] After the above calculation to obtain the image key and the inserted image is compressed to obtain the image data, Fig.10 In the specific implementation, the picture data in step 306 is stored in the memory cache, which may include:
[0160] Step 1002: Determine a key-value pair corresponding to the inserted picture according to the picture key and corresponding picture data of the inserted picture;
[0161] Step 1004: Store the key-value pair into the memory cache.
[0162] In the embodiment, the picture key of the inserted picture is used as the key object, and the corresponding picture data is used as the value object. The key-value pair <picture key, picture data> corresponding to the inserted picture is determined according to the storage structure of the key-value pair, and then the above key-value pair <picture key, picture data> is stored in the memory cache.
[0163] like Fig.11 As shown, when the key-value pair is stored in the memory cache in the above step 1004, it is necessary to control the storage space of the memory cache using the storage space threshold, and it is necessary to ensure that the storage space of the memory cache storing the image data does not exceed the storage space threshold. Specifically, when storing in the memory, it may include:
[0164] Step 1102, obtaining the storage space of the current memory cache; the storage space of the current memory cache is the sum of the storage space occupied by all key-value pairs stored in the current memory cache;
[0165] Step 1104, when the storage space of the current memory cache does not exceed the storage space threshold, storing the key-value pair into the memory cache;
[0166] Step 1106, when the storage space of the current memory cache exceeds the storage space threshold, a least recently used key-value pair is determined from all key-value pairs stored in the current memory cache using a least recently used algorithm, the least recently used key-value pair is deleted from the memory cache, and the key-value pair is stored in the memory cache.
[0167] First, it is necessary to determine the storage space of the current memory cache based on the sum of the storage space occupied by all key-value pairs stored in the current memory cache, and judge whether the storage space of the current memory cache exceeds the storage space threshold; when the storage space of the current memory cache does not exceed the storage space threshold, it means that the current memory cache has sufficient storage space to accommodate the key-value pair, so the key-value pair can be stored in the memory cache; when the storage space of the current memory cache exceeds the storage space threshold, it means that the storage space in the current memory cache is insufficient to accommodate the key-value pair, triggering the LRU (Least recently used) mechanism, using the least recently used algorithm (LRU algorithm), from all the key-value pairs stored in the current memory cache, determine the least recently used key-value pair, delete the least recently used key-value pair from the memory cache, and store the key-value pair in the memory cache.
[0168] The above LRU mechanism, such as Fig.12 As described above, when the memory cache is full, the data with the lowest probability of being accessed in the future will be eliminated based on the access records of all data in the memory cache. That is to say, through the LRU mechanism, the data that has been accessed recently has the highest probability of being accessed in the future. Assuming that only five key-value pairs can be stored in the memory cache, and the new key-value pair will be inserted at the head of the linked list, five key-value pairs are inserted in succession: A, B, C, D, and E. When a new key-value pair F is inserted, each key-value pair moves back one position, and the key-value pair A at the end is eliminated and deleted from the memory cache. Next, the key-value pair B is read externally. After the key-value pair B is read, it will be marked as active, so it will be moved back to the head, and then a new key-value pair G is inserted, and each key-value pair moves back one position, and the key-value pair C at the end is eliminated.
[0169] This embodiment uses the LRU mechanism to delete the least recently used key-value pair from the memory cache, freeing up storage space to store the key-value pair corresponding to the inserted image into the memory cache.
[0170] Specifically, after the above step 306, the method further includes:
[0171] If the storage status of the inserted picture in the memory cache is stored, the picture data corresponding to the inserted picture in the memory cache is determined.
[0172] In an embodiment, the above-mentioned determining the picture data corresponding to the inserted picture in the memory cache may include:
[0173] According to the picture key corresponding to the inserted picture, a corresponding key-value pair is determined from the memory cache to obtain the picture data in the corresponding key-value pair.
[0174] By determining that the storage status of the inserted image in the memory cache is stored, it means that the inserted image has been inserted in the current device before the current moment and the image data is left in the memory cache. Therefore, the image data can be used directly without loading from the local disk. The image key of the inserted image is used to find the corresponding key-value pair from the internal cache to obtain the image data in the key-value pair. When rendering, the image data can be directly retrieved from the memory, eliminating the process of loading files from the local disk and speeding up the efficiency of image rendering. The above process is also called image reuse, which specifically means reading the image data directly from the memory cache and using it directly. The specific steps are that each time the active interface needs to be re-rendered, all interface elements (including handwriting, image data, etc.) will be redrawn and rendered. When the drawing is triggered, the original data of the image can be read directly from the memory cache. The main situations of image reuse include when the display interface triggers drawing and rendering or when the same image element is inserted.
[0175] After the above steps 306, 1004, and 1106 store the picture data into the memory cache and the above step of determining the picture data corresponding to the inserted picture in the memory cache, calling the picture data from the memory cache to render and display it in the display interface of the application program includes:
[0176] According to the image key, a corresponding key-value pair is found from the memory cache, the image data of the found corresponding key-value pair is called, and the image data is rendered in the application display interface to display the inserted image.
[0177] In the embodiment, according to the picture key, the corresponding key-value pair is found in the memory cache, the picture data of the key-value pair is called to be rendered in the program display interface, the inserted picture is displayed, and the insertion operation of the inserted picture is completed.
[0178] This implementation also provides a temporary image file cache strategy. After the key-value pair is stored in the memory cache, the key-value pair needs to be synchronously saved to the local disk to achieve long-term data preservation, and will not be lost due to power failure of the memory. Specifically, the image key of the key-value pair is used as the file name, and the image data of the key-value pair is stored in the local disk. For example, a new file is created in the local disk with the image key as the file name, and the image data is written to the newly created file to achieve the insertion of the image and store it in the local disk.
[0179] like Fig.13 As shown, based on the image data stored in the local disk, the specific implementation also includes:
[0180] Step 1302, when re-rendering the inserted image, searching the memory cache for a corresponding key-value pair according to the image key of the inserted image;
[0181] Step 1304: if a key-value pair corresponding to the picture key of the inserted picture is found in the memory cache, the picture data in the key-value pair is called to be rendered and displayed in the application display interface;
[0182] Step 1306, if the key-value pair corresponding to the picture key of the inserted picture is not found in the memory cache, the picture key of the inserted picture is used to search the corresponding file name in the local disk, the picture data corresponding to the file name is loaded into the memory cache, and the picture data in the memory cache is called to render and display in the application display interface.
[0183] In an embodiment, when it is necessary to insert another picture that has been inserted before the current moment, the inserted picture needs to be re-rendered. First, according to the picture key of the inserted picture, the corresponding key-value pair is searched in the memory cache; if the key-value pair corresponding to the picture key of the inserted picture is found in the memory cache, it means that the inserted picture has not triggered the LRU mechanism and has not been eliminated from the memory cache, then the picture data in the key-value pair can be directly called to render and display in the application display interface; if the key-value pair corresponding to the picture key of the inserted picture is not found in the memory cache, it means that the inserted picture has triggered the LRU mechanism and has been eliminated from the memory cache, and it can be reloaded from the local disk, and the picture key of the inserted picture is used to search the corresponding file name in the local disk, and the picture data corresponding to the file name is loaded into the memory cache, and the picture data in the memory cache is called to render and display in the application display interface.
[0184] When the display interface switch of the application is triggered, the display interface of the application is switched, and the key-value pairs stored in the memory cache are cleared to release the storage space of the memory cache. When switching to a new display interface, there is no picture on the display interface, and there is no corresponding key-value pair in the memory cache.
[0185] like Fig.14 As described above, after the inserted image is rendered and displayed on the display interface of the application, when the current display interface needs to be saved, the main process includes:
[0186] Step 1402: determining whiteboard data according to the display interface of the application; the whiteboard data includes: picture description data and handwriting description data; the picture description data includes: coordinate information of the picture key and the picture on the display interface of the application; the handwriting description data includes: touch data points corresponding to the handwriting generated by the user when writing on the display interface of the application;
[0187] Step 1404: Write the image data and the whiteboard data into the whiteboard file in the form of a file read and write stream, generate a binary file and store it in the local disk.
[0188] In the embodiment, when the saving mechanism is triggered, according to the display interface of the application, the coordinate information of the picture key and the picture on the display interface of the application is determined as the picture description data, the touch data point corresponding to the handwriting generated by the user when writing on the display interface of the application is determined as the handwriting description data, and the picture description data and the handwriting description data are determined as whiteboard data in the form of IO (file read and write stream);
[0189] Then the image data and whiteboard data are written into the whiteboard file in the form of file read and write streams, a binary file is generated and stored in the local disk; the binary file can be imported into the application of the local device to open, or it can be transferred to other devices to open.
[0190] When the binary file is opened on a local device, the binary file is loaded from the local disk into the memory, and the image data and the whiteboard data are parsed. Then, the corresponding image and handwriting are rendered and displayed in the application display interface according to the image data and the whiteboard data.
[0191] When the binary file is opened on another device, the binary file is transferred to the other device, loaded from the disk of the other device to the memory, and the image data and the whiteboard data are parsed. Then, according to the image data and the whiteboard data, the corresponding image and handwriting are rendered and displayed in the application display interface.
[0192] The present disclosure reduces the space occupied by the inserted pictures in the memory cache by compressing the inserted pictures to obtain the picture data, and can insert and display as many pictures as possible within the limited storage space. Furthermore, by configuring the storage space threshold of the memory cache, the storage space of the memory cache is controlled not to exceed the storage space threshold when the picture data is stored in the memory cache, so that the actual storage space occupied by the application in the memory can be kept in a stable state, and the increase in the number of inserted pictures will not cause the increase in the actual storage space occupied by the application, thereby ensuring the normal operation of the application and the operating system. The strategy optimization method for inserting pictures on the workbench enables the whiteboard to insert a large number of pictures and run smoothly.
[0193] The present disclosure also provides a method for displaying an image. Fig.15 As shown,
[0194] Step 1501, obtaining an insert picture;
[0195] Step 1502, determining a picture insertion threshold;
[0196] Step 1503, obtaining the number of images inserted into the display interface of the application, and determining whether the number of images inserted exceeds the image insertion threshold;
[0197] Step 1508: If the number of inserted pictures exceeds the picture insertion threshold, the insertion operation of inserting the pictures is canceled.
[0198] Step 1504, if the number of inserted pictures does not exceed the picture insertion threshold, then perform an insert operation of inserting the picture and determine the storage status of the inserted picture in the memory cache;
[0199] If the storage status of the inserted image in the memory cache is not stored, then step 1505 is executed to compress the inserted image to obtain image data and then store it in the memory cache; the storage space of the memory cache storing the image data does not exceed the storage space threshold;
[0200] If the storage status of the inserted image in the memory cache is stored, executing step 1506, determining the image data corresponding to the inserted image in the memory cache, and reusing the above image data;
[0201] Step 1507, calling the image data from the memory cache and rendering and displaying it in the display interface of the application.
[0202] The present disclosure also provides another process of a method for displaying an image. Fig.16 As shown,
[0203] Step 1601, obtaining an inserted picture;
[0204] Step 1602, determining the storage status of the inserted image in the memory cache;
[0205] If the storage status of the inserted image in the memory cache is stored, step 1605 is executed to determine the image data corresponding to the inserted image in the memory cache, and the above image data is reused; since the image data in the memory cache is directly reused and no new image data is added, the storage space occupied by the memory cache is not increased, and the storage space occupied by the application is not increased, so the stable operation of the application is maintained;
[0206] If the storage status of the inserted image in the memory cache is not stored, executing step 1603 to obtain the number of inserted images in the display interface of the application program, and determining whether the number of inserted images exceeds the image insertion threshold;
[0207] If the number of inserted pictures exceeds the picture insertion threshold, step 1607 is executed to cancel the insertion operation of the inserted pictures.
[0208] If the number of inserted pictures does not exceed the picture insertion threshold, jump to step 1604, execute the insertion operation of inserting the picture, compress the inserted picture (step 1604), and store the obtained picture data in the memory cache (step 1605); the storage space of the memory cache storing the picture data does not exceed the storage space threshold;
[0209] Step 1606, calling the image data from the memory cache and rendering and displaying it in the display interface of the application.
[0210] The above Fig.15 and Fig.16 Two different processes are recorded respectively, one is to judge whether the number of inserted pictures exceeds the threshold before judging whether there are inserted pictures in the memory cache, and the other is to judge whether the number of inserted pictures exceeds the threshold after judging whether there are inserted pictures in the memory cache. Both methods can limit the maximum space occupied by the application in the memory by limiting the number of inserted pictures, control the memory space occupied by the application in a stable state, and facilitate the stable operation of the application and the operating system. Further, by configuring the storage space threshold of the memory cache, the storage space of the memory cache is controlled not to exceed the storage space threshold when the picture data is stored in the memory cache, so that the actual storage space occupied by the application in the memory can be kept in a stable state, and the increase in the number of inserted pictures will not cause the increase in the actual storage space occupied by the application, thereby ensuring the normal operation of the application and the operating system. By compressing the inserted pictures to obtain picture data, the space occupied by the inserted pictures in the memory cache can be reduced, and more pictures can be inserted and displayed as much as possible within the limited storage space.
[0211] Based on the same inventive concept, a memory optimization method is also provided in an embodiment of the present disclosure, as described in the following embodiment.
[0212] like Fig.17 As shown, the embodiment of the present disclosure provides a memory optimization method, including:
[0213] Step 1702, determining the storage status of the inserted picture in the memory cache according to the inserted picture; the memory cache is configured with a storage space threshold;
[0214] Step 1704: if the storage status of the inserted image in the memory cache is not stored, the inserted image is processed into image data and then stored in the memory cache; the storage space of the memory cache storing the image data does not exceed the storage space threshold;
[0215] Step 1706: Call the image data from the memory cache according to rendering requirements.
[0216] Through the above memory optimization method, a storage space threshold is configured for the memory cache, and the actual storage space occupied by the application is limited; through the storage space threshold configured for the memory cache, the storage space of the memory cache is controlled not to exceed the storage space threshold when the image data is stored in the memory cache, so that the actual storage space occupied by the application in the memory can be kept in a stable state, and the actual storage space occupied by the application will not increase due to the increase in the number of inserted pictures, thereby ensuring the normal operation of the application and the operating system and realizing memory optimization.
[0217] It should be noted that, although the steps of the image display method and the memory optimization method in the present disclosure are described in a specific order in the accompanying drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0218] It should be noted that the acquisition, storage, use, and processing of data in the technical solution disclosed in this disclosure are in compliance with the relevant provisions of national laws and regulations, and various types of data such as personal identity data, operation data, behavioral data, etc. related to individuals, customers, and groups obtained in the embodiments of this disclosure have all been authorized.
[0219] Based on the same inventive concept, the present disclosure also provides a picture display device in the following embodiments. Since the principle of solving the problem in the device embodiment is similar to that in the above picture display method embodiment, the implementation of the device embodiment can refer to the implementation of the above picture display method embodiment, and the repeated parts will not be repeated.
[0220] Fig.18 A schematic diagram of a picture display device in an embodiment of the present disclosure is shown. Fig.18 As shown, the device comprises:
[0221] The memory cache determination module 1801 is used to determine the memory cache according to the available memory of the application; the memory cache is configured with a storage space threshold;
[0222] The inserted picture storage status determination module 1802 is used to obtain the inserted picture and determine the storage status of the inserted picture in the memory cache;
[0223] The picture data storage module 1803 is used for processing the inserted picture into picture data and storing it in the memory cache if the storage state of the inserted picture in the memory cache is not stored; the storage space of the memory cache storing the picture data does not exceed the storage space threshold;
[0224] The rendering and display module 1804 is used to call the image data from the memory cache and render and display it in the display interface of the application.
[0225] It should be noted that the above-mentioned memory cache determination module 1801, the inserted picture storage state determination module 1802, the picture data storage module 1803 and the rendering display module 1804 correspond to steps 302 to 308 in the method embodiment, and the examples and application scenarios implemented by the above-mentioned modules and the corresponding steps are the same, but are not limited to the contents disclosed in the above-mentioned method embodiment. It should be noted that the above-mentioned modules as part of the device can be executed in a computer system such as a set of computer executable instructions.
[0226] Based on the same inventive concept, a memory optimization device is also provided in the embodiments of the present disclosure, as described in the following embodiments. Since the principle of solving the problem in the embodiment of the device is similar to that in the above-mentioned embodiment of the memory optimization method, the implementation of the embodiment of the device can refer to the implementation of the above-mentioned embodiment of the memory optimization method, and the repeated parts will not be repeated.
[0227] Fig.19 A schematic diagram of a memory optimization device in an embodiment of the present disclosure is shown. Fig.19 As shown, the device comprises:
[0228] The inserted picture storage state determination module 1901 is used to determine the storage state of the inserted picture in the memory cache according to the inserted picture; the memory cache is configured with a storage space threshold;
[0229] The picture data storage module 1902 is used for processing the inserted picture into picture data and storing it in the memory cache if the storage state of the inserted picture in the memory cache is not stored; the storage space of the memory cache storing the picture data does not exceed the storage space threshold;
[0230] The image data calling rendering module 1903 is used to call the image data from the memory cache according to rendering requirements.
[0231] It should be noted that the above-mentioned inserted picture storage state determination module 1901, picture data storage module 1902 and picture data call rendering module 1903 correspond to steps 1702 to 1706 in the method embodiment, and the examples and application scenarios implemented by the above-mentioned modules and the corresponding steps are the same, but are not limited to the contents disclosed in the above-mentioned method embodiment. It should be noted that the above-mentioned modules as part of the device can be executed in a computer system such as a set of computer executable instructions.
[0232] Those skilled in the art will appreciate that various aspects of the present disclosure may be implemented as systems, methods or program products. Therefore, various aspects of the present disclosure may be specifically implemented in the following forms, namely: complete hardware implementation, complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as "circuits", "modules" or "systems".
[0233] Refer to the following Fig. 20 The electronic device 2000 according to this embodiment of the present disclosure is described. Fig. 20 The electronic device 2000 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0234] like Fig. 20 As shown, the electronic device 2000 is in the form of a general computing device. The components of the electronic device 2000 may include but are not limited to: the at least one processing unit 2010, the at least one storage unit 2020, and a bus 2030 connecting different system components (including the storage unit 2020 and the processing unit 2010).
[0235] The storage unit stores a program code, which can be executed by the processing unit 2010, so that the processing unit 2010 performs the steps of various exemplary embodiments of the present disclosure described in the above "Exemplary Method" section of this specification. For example, the processing unit 2010 can perform the following steps of the above picture display method embodiment:
[0236] Determining a memory cache according to available memory of the application; the memory cache is configured with a storage space threshold;
[0237] Obtain an inserted picture, and determine a storage status of the inserted picture in the memory cache;
[0238] If the storage state of the inserted image in the memory cache is not stored, the inserted image is processed into image data and then stored in the memory cache; the storage space of the memory cache storing the image data does not exceed the storage space threshold;
[0239] The image data is called from the memory cache and rendered and displayed in the display interface of the application.
[0240] For example, the processing unit 2010 may perform the following steps of the above memory optimization method embodiment:
[0241] Determining, according to the inserted picture, a storage state of the inserted picture in the memory cache; the memory cache is configured with a storage space threshold;
[0242] If the storage state of the inserted image in the memory cache is not stored, the inserted image is processed into image data and then stored in the memory cache; the storage space of the memory cache storing the image data does not exceed the storage space threshold;
[0243] According to rendering requirements, the image data is called from the memory cache.
[0244] The storage unit 2020 may include a readable medium in the form of a volatile storage unit, such as a random access storage unit (RAM) 20201 and / or a cache storage unit 20202 , and may further include a read-only storage unit (ROM) 20203 .
[0245] The storage unit 2020 may also include a program / utility 20204 having a set (at least one) of program modules 20205, such program modules 20205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include the implementation of a network environment.
[0246] Bus 2030 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0247] The electronic device 2000 may also communicate with one or more external devices 2040 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 2000, and / or communicate with any device that enables the electronic device 2000 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed through an input / output (I / O) interface 2050. In addition, the electronic device 2000 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) through a network adapter 2060. As shown, the network adapter 2060 communicates with other modules of the electronic device 2000 through a bus 2030. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 2000, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.
[0248] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0249] In particular, according to an embodiment of the present disclosure, the process described in the above reference flow chart may be implemented as a computer program product, which includes: a computer program, which implements the above-mentioned image display method and memory optimization method when executed by a processor.
[0250] In an exemplary embodiment of the present disclosure, a computer-readable storage medium is also provided, which may be a readable signal medium or a readable storage medium. A program product capable of implementing the above method of the present disclosure is stored thereon. In some possible implementations, various aspects of the present disclosure may also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to cause the terminal device to execute the steps according to various exemplary implementations of the present disclosure described in the above “Exemplary Method” section of this specification.
[0251] More specific examples of computer-readable storage media in the present disclosure may include, but are not limited to, an electrical connection having one or more conductors, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0252] In the present disclosure, a computer readable storage medium may include a data signal propagated in baseband or as part of a carrier wave, wherein a readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A readable signal medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0253] Alternatively, the program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.
[0254] In a specific implementation, the program code for performing the operations of the present disclosure may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., using an Internet service provider to connect through the Internet).
[0255] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.
[0256] In addition, although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0257] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0258] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the appended claims.
Claims
1. A method for displaying an image, characterized in that: include: Determining a memory cache according to available memory of the application; the memory cache is configured with a storage space threshold; Obtain an inserted picture, and determine a storage status of the inserted picture in the memory cache; If the storage state of the inserted image in the memory cache is not stored, the inserted image is processed into image data and then stored in the memory cache; the storage space of the memory cache storing the image data does not exceed the storage space threshold; The image data is called from the memory cache and rendered and displayed in the display interface of the application.
2. The image display method according to claim 1, characterized in that: Also includes: If the storage status of the inserted picture in the memory cache is stored, the picture data corresponding to the inserted picture in the memory cache is determined.
3. The image display method according to claim 1, characterized in that: Based on the available memory for the application, determine the memory cache, including: According to the available memory of the application, a memory cache with a set memory space is determined in the memory where the application is running, and a storage space threshold is configured for the memory cache.
4. The image display method according to claim 2, characterized in that: The memory cache stores a key-value pair; the key-value pair is a data storage structure composed of a picture key as a key object and picture data as a value object; Determining the storage status of the inserted picture in the memory cache includes: Determining the image attributes of the inserted image; Determine a picture key according to the picture attributes; Match the image key with the key-value pair in the memory cache to determine the storage status of the inserted image in the memory cache; wherein; if the image key matches the image key of the key-value pair in the memory cache successfully, then determine that the storage status of the inserted image in the memory cache is stored; if the image key matches the image key of the key-value pair in the memory cache unsuccessfully, then determine that the storage status of the inserted image in the memory cache is not stored.
5. The image display method according to claim 4, characterized in that: The image attributes include: file path, the last modification time of the file, and file size; Determining a picture key according to the picture attribute includes: Determine file parameters according to the file path, the last modification time of the file and the file size; The MD5 value obtained by calculating the file parameters using the information digest MD5 algorithm is determined as the image key.
6. The image display method according to claim 4, characterized in that: The picture data is stored in the memory cache, including: Determine a key-value pair corresponding to the inserted picture according to the picture key and the corresponding picture data of the inserted picture; The key-value pair is stored in the memory cache.
7. The image display method according to claim 6, characterized in that: Storing the key-value pair in the memory cache includes: Obtaining the storage space of the current memory cache; the storage space of the current memory cache is the sum of the storage space occupied by all key-value pairs stored in the current memory cache; When the storage space of the current memory cache does not exceed the storage space threshold, storing the key-value pair in the memory cache; When the storage space of the current memory cache exceeds the storage space threshold, a least recently used key-value pair is determined from all key-value pairs stored in the current memory cache using a least recently used algorithm, the least recently used key-value pair is deleted from the memory cache, and the key-value pair is stored in the memory cache.
8. The image display method according to claim 4, characterized in that: Determining the picture data corresponding to the inserted picture in the memory cache includes: According to the picture key corresponding to the inserted picture, a corresponding key-value pair is determined from the memory cache to obtain the picture data in the corresponding key-value pair.
9. The image display method according to claim 8, characterized in that: Calling the image data from the memory cache and rendering and displaying it in the display interface of the application program includes: According to the image key, a corresponding key-value pair is found from the memory cache, the image data of the found corresponding key-value pair is called, and the image data is rendered in the application display interface to display the inserted image.
10. The image display method according to claim 6, characterized in that: Also includes: After the key-value pair is stored in the memory cache, the image data of the key-value pair is stored in the local disk using the image key of the key-value pair as the file name.
11. The image display method according to claim 10, characterized in that: Also includes: When re-rendering the inserted image, searching the memory cache for a corresponding key-value pair according to the image key of the inserted image; If a key-value pair corresponding to the picture key of the inserted picture is found in the memory cache, the picture data in the key-value pair is called to be rendered and displayed in the application display interface; If the key-value pair corresponding to the picture key of the inserted picture is not found in the memory cache, the picture key of the inserted picture is used to search the corresponding file name in the local disk, the picture data corresponding to the file name is loaded into the memory cache, and the picture data in the memory cache is called to render and display in the application display interface.
12. The image display method according to claim 6, characterized in that: Also includes: When the display interface of the application is switched, the key-value pairs stored in the memory cache are cleared to release the storage space of the memory cache.
13. The image display method according to claim 1, characterized in that: Before determining the storage status of the inserted picture in the memory cache, the method further includes: Determining a picture insertion threshold according to the available memory of the application, the cache coefficient of the memory cache, and the memory space occupied by the picture with a set resolution; Obtaining the number of images inserted into the display interface of the application, and determining whether the number of images inserted exceeds the image insertion threshold; If the number of inserted pictures does not exceed the picture insertion threshold, performing the insertion operation of the inserted picture, and determining the storage status of the inserted picture in the memory cache; If the number of inserted pictures exceeds the picture insertion threshold, the insertion operation of the inserted pictures is canceled.
14. The image display method according to claim 1, characterized in that: After the storage status of the inserted picture in the memory cache is not stored, the method further includes: Determining a picture insertion threshold according to the available memory of the application, the cache coefficient of the memory cache, and the memory space occupied by the picture with a set resolution; Obtaining the number of images inserted into the display interface of the application, and determining whether the number of images inserted exceeds the image insertion threshold; If the number of inserted pictures does not exceed the picture insertion threshold, the insertion operation of the inserted pictures is performed, and the inserted pictures are processed into picture data and then stored in the memory cache; If the number of inserted pictures exceeds the picture insertion threshold, the insertion operation of the inserted pictures is canceled.
15. The image display method according to claim 1, characterized in that: Processing the inserted picture into picture data includes: Obtaining the resolution of the display device running the application; Determining the resolution of the inserted picture; According to the resolution of the display device and the resolution of the inserted picture, the inserted picture is compressed to obtain picture data.
16. The image display method according to claim 15, characterized in that: The resolution of the display device includes: a first horizontal dimension and a first vertical dimension; the resolution of the inserted picture includes: a second horizontal dimension and a second vertical dimension; According to the resolution of the display device and the resolution of the inserted picture, compressing the inserted picture to obtain picture data includes: If the second horizontal dimension is larger than the first horizontal dimension or the second vertical dimension is larger than the first vertical dimension, the inserted picture is size compressed and quality compressed to determine the picture data; the size compression is used to sample the inserted picture to reduce it to the target resolution; the quality compression is used to convert the encoding format of the inserted picture to reduce it to the target storage space.
17. The image display method according to claim 1, characterized in that: Also includes: Determining whiteboard data according to a display interface of the application; The whiteboard data includes: picture description data and handwriting description data; the picture description data includes: coordinate information of the picture key and the picture on the application display interface; the handwriting description data includes: touch data points corresponding to the handwriting generated by the user when writing on the display interface of the application; The image data and the whiteboard data are written into the whiteboard file in the form of a file read and write stream, and a binary file is generated and stored in a local disk.
18. The image display method according to claim 17, characterized in that: Also includes: Load the binary file from the local disk into the memory, and parse the image data and the whiteboard data; According to the image data and the whiteboard data, the corresponding image and handwriting are rendered and displayed in the application display interface.
19. A picture display device, characterized in that: include: A memory cache determination module, used to determine a memory cache according to the available memory of the application; the memory cache is configured with a storage space threshold; An inserted picture storage status determination module, used to obtain an inserted picture and determine the storage status of the inserted picture in the memory cache; A picture data storage module, configured to process the inserted picture into picture data and store it in the memory cache if the storage state of the inserted picture in the memory cache is not stored; the storage space of the memory cache storing the picture data does not exceed the storage space threshold; A rendering and display module is used to call the image data from the memory cache and render and display it in the display interface of the application.
20. A memory optimization method, characterized in that: include: Determining, according to the inserted picture, a storage state of the inserted picture in the memory cache; The memory cache is configured with a storage space threshold; If the storage state of the inserted image in the memory cache is not stored, the inserted image is processed into image data and then stored in the memory cache; the storage space of the memory cache storing the image data does not exceed the storage space threshold; According to rendering requirements, the image data is called from the memory cache.
21. A memory optimization device, characterized in that: include: An inserted picture storage state determination module, used to determine the storage state of the inserted picture in the memory cache according to the inserted picture; The memory cache is configured with a storage space threshold; A picture data storage module, configured to process the inserted picture into picture data and store it in the memory cache if the storage state of the inserted picture in the memory cache is not stored; the storage space of the memory cache storing the picture data does not exceed the storage space threshold; The image data calls the rendering module, which is used to call the image data from the memory cache according to rendering requirements.
22. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to execute the image display method described in any one of claims 1 to 18 or the memory optimization method described in claim 20 by executing the executable instructions.
23. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the image display method described in any one of claims 1 to 18 or the memory optimization method described in claim 20 is implemented.