Picture rendering method and device, equipment and storage medium
Through segmented rendering and buffer pool management technology, the problems of memory overflow and low rendering performance during high-definition long image display are solved, and efficient and smooth image display is achieved, improving the user experience.
Patent Information
- Application Number
- CN202411079665.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-07
- Publication Date
- 2024-11-12
AI Technical Summary
When the existing technology displays high-definition long images, the application memory usage has increased sharply, which may cause memory overflow and affect the user experience. The traditional rendering method cannot load new content in time, resulting in poor sliding and delayed response, and cannot completely solve the performance. and experience issues.
By obtaining the original size of the image to be rendered, determining the scaling ratio and actual display size, rendering in segments and using buffer pool management, reducing memory usage, improving rendering efficiency, and ensuring image quality.
It effectively reduces memory usage, improves rendering efficiency, shortens rendering waiting time, improves user experience, avoids lag and delay, and provides a smooth image browsing experience.
Smart Images

Figure CN118939364A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a picture rendering method, device, equipment and storage medium. Background Art
[0002] With the popularity of smart phones and the rapid development of mobile Internet, more and more applications need to display various high-definition long images on mobile devices, such as picture sharing on social media platforms, infographics in news and information applications, product details pages on e-commerce platforms, etc. However, when displaying these long images, existing technologies have many shortcomings and challenges.
[0003] Current image display technology usually loads the entire image at once. For high-resolution, large-size long images, this method will cause the application memory usage to increase dramatically, even exceeding the device's memory capacity. Especially on mobile devices, where memory resources are relatively limited, it is easy to cause memory overflow and cause the application to crash.
[0004] The rendering of long images requires high GPU performance of the device. Large-size images require more GPU processing power. If the image size exceeds the processing power of the device GPU, it will cause CPU and GPU resource competition, affecting the normal operation of other applications. Insufficient rendering performance will cause interface freezes and frame drops, seriously affecting the user experience.
[0005] When users scroll through long images, traditional rendering methods cannot load new content in time, resulting in unsmooth scrolling, delayed response, and even white screens, incomplete image loading, and other problems. These problems greatly affect the user's browsing experience and satisfaction with the application.
[0006] Existing solutions mainly focus on reducing memory usage and improving rendering speed by compressing images or reducing image resolution. However, this method will lead to a decline in image quality and cannot meet users' demand for high-definition images. At the same time, although the existing segmented loading technology can alleviate memory and rendering pressure to a certain extent, it still has shortcomings when processing ultra-large-size long images and cannot completely solve performance and experience problems.
[0007] Therefore, a new technical solution is urgently needed that can effectively optimize the rendering process of long images, reduce memory usage, improve rendering efficiency, and provide a smooth user experience while ensuring image quality. Summary of the invention
[0008] The main purpose of the present invention is to provide a method, device, equipment and storage medium for image rendering, aiming to solve the technical problem that the existing image rendering technology has low performance and poor effect in rendering long images.
[0009] To achieve the above object, the present invention provides a picture rendering method, which comprises the following steps:
[0010] Obtaining a picture to be rendered, and identifying the original size of the picture to be rendered;
[0011] Determine a scaling ratio of the image to be rendered according to a display device to which the image to be rendered is applied, and determine an actual size of the image to be rendered according to the original size and the scaling ratio;
[0012] Determine a single-segment rendering length, determine a total number of segments n according to the single-segment rendering length and the actual size, and generate a pixel data group according to the total number of segments and the image to be rendered;
[0013] The number m of displayable segments is determined according to the display device, a picture display control group is created according to the number m of displayable segments, and a rendering operation is performed using the picture display control and the pixel data group.
[0014] Optionally, the step of performing a rendering operation using the image display control and the pixel data group includes:
[0015] Rendering the m pixel data in the pixel data group to the m picture display controls in the picture display control group;
[0016] When the mth picture display control has been displayed in a preset size in the display device, the m+1th picture display control is rendered from the buffer pool to the lower end of the mth picture display control.
[0017] Optionally, after the step of rendering the m+1th picture display control to the lower end of the mth picture display control, the method further includes:
[0018] The topmost picture display control among the m picture display controls is moved into the buffer pool.
[0019] Optionally, after the step of moving the topmost image display control among the m image display controls into the buffer pool, the method further includes:
[0020] If the image to be rendered continues to be displayed downward by the display device, when the m+1th image display control has displayed a preset size in the display device, the m+2th image display control is rendered from the cache pool to the lower end of the m+1th image display control;
[0021] If the image to be rendered continues to be displayed downward by the display device, the above steps are repeated until the last pixel data of the image to be rendered is displayed by the display device.
[0022] Optionally, after the step of moving the topmost image display control among the m image display controls into the buffer pool, the method further includes:
[0023] If the image to be rendered is displayed upward by the display device, when the first image display control has displayed a preset size in the display device, rendering the cached image display control from the cache pool to the upper end of the first image display control;
[0024] Move the (m+2)th picture display control into the cache pool.
[0025] Optionally, the step of creating a picture display control group according to the number of displayable segments m includes:
[0026] Determine the device performance of the display device and the user rendering requirement, create the image display control group according to the device performance and the user rendering requirement, and the number of image display controls in the image display control group is greater than or equal to m+2.
[0027] Optionally, the step of determining the single-segment rendering length includes:
[0028] The screen width of the display device is used as the single-segment rendering length.
[0029] Furthermore, to achieve the above object, the present invention also provides a picture rendering device, the picture rendering device comprising:
[0030] An image recognition module is used to obtain an image to be rendered and to recognize the original size of the image to be rendered;
[0031] A scaling calculation module, which determines a scaling ratio of the image to be rendered according to a display device to which the image to be rendered is applied, and determines an actual size of the image to be rendered according to the original size and the scaling ratio;
[0032] A pixel segmentation module determines a single segment rendering length, determines a total segment number n according to the single segment rendering length and the actual size, and generates a pixel data group according to the total segment number and the image to be rendered;
[0033] A control rendering module determines the number of displayable segments m according to the display device, creates a picture display control group according to the number of displayable segments m, and performs rendering operations using the picture display control and the pixel data group.
[0034] Furthermore, to achieve the above-mentioned purpose, the present invention also provides an image rendering device, which includes a memory, a processor, and an image rendering program stored in the memory and executable on the processor, and the image rendering program, when executed by the processor, implements the steps of the image rendering method described above.
[0035] Furthermore, to achieve the above-mentioned purpose, the present invention also provides a storage medium, on which a picture rendering program is stored, and when the picture rendering program is executed by a processor, the steps of the picture rendering method described above are implemented.
[0036] The present invention relates to a method for rendering an image, which obtains an image to be rendered, identifies the original size of the image to be rendered, determines the zoom ratio of the image to be rendered according to the display device to which the image to be rendered is applied, and determines the actual size of the image to be rendered displayed in the display device according to the original size and the zoom ratio. Determine the length of a single-segment rendering, determine the total number of segments according to the length of the single-segment rendering and the time size of the image to be rendered displayed in the display device, and generate a pixel data group according to the total number of segments and the image to be rendered; then determine the number of displayable segments according to the display device, create an image display control group according to the number of displayable segments, and use the image display control group to render the pixel data group. The present invention reduces memory usage through segmented rendering and cache management, avoids the problem of memory explosion caused by loading a large amount of data at one time, improves rendering efficiency, shortens rendering waiting time, reduces dependence on device performance, and improves user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 This is a schematic diagram of the structure of the device hardware operating environment involved in the embodiment of the image rendering device of the present invention;
[0038] Figure 2 This is a schematic diagram of the process of the first embodiment of the image rendering method of the present invention;
[0039] Figure 3 Schematic diagram of functional modules of a preferred embodiment of the image rendering device of the present invention.
[0040] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0041] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0042] It should be noted that with the popularity of smart phones and the rapid development of mobile Internet, more and more applications need to display various high-definition long images on mobile devices, such as picture sharing on social media platforms, infographics in news and information applications, product details pages on e-commerce platforms, etc. However, when displaying these long images, the existing technologies have many shortcomings and challenges.
[0043] Current image display technology usually loads the entire image at once. For high-resolution, large-size long images, this method will cause the application memory usage to increase dramatically, even exceeding the device's memory capacity. Especially on mobile devices, where memory resources are relatively limited, it is easy to cause memory overflow and cause the application to crash.
[0044] The rendering of long images requires high GPU performance of the device. Large-size images require more GPU processing power. If the image size exceeds the processing power of the device GPU, it will cause CPU and GPU resource competition, affecting the normal operation of other applications. Insufficient rendering performance will cause interface freezes and frame drops, seriously affecting the user experience.
[0045] When users scroll through long images, traditional rendering methods cannot load new content in time, resulting in unsmooth scrolling, delayed response, and even white screens, incomplete image loading, and other problems. These problems greatly affect the user's browsing experience and satisfaction with the application.
[0046] Existing solutions mainly focus on reducing memory usage and improving rendering speed by compressing images or reducing image resolution. However, this method will lead to a decline in image quality and cannot meet users' demand for high-definition images. At the same time, although the existing segmented loading technology can alleviate memory and rendering pressure to a certain extent, it still has shortcomings when processing ultra-large-size long images and cannot completely solve performance and experience problems.
[0047] Therefore, a new technical solution is urgently needed that can effectively optimize the rendering process of long images, reduce memory usage, improve rendering efficiency, and provide a smooth user experience while ensuring image quality.
[0048] Based on the above defects, the present invention provides a picture rendering device, referring to Figure 1 , Figure 1 It is a structural schematic diagram of the device hardware operating environment involved in the embodiment of the image rendering device of the present invention.
[0049] like Figure 1As shown, the image rendering device may include: a processor 1001, such as a CPU, a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or it may be a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0050] Those skilled in the art will understand that Figure 1 The hardware structure of the image rendering device shown in the figure does not constitute a limitation on the image rendering device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0051] like Figure 1 As shown, the memory 1005 as a storage medium may include an operating system, a network communication module, a user interface module, and a picture rendering program. The operating system is a program for managing and controlling picture rendering devices and software resources, and supports the operation of the network communication module, the user interface module, the picture rendering program, and other programs or software; the network communication module is used to manage and control the network interface 1004; and the user interface module is used to manage and control the user interface 1003.
[0052] exist Figure 1 In the hardware structure of the picture rendering device shown, the network interface 1004 is mainly used to connect to the background server and communicate data with the background server; the user interface 1003 is mainly used to connect to the client and communicate data with the client; the processor 1001 can call the picture rendering program stored in the memory 1005 and perform the following operations:
[0053] Obtaining a picture to be rendered, and identifying the original size of the picture to be rendered;
[0054] Determine a scaling ratio of the image to be rendered according to a display device to which the image to be rendered is applied, and determine an actual size of the image to be rendered displayed on the display device according to the original size and the scaling ratio;
[0055] Determine a single-segment rendering length, determine a total number of segments n according to the single-segment rendering length and the actual size, and generate a pixel data group according to the total number of segments and the image to be rendered;
[0056] The number m of displayable segments is determined according to the display device, a picture display control group is created according to the number m of displayable segments, and a rendering operation is performed using the picture display control and the pixel data group.
[0057] Furthermore, the step of performing a rendering operation using the picture display control and the pixel data group includes:
[0058] Rendering the m pixel data in the pixel data group to the m picture display controls in the picture display control group;
[0059] When the mth picture display control has been displayed in a preset size in the display device, the m+1th picture display control is rendered from the buffer pool to the lower end of the mth picture display control.
[0060] Furthermore, after the step of rendering the m+1th picture display control to the lower end of the mth picture display control, the method further includes:
[0061] The topmost picture display control among the m picture display controls is moved into the buffer pool.
[0062] Furthermore, after the step of moving the topmost image display control among the m image display controls into the buffer pool, the method further includes:
[0063] If the image to be rendered continues to be displayed downward by the display device, when the m+1th image display control has displayed a preset size in the display device, the m+2th image display control is rendered from the cache pool to the lower end of the m+1th image display control;
[0064] If the image to be rendered continues to be displayed downward by the display device, the above steps are repeated until the last pixel data of the image to be rendered is displayed by the display device.
[0065] Furthermore, after the step of moving the topmost image display control among the m image display controls into the buffer pool, the method further includes:
[0066] If the image to be rendered is displayed upward by the display device, when the first image display control has displayed a preset size in the display device, rendering the cached image display control from the cache pool to the upper end of the first image display control;
[0067] Move the (m+2)th picture display control into the cache pool.
[0068] Furthermore, the step of creating a picture display control group according to the number of displayable segments m includes:
[0069] Determine the device performance of the display device and the user rendering requirement, create the image display control group according to the device performance and the user rendering requirement, and the number of image display controls in the image display control group is greater than or equal to m+2.
[0070] Furthermore, the step of determining the single-segment rendering length includes:
[0071] The screen width of the display device is used as the single-segment rendering length.
[0072] The specific implementation of the image rendering device of the present invention is basically the same as the various embodiments of the image rendering method described below, and will not be repeated here.
[0073] The present invention also provides a picture rendering method based on the picture rendering device.
[0074] Reference Figure 2 , Figure 2 Schematic diagram of the process of the first embodiment of the image rendering method of the present invention.
[0075] The embodiment of the present invention provides an embodiment of the image rendering method. It should be noted that although a logical order is shown in the flow chart, in some cases, the steps shown or described may be executed in an order different from that shown here.
[0076] In various embodiments of the image rendering method, the execution subject is an image rendering device.
[0077] The image rendering method is applied to an image rendering device, and the image rendering method includes:
[0078] Step S10, obtaining a picture to be rendered, and identifying the original size of the picture to be rendered;
[0079] With the popularity of smart phones and the rapid development of mobile Internet, more and more applications need to display various high-definition long images on mobile devices, such as picture sharing on social media platforms, infographics in news and information applications, product details pages on e-commerce platforms, etc. However, when displaying these long images, existing technologies have many shortcomings and challenges.
[0080] Current image display technology usually loads the entire image at once. For high-resolution, large-size long images, this method will cause the application memory usage to increase dramatically, even exceeding the device's memory capacity. Especially on mobile devices, where memory resources are relatively limited, it is easy to cause memory overflow and cause the application to crash.
[0081] The rendering of long images requires high GPU performance of the device. Large-size images require more GPU processing power. If the image size exceeds the processing power of the device GPU, it will cause CPU and GPU resource competition, affecting the normal operation of other applications. Insufficient rendering performance will cause interface freezes and frame drops, seriously affecting the user experience.
[0082] When users scroll through long images, traditional rendering methods cannot load new content in time, resulting in unsmooth scrolling, delayed response, and even white screens, incomplete image loading, and other problems. These problems greatly affect the user's browsing experience and satisfaction with the application.
[0083] Existing solutions mainly focus on reducing memory usage and improving rendering speed by compressing images or reducing image resolution. However, this method will lead to a decline in image quality and cannot meet users' demand for high-definition images. At the same time, although the existing segmented loading technology can alleviate memory and rendering pressure to a certain extent, it still has shortcomings when processing ultra-large-size long images and cannot completely solve performance and experience problems.
[0084] Therefore, a new technical solution is urgently needed that can effectively optimize the rendering process of long images, reduce memory usage, improve rendering efficiency, and provide a smooth user experience while ensuring image quality.
[0085] The image rendering method in this embodiment is applicable to a device having an image rendering method function.
[0086] In this embodiment, the image to be rendered is first obtained. The image to be rendered is generally a giant long image (such as a high-definition poster, a series of images with one picture to understand, and similar images with memory exceeding hundreds of MB or even GB). Using common image controls to directly render images will cause the memory usage of the app to soar. If the image size exceeds the maximum size that the device GPU can handle, it will block the CPU's computing power. The result is that the user will wait for a long time for rendering, resulting in frame drops, freezing, or even direct crashes and flashbacks, which seriously affects the user experience.
[0087] The way to obtain the image to be rendered can be to obtain the image to be rendered through a network request, and use an HTTP request to download the long image to be rendered from a remote server. This can be achieved by using an appropriate network library or API, such as the requests library in Python, the HttpURLConnection class in Java, or the fetch API in JavaScript.
[0088] Download the target image file by sending an HTTP GET request, ensure the request is successful and save the file to local storage. When sending the request, you can handle possible errors, such as network interruption or unavailable resources.
[0089] After the download is complete, use an image processing library to read the image file and obtain its original size. Common image processing libraries include the PIL (Pillow) library in Python, the ImageIO class in Java, or the HTMLImageElement object in JavaScript.
[0090] After reading the image, get the original size of the image (w1*h1), that is, the width (w1) and height (h1). These sizes are used to calculate the actual display size of the image on the target device and determine the single-segment rendering length and the total number of segments. Image processing libraries usually provide methods for obtaining image sizes, such as the size attribute in the PIL library.
[0091] Step S20, determining a scaling ratio of the image to be rendered according to the display device to which the image to be rendered is applied, and determining an actual size of the image to be rendered displayed on the display device according to the original size and the scaling ratio;
[0092] In this embodiment, determining the scaling ratio of the image according to the display device to which the image is to be rendered, and determining the actual size of the image in the display device according to the original size and the scaling ratio are key steps to ensure that the image is displayed at the best ratio on different devices. The specific steps may include:
[0093] Get the display device size: Get the width and height of the display device. This can be obtained through the device API. For example, use the window manager or screen object on a mobile device to get the screen size. The width and height of the display device can be the width and height of the screen used by the display device for actual display.
[0094] Determine the image's scaling ratio: Based on the image's original width (w1) and height (h1), and the device's width (w 设备 ) and height (h 设备 ), the scaling factor (s) is calculated based on the short side of the image. If the image height (h1) is greater than the width (w1), the width is used to calculate the scaling factor Otherwise, use the height to calculate the scale factor
[0095] Calculate the actual display size: Use the above calculated scaling ratio (s) to determine the actual display size of the image on the display device, that is, the actual height h2 required to display on the device (the total size required to render on the device is w2*h2). Figure 1 The height is usually larger than the width, so the width is used to calculate the scaling ratio. The actual display width (w2) is the device width (w 设备 ), the actual display height (h2) is the original height (h1) multiplied by the scaling ratio (s), that is, h2 = h1*s.
[0096] In this way, the image is displayed in the appropriate proportion on the device, neither distorted nor exceeding the device display range.
[0097] Example description:
[0098] Assume there is a long image whose original size is 3000 pixels wide and 9000 pixels high. The following steps can be used to determine its actual display size on the target device.
[0099] Get the display device size: Assume that the target device has a width of 1080 pixels and a height of 1920 pixels.
[0100] Calculate the scaling ratio: Since the image height (9000 pixels) is greater than the width (3000 pixels), use the width to calculate the scaling ratio
[0101] Determine the actual display size: actual display width w2 = 1080 pixels. Actual display height h2 = 9000*0.36 = 3240 pixels.
[0102] Step S30, determining a single-segment rendering length, determining a total number of segments n according to the single-segment rendering length and the actual size, and generating a pixel data group according to the total number of segments and the image to be rendered;
[0103] In this embodiment, determining the length of a single segment rendering, determining the total number of segments n according to the single segment rendering length and the actual size, and generating a pixel data group are important steps to achieve long image optimized rendering. The specific steps may include:
[0104] Determine the single-segment rendering length a: The single-segment rendering length a is usually set to the screen width of the display device or other suitable length to facilitate segment processing and rendering. In this embodiment, it is assumed that we set the screen width of the display device w 设备 Set to single segment rendering length a.
[0105] Calculate the total number of segments n: The total number of segments n can be calculated using the actual display height h2 and the single segment rendering length a. The calculation formula is: Indicates rounding up. For example, if the actual display height h2 = 3240 pixels and the single segment rendering length a = 1080 pixels, then the total number of segments is
[0106] Generate pixel data group: Divide the image to be rendered into several pixel data according to the single-segment rendering length a. Each data represents a rendering segment, and all pixel data form a pixel data group. First, read the pixel data of the image, divide the data into n data to form a data group data (data is a data array, and the data subscript is 0 to n-1). For example, the original pixel data of the image can be divided into 3 parts, each part contains a data block of 1080×1080 pixels. These segmented pixel data will be stored in a pixel data group for subsequent rendering operations.
[0107] Example description:
[0108] Assume there is a long image whose original size is 3000 pixels wide and 9000 pixels high. The following steps can be used to generate a pixel data set:
[0109] Determine the single-segment rendering length: Set the single-segment rendering length a to the screen width of the display device, 1080 pixels.
[0110] Calculate the total number of segments: Using the actual display height of 3240 pixels and the single segment rendering length of 1080 pixels, calculate the total number of segments n = 3.
[0111] Generate pixel data group: Divide the image into 3 pixel data, each pixel data corresponds to a rendering segment. These pixel data will be stored in a pixel data group for use in subsequent rendering.
[0112] Step S40, determining the number of displayable segments m according to the display device, creating a picture display control group according to the number of displayable segments m, and performing a rendering operation using the picture display control and the pixel data group.
[0113] In this embodiment, determining the number of displayable segments m of the display device, creating a picture display control group according to the number of displayable segments m, and using these controls and pixel data groups to perform rendering operations are key steps to achieve long picture optimization rendering. The specific implementation steps may be:
[0114] Determine the number of displayable segments: based on the screen height h of the display device 设备 and the single segment rendering length a, calculate the number of segments m that can be displayed simultaneously on the device screen. The calculation formula is: For example, if the device's screen height is 1920 pixels and the single segment rendering length a is 1080 pixels, the number of segments that can be displayed is
[0115] Create an image display control group: Create an image display control group based on the calculated number of displayable segments m. To ensure that there are always enough controls for display and caching during the sliding process, at least m+2 image display controls are usually created. For example, if the number of displayable segments m=2, at least 2+2=4 image display controls are created.
[0116] Rendering operation using image display controls and pixel data groups: Assign the generated pixel data groups to the image display control groups for rendering. During initialization, render the first m pixel data to the corresponding image display controls, and render these controls to the screen. The remaining controls are used for preloading and caching to ensure that new content can be rendered in time when the user slides.
[0117] The present invention relates to a method for rendering an image, which obtains an image to be rendered, identifies the original size of the image to be rendered, determines the zoom ratio of the image to be rendered according to the display device to which the image to be rendered is applied, and determines the actual size of the image to be rendered displayed in the display device according to the original size and the zoom ratio. Determine the length of a single-segment rendering, determine the total number of segments according to the length of the single-segment rendering and the time size of the image to be rendered displayed in the display device, and generate a pixel data group according to the total number of segments and the image to be rendered; then determine the number of displayable segments according to the display device, create an image display control group according to the number of displayable segments, and use the image display control group to render the pixel data group. The present invention reduces memory usage through segmented rendering and cache management, avoids the problem of memory explosion caused by loading a large amount of data at one time, improves rendering efficiency, shortens rendering waiting time, reduces dependence on device performance, and improves user experience.
[0118] Furthermore, a second embodiment of the image rendering method of the present invention is proposed. In the above step S40, the step of performing a rendering operation using the image display control and the pixel data group includes:
[0119] Step a1, rendering the m pixel data in the pixel data group to the m picture display controls in the picture display control group;
[0120] Step a2: when the mth picture display control has displayed a preset size in the display device, rendering the (m+1)th picture display control from the buffer pool to the lower end of the mth picture display control.
[0121] In this embodiment, a rendering operation is performed using a picture display control and a pixel data group, and m pixel data in the pixel data group are rendered to m picture display controls in the picture display control group. When the mth picture display control has displayed a preset size in the display device, the m+1th picture display control is rendered from the buffer pool to the bottom of the mth picture display control.
[0122] Specific steps may include:
[0123] Initialization rendering: Render the first m pixel data in the pixel data group into the first m picture display controls, and render these controls onto the screen. For example, if the number of displayable segments m=2, render the first two pixel data in the pixel data group into the first two picture display controls, respectively, and display them on the screen.
[0124] Monitor the display status: When the user starts to scroll the long image, monitor the display status of the mth image display control on the screen in real time. When the mth image display control is displayed to a preset size (for example, to 50%), prepare for the next operation.
[0125] Render new controls from the buffer pool: When the mth image display control is detected to be displayed at the preset size, the m+1th image display control is taken from the buffer pool and rendered to the bottom of the mth image display control. The pixel data required by the m+1th image display control is asynchronously loaded to ensure that new content can be displayed in time when the user continues to scroll.
[0126] The example is as follows: Assuming that the device screen height is 1920 pixels, the single segment rendering length is 1080 pixels, the pixel data group of the long image has been generated, and the number of displayable segments m=2, the specific operations are as follows:
[0127] Render the first two pixel data in the pixel data group into the first two image display controls, and render these controls on the screen. Monitor the display of the second image display control on the screen in real time.
[0128] When the second control is displayed to a preset size (such as 50%), prepare to render a new control.
[0129] When the second control is displayed to the preset size, the third control is taken out from the buffer pool, rendered to the bottom of the second control, and the pixel data required by the third control is asynchronously loaded.
[0130] Through the above steps, this embodiment can ensure smooth display of long images on mobile devices and improve user experience.
[0131] Furthermore, a third embodiment of the image rendering method of the present invention is proposed. In the above step a2, after the step of rendering the m+1th image display control to the lower end of the mth image display control, the method further includes:
[0132] Step b1, moving the topmost picture display control among the m picture display controls into the buffer pool.
[0133] In this embodiment, in the method of the present invention, after the step of rendering the m+1th picture display control to the lower end of the mmth picture display control, the method further includes moving the topmost picture display control among the m picture display controls into the buffer pool. Managing the buffer pool is an important step in ensuring smooth display of long images on mobile devices. The following is a detailed specific implementation method, including how to initialize the buffer pool, manage controls entering and exiting the buffer pool, and dynamically update the buffer pool during scrolling. The specific steps may include:
[0134] Initialize the buffer pool: Create and initialize the buffer pool before starting rendering. The buffer pool is used to store image display controls that are not displayed on the screen but are ready for rendering. For example, initialize an empty buffer pool list or queue.
[0135] Move controls into the buffer pool: When a picture display control completely moves off the screen during scrolling, remove the control from the display area and put it into the buffer pool for standby. For example, when the user continues to pull up and the top picture display control moves off the screen, add it to the buffer pool.
[0136] Take out controls from the buffer pool: When a new image display control needs to be rendered, take out a control from the buffer pool, update its pixel data, and render it to the screen. For example, when the user continues to pull up and the second control is displayed to the preset size, take out a new control from the buffer pool and render it below the second control.
[0137] Load data asynchronously: The control taken out of the buffer pool needs to load new pixel data asynchronously to ensure that the rendering process does not block the user's scrolling operation. For example, use asynchronous methods to load new pixel data and update the control content.
[0138] Dynamically adjust the buffer pool size: Dynamically adjust the buffer pool size based on device performance and user scrolling speed to ensure that there are enough controls to quickly replace and display new content. For example, the buffer pool size can be reduced on high-performance devices and increased on low-performance devices.
[0139] This embodiment can ensure the smooth display of long images on mobile devices through the above method, significantly improving the user experience. This optimization method not only greatly reduces memory usage and improves rendering efficiency, but also ensures the continuous and instant loading of images when users slide quickly. Users can enjoy a seamless scrolling experience and avoid common freezes, delays or white screens. In addition, the strategy of dynamically adjusting the buffer pool size and asynchronously loading data enables the method to adapt to devices with different performance and provide a consistent high-quality user experience.
[0140] Furthermore, a fourth embodiment of the image rendering method of the present invention is proposed, which, after the above step b1, further includes:
[0141] Step c1, if the image to be rendered continues to be displayed downward by the display device, when the m+1th image display control has displayed a preset size in the display device, rendering the m+2th image display control from the cache pool to the lower end of the m+1th image display control;
[0142] Step c2: if the image to be rendered continues to be displayed downward by the display device, the above steps are repeated until the last pixel data of the image to be rendered is displayed by the display device.
[0143] In this embodiment, continuing to display downward is one of the important steps to ensure smooth display of long images on mobile devices. The specific steps may include:
[0144] If the image to be rendered continues to be displayed downward by the display device, when the m+1th control has displayed a preset size (eg, 50%) in the display device, the m+2th control is taken out from the buffer pool and rendered to the bottom of the m+1th control.
[0145] If the image to be rendered continues to be displayed downward by the display device, repeat the above steps, take out the next control from the buffer pool, and render it to the bottom of the m+2th control, so as to push it inward to ensure that the new content can be displayed in time when the user continues to scroll, until the last pixel data of the image to be rendered is displayed.
[0146] For example, if the number of displayable segments m=2, render the first two pixel data in the pixel data group to the first two picture display controls respectively, and render these controls to the screen so that the user can see the initial image content. Monitor the display of the second picture display control on the screen in real time. When the second control is displayed to a preset size (e.g., 50%), prepare to take out a new control from the buffer pool for rendering. Take out the third control from the buffer pool and render it to the bottom of the second control. At the same time, asynchronously load the pixel data required by the third control to ensure that its content can be updated and displayed in time.
[0147] After the third control is rendered, the first control is moved into the buffer pool for subsequent use. In this way, there are always enough controls in the buffer pool to cope with the user's continued scrolling needs.
[0148] If the image to be rendered continues to be displayed downward, when the third control is displayed to the preset size, the fourth control is taken out from the buffer pool and rendered to the bottom of the third control.
[0149] Asynchronously load the pixel data of the fourth control to ensure that the content can be updated in time.
[0150] If the image to be rendered continues to be displayed downward, the above steps are repeated to monitor the newly displayed controls, and continue to take out new controls from the buffer pool and render them. In this way, when the user continues to scroll, new content can be displayed in time, and a smooth browsing experience is always maintained until the last pixel data of the image to be rendered is displayed.
[0151] In addition, according to the device performance and current scrolling speed, the system can dynamically adjust the size of the buffer pool and the number of controls to ensure the best rendering effect on different devices. The number of controls in the buffer pool can be reduced on high-performance devices, while the number of controls can be increased on low-performance devices to balance performance and display effects.
[0152] Through the above steps, this embodiment can effectively manage the segmented rendering process of long images, ensuring that new image content can be displayed in a timely manner when the user scrolls and browses, thereby improving the user experience and avoiding problems such as freezes and delays.
[0153] Furthermore, a fifth embodiment of the image rendering method of the present invention is proposed, which, after the above step b1, further includes:
[0154] Step d1, if the image to be rendered is displayed upward by the display device, when the first image display control has displayed a preset size in the display device, rendering the cached image display control from the cache pool to the upper end of the first image display control;
[0155] Step d2, moving the (m+2)th picture display control into the cache pool.
[0156] In this embodiment, if the image to be rendered is displayed upward by the display device, when the first image display control has displayed the preset size in the display device, the cached image display control is taken out from the buffer pool and rendered to the upper end of the first image display control. The m+2th image display control is moved into the buffer pool to ensure that there are enough controls for rapid replacement and display of new content. If the image to be rendered is continuously displayed upward by the display device, the above steps are repeated to ensure that new content can be displayed in time when the user scrolls upward until the first pixel data of the long image is displayed.
[0157] For example, when the user scrolls up the page, the system continuously monitors the scrolling of the first currently displayed control. When the control is displayed to the set threshold (such as 50%), the cached control (such as the m+2th control) is taken out from the buffer pool and placed above the current first control. The image data of the cached control is loaded asynchronously to ensure that its content can be updated and displayed in time.
[0158] During the user's fast scrolling, the system can monitor the display of controls in the current display area in real time, and trigger new control rendering in time when the control is displayed to the preset size. This ensures that there will be no blank areas when the user scrolls quickly, and the new content can be seamlessly connected to provide a smooth interactive experience. Every time a new control is taken out of the buffer pool, the system will asynchronously load the pixel data of the control to ensure that the data loading process does not block the main thread and avoid interface freezes. After the asynchronous loading is completed, the content of the control is updated immediately so that it can be quickly rendered to the screen. Through refined control management and data loading strategies, users can get a continuous and smooth visual experience when browsing long pictures. It avoids common problems such as freezes, delays, and white screens, significantly improving user satisfaction with the application. Through dynamic loading and caching strategies, the system can effectively manage memory and avoid memory overflow caused by loading too much data at one time.
[0159] Through the above steps, this embodiment can effectively manage the segmented rendering process of long images, ensuring that new image content can be displayed in a timely manner when the user scrolls and browses, thereby improving the user experience and avoiding problems such as freezes and delays. It not only improves the rendering efficiency, but also ensures the stability and smoothness of the application.
[0160] Furthermore, a sixth embodiment of the image rendering method of the present invention is proposed. In the above step S40, the step of creating an image display control group according to the number of displayable segments m includes:
[0161] Step e1, determining the device performance of the display device and the user rendering requirements, creating the image display control group according to the device performance and the user rendering requirements, wherein the number of image display controls in the image display control group is greater than or equal to m+2.
[0162] In this embodiment, creating a picture display control group according to the number of displayable segments m is one of the key steps to ensure smooth display of long pictures on mobile devices. The specific steps may include:
[0163] Determine display device performance: Evaluate the device's rendering capabilities by detecting the device's hardware configuration, including processor speed, memory size, GPU performance, etc. For example, high-performance devices can support more parallel rendering controls, while low-performance devices may need to reduce the number of controls to avoid performance bottlenecks.
[0164] Evaluate user rendering needs: Determine the required rendering accuracy and speed based on the user's specific needs and usage scenarios. For example, in high-resolution displays or application scenarios that require fine images, more controls may be required to ensure image quality. Consider the user's scrolling speed and usage habits to determine the number of controls that need to be preloaded and cached.
[0165] Calculate the number of controls: Calculate the number of image display controls required based on device performance and user needs. Typically, the number of image display controls should be greater than or equal to m+2 to ensure that there are enough controls for real-time rendering and preloading.
[0166] Create an image display control group: Create an image display control group based on the calculation results. Ensure that the number of controls can meet the requirements of real-time rendering and preloading. For example, high-performance devices can support more parallel rendering controls, while low-performance devices may need to reduce the number of controls to avoid performance bottlenecks. For example, if the device's asynchronous drawing and rendering capabilities are poor, you need to configure more controls to perform pre-rendering operations in advance. For example, you can reduce the number of controls in the buffer pool on high-performance devices and increase the number of controls on low-performance devices to balance performance and display effects.
[0167] Through the above steps, this embodiment can dynamically adjust the size of the buffer pool and the number of controls according to device performance and user needs, ensuring that the best rendering effect can be provided on different devices.
[0168] Furthermore, a seventh embodiment of the image rendering method of the present invention is proposed. In the above step S30, the step of determining the single-segment rendering length includes:
[0169] Step f1, using the screen width of the display device as the single-segment rendering length.
[0170] In this embodiment, the screen width of the display device is used as the single-segment rendering length.
[0171] By setting the single-segment rendering length to the screen width of the display device, image scaling and cropping operations during the rendering process are avoided, reducing additional calculations and improving rendering performance.
[0172] The width of each rendering segment is consistent with the width of the device screen, ensuring that the image will not be stretched or compressed when displayed, maintaining the original proportion and clarity of the image, and improving the display effect.
[0173] The use of a unified single-segment rendering length simplifies the logic of long image segmentation processing, making the development process more intuitive and simple, and reducing development difficulty and time.
[0174] This method can adapt to devices of different sizes and resolutions. Whether it is a mobile phone, tablet or other mobile device, the length of a single segment rendering can be determined by obtaining the screen width, which has strong adaptability.
[0175] Through the above steps, this embodiment reduces image scaling and cropping operations, improves the response speed of image rendering, and enables users to experience faster response and smoother operation when scrolling through long images.
[0176] The invention also provides a picture rendering device.
[0177] Reference Figure 3 , Figure 3 This is a functional module diagram of a first embodiment of a picture rendering device of the present invention. The picture rendering device comprises:
[0178] An image recognition module is used to obtain an image to be rendered and to recognize the original size of the image to be rendered;
[0179] A scaling calculation module, which determines a scaling ratio of the image to be rendered according to a display device to which the image to be rendered is applied, and determines an actual size of the image to be rendered according to the original size and the scaling ratio;
[0180] A pixel segmentation module determines a single segment rendering length, determines a total segment number n according to the single segment rendering length and the actual size, and generates a pixel data group according to the total segment number and the image to be rendered;
[0181] A control rendering module determines the number of displayable segments m according to the display device, creates a picture display control group according to the number of displayable segments m, and performs rendering operations using the picture display control and the pixel data group.
[0182] In addition, an embodiment of the present invention further provides a storage medium.
[0183] The storage medium stores a picture rendering program, and when the picture rendering program is executed by the processor, the steps of the picture rendering method described above are implemented.
[0184] The specific implementation of the storage medium of the present invention is basically the same as the above-mentioned embodiments of the image rendering method, and will not be repeated here.
[0185] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the enlightenment of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims. All equivalent structures or equivalent process changes made using the contents of the specification and drawings of the present invention, or directly or indirectly used in other related technical fields, are protected by the present invention.
[0186] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to the multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of boxes in the block diagram and / or the flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0187] In addition, each functional module in each embodiment of the present application can be integrated together to form an independent part, or each module can exist separately, or two or more modules can be integrated to form an independent part. If the function is implemented in the form of a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a disk or an optical disk.
[0188] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0189] The above are only various implementations of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method for rendering an image, characterized in that: The image rendering method comprises the following steps: Obtaining a picture to be rendered, and identifying the original size of the picture to be rendered; Determine a scaling ratio of the image to be rendered according to a display device to which the image to be rendered is applied, and determine an actual size of the image to be rendered displayed on the display device according to the original size and the scaling ratio; Determine a single-segment rendering length, determine a total number of segments n according to the single-segment rendering length and the actual size, and generate a pixel data group according to the total number of segments and the image to be rendered; The number m of displayable segments is determined according to the display device, a picture display control group is created according to the number m of displayable segments, and a rendering operation is performed using the picture display control and the pixel data group.
2. The image rendering method according to claim 1, characterized in that: The step of performing a rendering operation using the picture display control and the pixel data group comprises: Rendering the m pixel data in the pixel data group to the m picture display controls in the picture display control group; When the mth picture display control has been displayed in a preset size in the display device, the m+1th picture display control is rendered from the buffer pool to the lower end of the mth picture display control.
3. The image rendering method as claimed in claim 2, characterized in that: After the step of rendering the m+1th picture display control to the lower end of the mth picture display control, the method further includes: The topmost picture display control among the m picture display controls is moved into the buffer pool.
4. The image rendering method according to claim 3, characterized in that: After the step of moving the topmost image display control among the m image display controls into the buffer pool, the method further includes: If the image to be rendered continues to be displayed downward by the display device, when the m+1th image display control has displayed a preset size in the display device, the m+2th image display control is rendered from the cache pool to the lower end of the m+1th image display control; If the image to be rendered continues to be displayed downward by the display device, the above steps are repeated until the last pixel data of the image to be rendered is displayed by the display device.
5. The image rendering method according to claim 3, characterized in that: After the step of moving the topmost image display control among the m image display controls into the buffer pool, the method further includes: If the image to be rendered is displayed upward by the display device, when the first image display control has displayed a preset size in the display device, rendering the cached image display control from the cache pool to the upper end of the first image display control; Move the (m+2)th picture display control into the cache pool.
6. The image rendering method according to claim 1, characterized in that: The step of creating a picture display control group according to the number of displayable segments m comprises: Determine the device performance of the display device and the user rendering requirement, create the image display control group according to the device performance and the user rendering requirement, and the number of image display controls in the image display control group is greater than or equal to m+2.
7. The image rendering method according to claim 1, characterized in that: The step of determining the single-segment rendering length comprises: The screen width of the display device is used as the single-segment rendering length.
8. A picture rendering device, characterized in that: The image rendering device comprises: An image recognition module is used to obtain an image to be rendered and to recognize the original size of the image to be rendered; A scaling calculation module, which determines a scaling ratio of the image to be rendered according to a display device to which the image to be rendered is applied, and determines an actual size of the image to be rendered according to the original size and the scaling ratio; A pixel segmentation module determines a single segment rendering length, determines a total segment number n according to the single segment rendering length and the actual size, and generates a pixel data group according to the total segment number and the image to be rendered; A control rendering module determines the number of displayable segments m according to the display device, creates a picture display control group according to the number of displayable segments m, and performs rendering operations using the picture display control and the pixel data group.
9. A picture rendering device, characterized in that: The image rendering device includes a memory, a processor, and an image rendering program stored in the memory and executable on the processor. When the image rendering program is executed by the processor, the steps of the image rendering method according to any one of claims 1 to 7 are implemented.
10. A storage medium, characterized in that: The storage medium stores a picture rendering program, and when the picture rendering program is executed by the processor, the steps of the picture rendering method according to any one of claims 1 to 7 are implemented.
