Image rendering methods, electronic device and storage medium
By parsing the dynamic image into a stitching diagram of multi-frame images and rendering it with GPU, the problem of excessive CPU resource occupancy during large data processing in traditional image rendering mode is solved, and high frame rate rendering and efficient resource utilization are achieved.
Patent Information
- Application Number
- PCT/IB2024/062975
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-12-21
- Filing Date
- 2024-12-20
- Publication Date
- 2025-06-26
AI Technical Summary
Traditional image rendering mode requires a large amount of CPU resources when processing large data volumes, resulting in application lag and difficulty in achieving high frame rate rendering.
By parsing the dynamic image into a stitching diagram of multi-frame images and rendering it with GPU, parallel rendering of multiple target frame images is achieved, avoiding the CPU-dependent operation of each frame image rendering.
Maintaining high frame rate rendering in large data rendering application scenarios improves rendering efficiency, frees up CPU resources, and avoids blocking of other main thread functions in the application.
Smart Images

Figure IB2024062975_26062025_PF_FP_ABST
Abstract
Description
[0001]Image Rendering Method, Electronic Device, and Storage Medium This disclosure claims priority to Chinese patent application No. 202311779296.7, filed with the China Patent Office on December 21, 2023, entitled "Image Rendering Method, Electronic Device, and Storage Medium," the entire contents of which are incorporated herein by reference. Technical Field This disclosure relates to the field of image processing technology, and more particularly to an image rendering method, electronic device, and storage medium. Background Art With the advent of the big data era, the demand for richer and more intuitive visual effects and high-performance rendering of large-scale data in the visualization field is increasing, and this demand is particularly pronounced for geographic data. However, when rendering and drawing large amounts of data, traditional methods require a large amount of central processing unit (CPU) resources, causing application lag and gradually encountering performance bottlenecks in rendering large amounts of data. SUMMARY OF THE INVENTION Embodiments of the present disclosure provide an image rendering method, electronic device, and storage medium to address or alleviate the problems existing in the prior art. In a first aspect, embodiments of the present disclosure provide an image rendering method, applied to a graphics processing unit (GPU). The method includes: determining a position of a target frame image in a mosaic, wherein the mosaic includes multiple mosaicked image frames, the multiple image frames being selected from at least one dynamic image; texture data and position data corresponding to the mosaic are pre-stored in a graphics memory of the GPU, the position data including the positions of the multiple image frames in the mosaic; determining a position of a target image element corresponding to the target fragment on the target frame image based on a position of a target fragment on a screen; obtaining texture data corresponding to the target image element from the graphics memory based on the position of the target image element on the target frame image and the position of the target frame image in the mosaic; and rendering the target fragment based on the obtained texture data. In a second aspect, embodiments of the present disclosure provide an image rendering method, comprising: generating a mosaic based on at least one resource image, wherein the resource image comprises a dynamic image, and the mosaic comprises multiple stitched-together image frames; generating corresponding texture data and position data for the mosaic, the position data comprising positions of the multiple image frames within the mosaic; and uploading the texture data and position data to a graphics memory of a GPU, so that the GPU performs image rendering based on the texture data and position data. In a third aspect, embodiments of the present disclosure provide an electronic device, comprising a memory, a processor, and a computer program stored in the memory, wherein the processor implements any of the aforementioned methods when executing the computer program.In a fourth aspect, embodiments of the present disclosure provide a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements any of the aforementioned methods. In a fifth aspect, embodiments of the present disclosure provide a computer program. When executed on a computer, the computer program causes the computer to perform any of the aforementioned methods. The image rendering method according to the embodiments of the present disclosure is applied to a GPU. This method parses a dynamic image into a mosaic of multiple frames and uses the GPU for rendering based on the position and texture of the target frame within the mosaic. This allows the GPU to render multiple target frames in parallel. On the one hand, the GPU performs all computations during the rendering phase, eliminating the need for CPU operations to render each frame of the dynamic image. This prevents performance pressure from blocking other main thread functions within the application, thereby maintaining high frame rates in applications requiring large amounts of data (such as large batches of dynamic images). On the other hand, the significantly improved rendering efficiency during the rendering phase reduces restrictions on the selection of dynamic image resources. Therefore, diverse, personalized, and multi-temporal dynamic image resources can be used for rendering, thereby improving configuration flexibility and visual quality. The above description is merely an overview of the technical solution of the present disclosure. To better understand the technical approach of the present disclosure, implementation should be conducted in accordance with the present specification. To further enhance the understanding of the above and other objectives, features, and advantages of the present disclosure, the following describes specific embodiments of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS In the accompanying drawings, unless otherwise specified, identical reference numerals throughout the various figures denote identical or similar components or elements. The drawings are not necessarily drawn to scale. It should be understood that these drawings depict only some embodiments according to the present disclosure and should not be construed as limiting the scope of the present disclosure. FIG1 illustrates a flowchart of an image rendering method in related art; FIG2 illustrates an architecture diagram of an electronic device 200 for implementing the image rendering method according to an embodiment of the present disclosure; FIG3 illustrates a flowchart of the image rendering method according to an embodiment of the present disclosure; FIG4A, FIG5A, FIG5B, FIG5C, and FIG5D illustrate schematic diagrams of stitching methods according to an embodiment of the present disclosure; FIG6 illustrates an example application diagram of the image rendering method according to an embodiment of the present disclosure during the rendering preparation phase; FIG7 illustrates a flowchart of the image rendering method according to an embodiment of the present disclosure; FIG8 illustrates an example application diagram of the image rendering method according to an embodiment of the present disclosure during the rendering phase; and FIG9 illustrates an architecture diagram of an electronic device 900 for implementing the image rendering method according to an embodiment of the present disclosure. DETAILED DESCRIPTION OF THE EMBODIMENTS In the following, only certain exemplary embodiments are briefly described.As those skilled in the art will appreciate, the described embodiments may be modified in various ways without departing from the spirit or scope of the present disclosure. Therefore, the drawings and descriptions are to be considered illustrative in nature and not restrictive. To facilitate understanding of the technical solutions of the embodiments of the present disclosure, the following describes related technologies of the embodiments of the present disclosure. The following related technologies are optional solutions that can be combined with the technical solutions of the embodiments of the present disclosure in any manner, and all fall within the scope of protection of the embodiments of the present disclosure. The following terms will be used below: Dynamic image: Also known as a dynamic picture or dynamic icon, it refers to a set of specific static images that switch at a specified frequency to produce a certain dynamic effect. It is often used as a design resource to express dynamic information or enhance visual effects. Common formats include Animated Portable Network Graphics (APNG) and Graphics Interchange Format (GIF). Scatter maps are one of the most common forms of geographic feature visualization. They display the geographic distribution of data on a map while encoding service information within the data through visual channels such as icons, color, and size. They offer visually appealing graphics and high data richness. Scatter forms include, but are not limited to, dots, icons, and bubble animations. Signed Distance Field (SDF) is a binary image storage format. By vectorizing pixels, SDF images maintain smooth edges when magnified, and smooth transitions between different images can be achieved using only interpolation. Therefore, they are often used in game engines to store and render monochrome images with clear edges, such as fonts and pattern fills. Sprites: In computer graphics, when a two-dimensional image is integrated into a scene and becomes part of the overall displayed image, it is called a sprite. A shader is a small program that runs on a graphics processing unit (GPU) and controls various stages of graphics rendering, such as the vertex shader and the fragment shader. A vertex shader processes input vertex data, such as vertex position, normal, and color. It can perform transformations on this data, such as converting vertices from model coordinates to clip coordinates. A fragment shader determines the final color of a pixel.It calculates the color of each fragment based on the information passed by the vertex shader and other data (such as textures and lighting). Fragment: In computer graphics, a fragment is a term used to describe a specific portion of an image. A fragment refers to the data for one or more pixels generated during the rasterization phase, containing information such as the pixel's color and depth. In the rendering pipeline, the fragment shader processes each fragment to determine the final pixel color. Leveraging the GPU's parallel processing capabilities, multiple fragments—and therefore multiple pixels—can be processed and rendered simultaneously. Global Variable (Unit): Also known as a uniform variable, a Uniform is typically set by the application. In graphics rendering scenarios, a Uniform is a way to pass data from the application to the shader. Uniform values remain constant throughout the rendering process and are the same for all vertices or fragments. Therefore, by updating the Uniform, information can be transferred between rendering frames. With the advent of the big data era, the demand for richer and more intuitive visual effects and high-performance rendering of large-scale data in the visualization field is increasing rapidly, especially for geographic data. Traditional rendering solutions are mostly CPU-based. For example, Figure 1 shows a traditional rendering solution. Although viewport detection reduces the number of renderings on the same screen and R-tree indexing accelerates searches, as data volume increases, frequent re-queries when panning and zooming the map consume significant CPU resources, leading to application lag. Furthermore, the CPU calculation loops used to query data within the screen limit the amount of data on the same screen to less than 1,000, as increasing the number of data on the same screen would result in a decrease in frame rate. Furthermore, the continuous CPU usage of traversal significantly impacts the operation of other functions within the application. Compared to the traditional model of creating object instances and rendering on the CPU, GPUs use a non-instantiated model, reading data stored in advance in video memory on a fragment-by-fragment basis, allowing for parallel rendering of multiple fragments. Therefore, GPU rendering of large-scale scattered points has become an inevitable solution. However, due to the data update costs caused by the physical isolation between the CPU and GPU, there is no reasonable solution for rendering large-scale dynamic images. Existing mainstream map engines offer some alternatives, but they still suffer from limited styles and the inability to animate different features asynchronously. This means that the rendering performance of scattered dynamic images in batch rendering mode is inferior to that of traditional drawing methods.Figure 2 shows the architecture of an electronic device 200 for implementing the image rendering method according to an embodiment of the present disclosure. As shown in Figure 2, the electronic device includes a central processing unit (CPU) 201 and a graphics processing unit (GPU) 202. The image rendering method includes a rendering preparation phase and a rendering phase. In the rendering preparation phase, the CPU 201 processes resource images (e.g., dynamic images, static images, etc.) input to the electronic device 200 to generate a mosaic image and uploads the texture data and position data corresponding to the mosaic image to the GPU 202. The GPU 202 performs style parsing on the resource data (e.g., geographic information fields, service information fields, etc.) input to the electronic device 200 to generate vertex data and style data. The texture data and position data corresponding to the mosaic image, as well as the vertex and style data, serve as rendering resources and are stored in the GPU 202's video memory for use by the shading program. In the rendering phase, the GPU 202 executes the shading program and calls the corresponding resources from the video memory to complete the image rendering. Vertex data is a collection of vertices, typically transmitted as an array of three 3D coordinates to represent a triangle. Vertex data is input into the vertex shader, which converts the 3D coordinates into another type of 3D coordinates and performs some basic processing on the vertex attributes. This data is then used by the geometry shader in the next stage, which takes a collection of vertices in the form of primitives as input, generates new vertices, and constructs new primitives to generate other shapes. The rasterization stage then maps the primitives to corresponding pixels on the final screen, generating fragments, which are then rendered by the fragment shader. Style data can be used as system-configured or defined texture data, along with texture data parsed from user-defined image resources, during the image rendering process.The image rendering method according to the embodiments of the present disclosure parses a dynamic image into a mosaic of multiple frames and uses the GPU for rendering based on the position and texture of the target frame within the mosaic. This means that the GPU can render multiple target frames in parallel. On the one hand, all computations during the rendering phase are performed entirely by the GPU, eliminating the need for CPU operations to render each frame of the dynamic image. This prevents increased performance pressure from blocking other main thread functions within the application, thereby maintaining high frame rates in large data rendering scenarios. On the other hand, the significantly improved rendering efficiency during the rendering phase reduces restrictions on the selection of dynamic image resources. Therefore, in terms of visualization effects, in addition to utilizing simple vertex and style data generated from resource data, diverse, personalized, and multi-temporal dynamic image resources can also be used for rendering, thereby increasing configuration flexibility and visual effects. It should be noted that the application scenarios or application examples of the image rendering method provided in the embodiments of the present disclosure are provided for ease of understanding, and the embodiments of the present disclosure do not specifically limit the application of the image rendering method. Furthermore, the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, storage, and display) involved in this disclosure are all authorized by the user or fully authorized by all parties. The collection, use, and processing of the relevant data must comply with the relevant laws, regulations, and standards of the relevant countries and regions, and corresponding operation portals are provided for users to select, edit, authorize, or deny. The following detailed description of the technical solutions of this disclosure and how they address the aforementioned technical issues is provided using specific embodiments. The specific embodiments listed above may be combined with each other, and identical or similar concepts or processes may not be described in detail in certain embodiments. Figure 3 shows a flowchart of an image rendering method according to an embodiment of the present disclosure. This image rendering method can be applied to a CPU and is targeted at the rendering preparation stage. As shown in Figure 3, the image rendering method includes steps S301, S302, and S303. oStep S301: Generate a mosaic based on at least one resource image, where the resource image includes a dynamic image, and the mosaic includes multiple stitched-together image frames. In the disclosed embodiments, a resource can be understood as a rendering resource, including image-based resources, namely, resource images. Resource images can be dynamic images or static images. Stitching one or more resource images together can generate a mosaic. Stitching can be performed by tiling, including horizontal or vertical tiling. The stitching method can also be algorithmically defined, which is not limited in the disclosed embodiments. A dynamic image is used as an example. As previously mentioned, a dynamic image, also known as a dynamic picture or dynamic icon, consists of a set of specific static images that switch at a specified frequency to produce a dynamic effect. Therefore, a dynamic image includes multiple static images. In one example, the mosaic is generated by stitching together multiple frames in a dynamic image. In another example, based on the frame image list of each dynamic image, each frame in the frame image list is stitched together to generate the mosaic. Step S302: Generate corresponding texture data and position data for the mosaic. The position data includes the positions of multiple image frames within the mosaic. Texture data is a set of data representing image information, typically stored in the form of a two-dimensional array. This data may include color information, transparency information, normal information, and other information, depending on the texture's intended use. Textures are typically applied to the surfaces of three-dimensional or two-dimensional models to add detail, color, or patterns. Color information describes the color of each pixel in the image. Typically, color consists of red (R), green (G), and blue (B) channels. The value of each channel is typically between 0 and 1, representing the intensity of the corresponding color component. For example, (1, 0, 0) represents pure red, (0, 1, 0) represents pure green, and (0, 0, 1) represents pure blue. Texture data also includes texture coordinates, which are two-dimensional floating-point coordinates typically in the range [0, 1]. For example, (0, 0) represents the lower-left corner of the texture, and (1, 1) represents the upper-right corner. Based on the texture coordinates, the GPU determines where to retrieve color information within the texture data. Position data includes the position of each frame within the mosaic. For example, the position data may include each frame's identification information (such as the frame number) and its position within the mosaic (i.e., the frame position). Based on this position data, the GPU can locate the frame within the mosaic to be rendered.It should be noted that the disclosed embodiments do not limit the representation of frame positions (i.e., the storage format of position data). For example, the pixel position range of a mosaic image can be used to represent the position of a frame image within the mosaic image. Figure 4A shows multiple frames of a dynamic image. The frames are numbered 21, 22, 23, 24, 25, 26, 27, and 28 in chronological order. These frames are stitched together to generate the mosaic image shown in Figure 4B. The position data may include the frame numbers 21, 22, 23, 24, 25, 26, 27, and 28 of each frame, as well as position information within the mosaic image. For example, the position data for frame image 23 includes [23, 99, 0], where 23 represents the frame number and (99, 0) represents the pixel position. Step S303: Upload texture data and position data to the GPU's video memory, so that the GPU performs image rendering based on the texture data and position data. For example, the CPU may cache the texture data and position data generated based on the mosaic, namely, the texture buffer data and the position buffer data, and then save the texture buffer data and the position buffer data to the GPU's video memory. The GPU then runs a shader program, retrieves the texture data and position data from the video memory, and compiles them into the shader program. During the rendering phase, the GPU runs the shader program to complete image rendering. In one embodiment, in step S301, generating a mosaic based on at least one resource image includes: parsing a dynamic image into a frame image list; and stitching together each frame image in the frame image list of each dynamic image to generate a mosaic. In one example, for any dynamic image, the image is first parsed into a frame image list, as shown in FIG4A . Then, each frame image in the frame image list is stitched together to generate a mosaic corresponding to the dynamic image, as shown in FIG4B . Finally, the mosaics corresponding to each dynamic image are stitched together to generate a large mosaic. In another example, any dynamic image is first parsed into a frame image list. Then, each frame image in the frame image list of each dynamic image is spliced together (i.e., there is no need to first generate a small spliced image corresponding to each dynamic image) to generate a large spliced image. It should be noted that the present embodiment does not specifically limit the splicing arrangement method and splicing order. Furthermore, FIG4A is only an exemplary representation of the frame image list. Other representations are also possible, such as arranging the frames in a row in chronological order or without a time axis. The present embodiment does not limit this.Furthermore, the method for parsing a dynamic image into a frame image list can be divided into two cases: the case where the dynamic image is a monochrome dynamic image; and the case where the dynamic image is a multi-color dynamic image. In the case where the dynamic image is a monochrome dynamic image, that is, in response to the dynamic image being a monochrome dynamic image, the method for parsing the dynamic image into a frame image list can include: extracting a portion of the frame images from the monochrome dynamic image; and using the portion of the frame images to generate a frame image list corresponding to the monochrome dynamic image. For example, as shown in FIG5A , a monochrome dynamic image includes multiple frame images 11, 12, 13, 14, 15, 16, 17, 18, and 19; extracting a portion of the frame images from the multiple frame images, for example, frames 11, 14, 16, and 19, and then generating a frame image list, as shown in FIG5B . In the case where the dynamic image is a multi-color dynamic image, each frame of the dynamic image is directly parsed into a frame image list, that is, no frame extraction is performed. This reduces image storage, the memory size of the mosaic, and video memory pressure. For example, a resource image includes a multi-color dynamic image and a monochrome dynamic image. Each frame of the multi-color dynamic image is stitched together to produce a mosaic 400, as shown in FIG4B . A monochrome dynamic image is subjected to frame extraction processing, that is, partial frames are stitched together to produce a mosaic 500, as shown in FIG5C . Then, mosaic 400 and mosaic 500 are stitched together to produce the final mosaic, i.e., the mosaic used to generate texture data and position data. In one embodiment, the resource image may also include a static image. Therefore, users can freely input a variety of resource images based on their configuration. The static image and multiple frames corresponding to the dynamic image are stitched together to generate the final mosaic. For example, the mosaic of frames corresponding to each dynamic image is stitched together with each static image to generate the final mosaic. For example, a resource image includes a multi-color dynamic image, a monochrome dynamic image, and a static image. By stitching together each frame of a multi-color dynamic image, a stitched image 400 can be obtained, as shown in FIG4B . A monochrome dynamic image is subjected to frame extraction processing, i.e., some of its frames are stitched together, to obtain a stitched image 500, as shown in FIG5C . Stitched images 400, 500, and a static image 601 are stitched together, for example, using a sprite image generation algorithm, to obtain a final stitched image 602. Furthermore, corresponding texture data and position data are generated for stitched image 602 and uploaded to the GPU's video memory.In one embodiment, when the dynamic image is a monochrome dynamic image, generating a frame image list corresponding to the monochrome dynamic image using partial frame images may include: converting the partial frame images into SDF format; and generating a frame image list corresponding to the monochrome dynamic image using the partial frame images in SDF format. That is, when the dynamic image is a monochrome dynamic image, the frame image format is SDF. As described above, the SDF format is a binary image storage format. Through pixel vectorization, SDF images can maintain smooth edges when magnified and achieve smooth transitions between different images solely through interpolation. This further reduces image storage volume without affecting rendering performance during the rendering phase. During the rendering phase, SDF images can be directly rendered. Specifically, the position of the target image element on the mosaic is determined based on the position of the target image element on the target frame image and the position of the target frame image in the mosaic. Based on the position of the target image element on the mosaic, texture data corresponding to the target image element is retrieved from video memory. Rendering can also be performed through interpolation. The following describes an application example of the image rendering method according to an embodiment of the present disclosure during the rendering preparation phase, in conjunction with FIG6 . As shown in Figure 6, during the rendering preparation phase, the CPU is responsible for: obtaining the input resource images, including dynamic images and static images; determining whether the dynamic image is a monochrome dynamic image; if it is a monochrome dynamic image, extracting frames and parsing them into a frame image list in the SDF format, that is, extracting frames from the monochrome dynamic image to obtain partial frame images, converting these partial frame images into frame images in the SDF format, and then generating a frame image list in the SDF format; stitching together each frame image in the frame image list of each dynamic image to generate a large stitched image (large image); generating a sprite image from the static image and the large image, that is, stitching the static image and the large image according to the sprite image algorithm; and storing the texture data and position data generated based on the stitched image into a buffer, namely, the texture buffer data and the position buffer data. The GPU is responsible for: obtaining input resource data, including geographic information fields and service information fields; performing style parsing on the resource data to generate vertex and style data and place them into buffers, namely vertex and style buffer data; saving the vertex and style buffer data, texture buffer data, and position buffer data to the GPU's video memory; and compiling the vertex and style buffer data, texture buffer data, and position buffer data into the shader program required for rendering.Figure 7 shows a flowchart of an image rendering method according to an embodiment of the present disclosure. This method can be applied to a GPU, primarily focusing on the rendering phase. Exemplarily, the method can be implemented by a GPU running a shader program. As shown in Figure 7, the method includes steps S701, S702, S703, and S704. Step S701: Determine the position of a target frame image within a mosaic. The mosaic includes multiple stitched-together frames, each selected from at least one dynamic image. Texture data and position data corresponding to the mosaic are pre-stored in the GPU's video memory. The position data includes the position of the multiple frames within the mosaic. The target frame image is the frame image currently being rendered. During the rendering preparation phase, the position data has been compiled into the shader program. Based on this position data, the target frame image currently being rendered can be located within the mosaic. The mosaic generation method and the position of the frame image within the mosaic can be found in the description of the above embodiments and will not be further elaborated here. Exemplarily, the target frame image can be determined based on the current time, and position data can be retrieved from video memory to determine the position of the target frame image within the mosaic. For example, during the rendering process, an external timer (e.g., a timer on the CPU or other time source) can be used to track time. The time information from the external timer is passed to the shading program (including the vertex shading program and the fragment shading program) by updating a global variable (Unit). The fragment shading program can then calculate the index of the currently rendered image frame (e.g., the frame number) based on the time information. For example, the fragment shading program first determines which dynamic image is currently being rendered, and then, based on the total duration and frame number of the dynamic image, maps the time information to a frame number range to determine which frame of the dynamic image is currently being rendered. Step S702: Based on the position of the target fragment on the screen, the position of the target image element corresponding to the target fragment on the target frame image is determined. A fragment is the smallest unit in image rendering, while a pixel is the basic unit of an image. During the rasterization stage, a fragment can generate data for one or more pixels. The fragment shading program processes each fragment to determine the final pixel color. Therefore, a target fragment corresponds to one or more pixels, which are called the target image element. The position of the target fragment on the screen is called the target fragment position, which is typically a two-dimensional vector consisting of x and y coordinates. The size of the target frame image includes the width and height of the target frame image (in pixels). The pixel position of the corresponding target image element can be calculated based on the target fragment position on the screen and the target frame image size.For example, if the target fragment position is (0.5, 0.5) and the size of the target frame image is (100, 100), then the pixel position of the corresponding target image element is (50, 50). Step S703: Based on the position of the target image element on the target frame image and the position of the target frame image in the mosaic, texture data corresponding to the target image element is obtained from the video memory. Exemplarily, the position of the target image element on the mosaic is determined based on the position of the target image element on the target frame image and the position of the target frame image in the mosaic. Based on the position of the target image element on the mosaic, texture data corresponding to the target image element is obtained from the video memory. Specifically, based on the position of the target frame image in the mosaic, the target frame image can be located in the mosaic. Then, based on the position of the target image element on the target frame image, texture coordinates in the mosaic are calculated. Furthermore, color information is obtained from the corresponding texture data using the texture coordinates (for details, please refer to the above embodiment and will not be repeated here). Step S704: Render the target fragment based on the acquired texture data. For example, during the rasterization phase, the fragment shader obtains a color value based on the acquired color information and renders the color value to the target fragment. It is understood that the GPU's image rendering process is parallel processing; that is, the shader can render each pixel of the same frame in parallel. Therefore, using the GPU for image rendering can achieve asynchronous playback of large-scale scattered dynamic images, avoiding the performance bottleneck caused by frame-by-frame CPU operations. According to the image rendering method of the embodiments of the present disclosure, a dynamic image is parsed into a mosaic of multiple image frames and rendered using the GPU based on the position and texture of the target frame image in the mosaic. That is, the GPU can render multiple target frame images in parallel. On the one hand, all calculations in the rendering phase are completed by the GPU, avoiding the need to rely on CPU operations for rendering each frame of the dynamic image. This will not cause the blocking of other main thread functions within the application due to increased performance pressure, thereby maintaining high frame rate rendering in application scenarios that render batch dynamic images. On the other hand, since the rendering efficiency is significantly improved in the rendering phase, there are fewer restrictions on the selection of dynamic image resources. Therefore, in terms of visualization effects, diverse, personalized, and multi-temporal dynamic image resources can be used for rendering, thereby improving configuration freedom and visual effects.In one embodiment, step S703 may include: in response to the target frame image being in SDF format, determining a first adjacent frame image and a second adjacent frame image of the target frame image in the mosaic according to the position of the target frame image in the mosaic; determining a first image element in the first adjacent frame image that matches the position of the target image element in the target frame image, and determining a second image element in the second adjacent frame image that matches the position of the target image element in the target frame image; determining an SDF value of the target image element based on the SDF value of the first image element and the SDF value of the second image element; and obtaining corresponding texture data from a video memory according to the SDF value of the target image element. Specifically, for a target frame image in SDF format, the preceding and following frames (i.e., the first adjacent frame image and the second adjacent frame image) are located in the mosaic graph. The SDF values of corresponding pixels (i.e., the first and second image elements) in the preceding and following frames are obtained. Interpolation is then performed, and the location of the texture data to be sampled is determined based on the interpolated SDF values. Based on the sampled locations, color information is sampled from the texture data to obtain color values, which are then rendered to the target fragment. During the rendering preparation phase, frames of the monochrome dynamic image are extracted and stored in SDF format. During the rendering phase, the SDF values are used to perform smooth interpolation between frames. This reduces the dynamic image storage size, reduces video memory pressure, and ensures stable GPU rendering performance in scenarios with multiple dynamic images. An example application of the image rendering method according to an embodiment of the present disclosure in the rendering phase is described below with reference to FIG8. During the rendering phase, the GPU is responsible for the following: An external timer transmits time information to the shading program by updating the Uniform. The fragment shading program calculates the frame index of the target image frame currently being rendered based on the time information, determining which frame of the dynamic image is currently being rendered. The fragment shading program then calculates the image pixel position corresponding to the target fragment (i.e., the position of the target image element within the target frame) based on the target fragment position. When rendering a target frame image that is not in SDF format, the target frame image is directly located in the mosaic graph, the color value of the target image element corresponding to the target fragment is obtained, and then rendered to the target fragment. When rendering a target frame image in SDF format, the two frames closest to the current frame (i.e., the first and second adjacent frames) are located in the mosaic graph, and the SDF value of the target frame image is interpolated based on the SDF values of the two frames. The color value is determined based on the SDF value of the target frame image and the texture data (including color information) and rendered to the target fragment. The timer updates the time, and the next frame is rendered.According to the method of the embodiments of the present disclosure, on the one hand, all calculations during the rendering phase are completed by the GPU, avoiding the need for CPU operations to render each frame of a dynamic image. This prevents the blocking of other main thread functions within the application due to increased performance pressure, thereby maintaining high frame rate rendering in application scenarios with large data rendering volumes. On the other hand, in terms of visualization effects, in addition to utilizing simple vertex and style data generated from resource data, rendering can also utilize diversified, personalized, and multi-temporal dynamic image resources, thereby improving configuration freedom and visual effects. On the other hand, through frame-sparse storage, image storage is reduced, the storage volume of the mosaic image is reduced, and video memory pressure is reduced, avoiding the performance bottleneck pressure caused by frame-by-frame CPU operations, and enabling asynchronous playback of large-scale scattered dynamic images. On the other hand, the technical solution of using SDF values for inter-frame smooth interpolation can ensure the stability of GPU rendering performance in scenarios with multiple dynamic images while reducing the dynamic image storage volume. In map rendering applications, the methods of the disclosed embodiments can fully utilize design resources, stably support large amounts of data, provide a highly flexible and high-performance visualization solution, and enhance the overall usability of the map engine. The disclosed embodiments also provide an image rendering device that can be deployed on a GPU. The image rendering device may include: a target frame image position determination module, configured to determine the position of the target frame image within a mosaic, wherein the mosaic includes multiple stitched-together image frames, the multiple frames selected from at least one dynamic image; texture data and position data corresponding to the mosaic are pre-stored in the GPU's video memory; the position data includes the positions of the multiple frames within the mosaic; a target image element position determination module, configured to determine the position of a target image element corresponding to the target fragment within the target frame image based on the position of the target fragment on the screen; a texture data acquisition module, configured to acquire texture data corresponding to the target image element from the video memory based on the position of the target image element within the target frame image and the position of the target frame image within the mosaic; and a fragment rendering module, configured to render the target fragment based on the acquired texture data. In one embodiment, the target frame image position determination module is specifically configured to: determine the target frame image based on the current time; and retrieve the position data from the video memory to determine the position of the target frame image in the mosaic. In one embodiment, the mosaic also includes a static image stitched together with the multiple image frames, and the position data also includes the position of the static image in the mosaic.In one embodiment, the dynamic image includes a monochrome dynamic image, and the mosaic includes a portion of frame images from the monochrome dynamic image. In one embodiment, the portion of frame images is in a signed distance field (SDF) format. In one embodiment, the texture data acquisition module is specifically configured to: in response to the target frame image being in the SDF format, determine a first adjacent frame image and a second adjacent frame image of the target frame image in the mosaic based on the position of the target frame image in the mosaic; determine a first image element in the first adjacent frame image that matches the position of the target image element in the target frame image, and determine a second image element in the second adjacent frame image that matches the position of the target image element in the target frame image; determine an SDF value of the target image element based on the SDF value of the first image element and the SDF value of the second image element; and acquire texture data corresponding to the target image element from the video memory based on the SDF value of the target image element. In one embodiment, the texture data acquisition module is specifically configured to: determine the position of the target image element on the mosaic based on the position of the target image element on the target frame image and the position of the target frame image in the mosaic; and obtain texture data corresponding to the target image element from the video memory based on the position of the target image element on the mosaic. The disclosed embodiments also provide an image rendering device that can be deployed on a CPU. The image rendering device includes: a mosaic generation module for generating a mosaic based on at least one resource image, wherein the resource image includes a dynamic image and the mosaic includes multiple stitched-together frames of image; a texture data and position data generation module for generating corresponding texture data and position data for the mosaic, the position data including the positions of the multiple frames of image in the mosaic; and an upload module for uploading the texture data and position data to the video memory of a GPU, so that the GPU performs image rendering based on the texture data and position data. In one embodiment, the mosaic generation module is specifically configured to: parse the dynamic image into a frame image list; and splice each frame image in the frame image list of each dynamic image to generate the mosaic. In one embodiment, parsing the dynamic image into the frame image list specifically includes: extracting a portion of the frame images from the monochrome dynamic image in response to the dynamic image being a monochrome dynamic image; and generating a frame image list corresponding to the monochrome dynamic image using the portion of the frame images.In one embodiment, generating a frame image list corresponding to the monochrome dynamic image using the partial frame images specifically includes: converting the partial frame images into SDF format; and generating a frame image list corresponding to the monochrome dynamic image using the partial frame images in SDF format. In one embodiment, the resource image also includes a static image, and the mosaic image also includes a static image stitched together with the multiple frame images. The functions of each module in each apparatus of the embodiments of the present disclosure can be found in the corresponding descriptions of the above-mentioned methods, and corresponding beneficial effects are achieved, and are not further described here. FIG9 is a block diagram of an electronic device 900 for implementing the image rendering method of the embodiments of the present disclosure. As shown in FIG9 , the electronic device 900 includes a memory 901 and a processor 902, wherein the processor 902 includes a CPU and a GPU. The memory 901 stores a computer program executable on the processor 902. When the processor 902 executes the computer program, the method of the above-mentioned embodiments is implemented. The number of the memory 901 and the processor 902 can be one or more. The electronic device 900 also includes a communication interface 903 for communicating with external devices and exchanging data. If the memory 901, processor 902, and communication interface 903 are implemented independently, the memory 901, processor 902, and communication interface 903 may be interconnected via a bus and communicate with each other. This bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus. This bus may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, FIG9 shows only one thick line, but this does not mean that there is only one bus or only one type of bus. Optionally, in a specific implementation, if the memory 901, processor 902, and communication interface 903 are integrated on a single chip, the memory 901, processor 902, and communication interface 903 may communicate with each other via an internal interface. The present embodiment provides a computer-readable storage medium storing a computer program. When executed by a processor, the program implements the method provided in the present embodiment. The embodiments of the present disclosure further provide a computer program. When the computer program is executed in a computer, it enables the computer to execute the method provided in the embodiments of the present disclosure.The present disclosure also provides a chip including a processor configured to retrieve and execute instructions stored in a memory, thereby enabling a communication device equipped with the chip to perform the methods provided in the present disclosure. The present disclosure also provides a chip including an input interface, an output interface, a processor, and a memory. The input interface, the output interface, the processor, and the memory are connected via an internal connection path. The processor is configured to execute code in the memory. When the code is executed, the processor performs the methods provided in the present disclosure. Furthermore, the memory may optionally include read-only memory and random access memory. The memory may be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. Non-volatile memory may include read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory may include random access memory (RAM), which serves as an external cache. By way of example and not limitation, many forms of RAM are available. For example, static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct RAM RAM (DR RAM). In the above embodiments, they may be implemented in whole or in part using software, hardware, firmware, or any combination thereof. When implemented using software, they may be implemented in whole or in part in the form of a computer program product. A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions according to the present disclosure are produced in whole or in part.A computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. Computer instructions can be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another. In the description of this disclosure, reference to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples" means that the specific features, structures, materials, or characteristics described in conjunction with that embodiment or example are included in at least one embodiment or example of this disclosure. Furthermore, the specific features, structures, materials, or characteristics described can be combined in any suitable manner in any one or more embodiments or examples. Furthermore, those skilled in the art may combine and integrate the different embodiments or examples described in this disclosure, as well as features from different embodiments or examples, unless mutually inconsistent. Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed to indicate or imply relative importance or to implicitly specify the number of technical features indicated. Therefore, features specified as "first" or "second" may explicitly or implicitly include at least one of those features. In the description of this disclosure, "plurality" means two or more, unless otherwise specifically defined. Any process or method depicted in a flowchart or otherwise described herein can be understood to represent a module, segment, or portion of code comprising one or more executable instructions for implementing a specific logical function or process step. Furthermore, the scope of the preferred embodiments of this disclosure includes alternative implementations in which functions may be performed out of the order shown or discussed, including performing functions substantially simultaneously or in reverse order depending on the functions involved. The logic and / or steps depicted in a flowchart or otherwise described herein can, for example, be considered a sequenced list of executable instructions for implementing the logical functions and can be embodied in any computer-readable medium for use by an instruction execution system, apparatus, or device (e.g., a computer-based system, a system including a processor, or other system that can fetch and execute instructions from an instruction execution system, apparatus, or device), or in conjunction with such an instruction execution system, apparatus, or device. It should be understood that various aspects of this disclosure can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods may be implemented using software or firmware stored in a memory and executed by a suitable instruction execution system. All or part of the steps of the above method embodiments may be performed by a program instructing the relevant hardware. The program may be stored in a computer-readable storage medium. When executed, the program includes one or a combination of the steps of the method embodiments.Furthermore, the functional units in the various embodiments of the present disclosure may be integrated into a single processing module, each unit may exist physically separately, or two or more units may be integrated into a single module. These integrated modules may be implemented in either hardware or software functional modules. If these integrated modules are implemented as software functional modules and sold or used as standalone products, they may also be stored in a computer-readable storage medium. This storage medium may be a read-only memory, a magnetic disk, or an optical disk. The foregoing is merely an exemplary embodiment of the present disclosure, but the scope of protection of the present disclosure is not limited thereto. Any person skilled in the art will readily conceive of various variations and substitutions within the technical scope of this disclosure, and such variations and substitutions are intended to be encompassed by the scope of protection of this disclosure. Therefore, the scope of protection of the present disclosure shall be subject to the scope of protection of the claims.
Claims
Claims 1. An image rendering method, applied to a graphics processing unit (GPU), the image rendering method comprising: Determine the position of a target frame image in a mosaic, wherein the mosaic includes multiple frame images stitched together, the multiple frame images are selected from at least one dynamic image, texture data and position data corresponding to the mosaic are pre-stored in a video memory of a GPU, and the position data includes the positions of the multiple frame images in the mosaic; determine the position of a target image element corresponding to the target fragment on the target frame image based on the position of the target fragment on the screen; obtain texture data corresponding to the target image element from the video memory according to the position of the target image element on the target frame image and the position of the target frame image in the mosaic; and render the target fragment based on the obtained texture data.
2. The method according to claim 1, wherein: Determining a position of a target frame image in a mosaic image includes: determining the target frame image based on a current time; and calling the position data from the video memory to determine the position of the target frame image in the mosaic image.
3. The method according to claim 1 or 2, wherein: The spliced image also includes a static image spliced together with the multiple frames of images, and the position data also includes the position of the static image in the spliced image.
4. The method according to any one of claims 1 to 3, wherein: The dynamic image includes a monochrome dynamic image, and the spliced image includes a partial frame image of the monochrome dynamic image.
5. The method according to claim 4, wherein: The partial frame image is in a signed distance field SDF format.
6. The method according to claim 5, wherein: According to the position of the target image element on the target frame image and the position of the target frame image in the mosaic, acquiring texture data corresponding to the target image element from the video memory includes: in response to the target frame image being in SDF format, determining a first adjacent frame image and a second adjacent frame image of the target frame image in the mosaic according to the position of the target frame image in the mosaic; determining a first image element matching the position of the target image element on the target frame image in the first adjacent frame image, and determining a second image element matching the position of the target image element on the target frame image in the second adjacent frame image; determining an SDF value of the target image element based on the SDF value of the first image element and the SDF value of the second image element; and acquiring texture data corresponding to the target image element from the video memory according to the SDF value of the target image element.
7. The method according to any one of claims 1 to 5, wherein: Acquiring texture data corresponding to the target image element from the video memory according to the position of the target image element on the target frame image and the position of the target frame image in the mosaic, includes: determining the position of the target image element on the mosaic according to the position of the target image element on the target frame image and the position of the target frame image in the mosaic; and acquiring texture data corresponding to the target image element from the video memory based on the position of the target image element on the mosaic.
8. An image rendering method, comprising: Generate a mosaic based on at least one resource image, wherein the resource image includes a dynamic image, and the mosaic includes multiple frame images stitched together; generate corresponding texture data and position data for the mosaic, wherein the position data includes the position of the multiple frame images in the mosaic; upload the texture data and the position data to a video memory of a GPU, so that the GPU generates a mosaic based on the texture data and the position data. The position data is used for image rendering.
9. The method according to claim 8, wherein: Generating a mosaic image based on at least one resource image includes: parsing the dynamic image into a frame image list; and splicing together frame images in the frame image list of the dynamic image to generate the mosaic image.
10. The method according to claim 9, wherein: Parsing the dynamic image into a frame image list includes: in response to the dynamic image being a monochrome dynamic image, extracting a portion of frame images in the monochrome dynamic image; and generating a frame image list corresponding to the monochrome dynamic image using the portion of frame images.
11. The method according to claim 10, wherein: Generating a frame image list corresponding to the monochrome dynamic image by using the partial frame images, comprising: converting the partial frame images into an SDF format; and generating a frame image list corresponding to the monochrome dynamic image by using the partial frame images in the SDF format.
12. The method according to claim 8, wherein: The resource image also includes a static image, and the spliced image also includes a static image spliced together with the multiple frames of images.
13. An electronic device, comprising a memory and a processor, wherein the processor is used to implement the method according to any one of claims 1 to 12.
14. A computer-readable storage medium, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the method according to any one of claims 1 to 12 is implemented.
15. A computer program, when executed in a computer, causes the computer to execute the method according to any one of claims 1 to 12.
Citation Information
Patent Citations
Rapid generating method for ultrahigh-resolution composite image in raster 3D displaying
CN103745448A
Animation generation method and device
CN107403460A
Object three-dimensional reconstruction method based on depth camera module
CN110751684A
Batch processing drawing method for 3D simulation scene image based on edge calculation
CN110992462A
Video cover extraction method and related device
CN116453005A