Image material rendering method and apparatus, computer device, and storage medium
By calculating the scaling ratio of the screen interface of the device and the canvas, the texture size of the image material is dynamically adjusted, solving the problem of rendering clarity decline caused by different device resolutions, and achieving a higher quality image display effect.
Patent Information
- Application Number
- PCT/CN2024/101256
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-06-25
- Filing Date
- 2024-06-25
- Publication Date
- 2025-01-02
AI Technical Summary
In scenes such as poster design, upsampling or downsampling during image material rendering due to differences in screen resolutions of different devices leads to a decrease in clarity of the final displayed poster.
By determining the display size of the editing area of the material to be rendered in the screen interface, calculating the scaling ratio of the canvas and editing area, and adjusting the texture size of the material according to the scaling ratio, ensuring that the material and the canvas are kept in equal-scale scaling, avoiding the display accuracy due to the canvas size. .
Improve the rendering clarity of the material to be rendered, avoid image information loss and texture memory waste caused by device resolution differences, and achieve higher quality image display.
Smart Images

Figure CN2024101256_02012025_PF_FP_ABST
Abstract
Description
Image material rendering method, device, computer equipment and storage medium
[0001] This application claims priority to Chinese patent application No. 202310752811.6, filed on June 25, 2023, entitled “A method, device, computer equipment and storage medium for rendering image materials”. The contents disclosed in the above-mentioned Chinese patent application are hereby cited in their entirety as part of this application. Technical Field
[0002] The present disclosure relates to the field of computer technology, for example, to a method, apparatus, computer equipment, and storage medium for rendering image materials. Background Art
[0003] In poster design scenarios, users often need to define multiple layers and combine them to create a poster design. However, different users use devices with different screen resolutions. When there is a discrepancy between the layers of the display material and the screen resolution, the rendering process involves varying degrees of upsampling or downsampling, which can result in a decrease in the clarity of the final displayed poster.
[0004] Summary of the Invention
[0005] The embodiments of the present disclosure at least provide a method, apparatus, computer equipment, and storage medium for rendering image materials.
[0006] In a first aspect, an embodiment of the present disclosure provides a method for rendering an image material, comprising:
[0007] Determine a first display size of an editing area on a screen interface set for the material to be rendered;
[0008] Determining a first scaling ratio for rendering the canvas to the editing area based on a canvas size of the to-be-rendered material and an area size of the editing area of the screen interface;
[0009] Determining, based on the first scaling ratio and the first display size, a second display size of the to-be-rendered material after it is rendered onto the canvas;
[0010] Based on the second display size, a texture size of the material to be rendered is determined, and the material to be rendered is rendered according to the texture size.
[0011] In one possible implementation, determining a first scaling ratio for rendering the canvas to the editing area based on a canvas size of the material to be rendered and an area size of the editing area on the screen interface includes:
[0012] respectively calculating a first height scaling ratio between a canvas height of the canvas size and a region height of the editing region, and a first width scaling ratio between a canvas width of the canvas size and a region width of the editing region;
[0013] The first scaling ratio is determined based on the first width scaling ratio and the first height scaling ratio.
[0014] In a possible implementation, determining the first scaling ratio based on the first width scaling ratio and the first height scaling ratio includes:
[0015] In a case where the first width scaling ratio is greater than the first height scaling ratio, using the first height scaling ratio as the first scaling ratio;
[0016] When the first width scaling ratio is less than or equal to the first height scaling ratio, the first width scaling ratio is used as the first scaling ratio.
[0017] In one possible implementation, when the first width scaling ratio is greater than the first height scaling ratio, after the canvas is scaled according to the first height scaling ratio, the height of the scaled canvas is the same as the height of the editing area, and the width of the scaled canvas is smaller than the width of the editing area.
[0018] When the first width scaling ratio is less than or equal to the first height scaling ratio, after the canvas is scaled according to the first width scaling ratio, the width of the scaled canvas is the same as the width of the editing area, and the height of the scaled canvas is less than or equal to the height of the editing area.
[0019] In a possible implementation, determining the texture size of the to-be-rendered material based on the second display size includes:
[0020] When the second display size is smaller than or equal to the preset display size, using the second display size as the texture size of the material to be rendered;
[0021] In a case where the second display size is larger than the preset display size, scaling is performed on the second display size to determine a texture size of the material to be rendered.
[0022] In a possible implementation, when the second display size is larger than the preset display size, scaling the second display size to determine the texture size of the to-be-rendered material includes:
[0023] determining a third scaling ratio of the second display size based on the second display size and the preset display size;
[0024] The second display size is scaled according to the third scaling ratio to determine the texture size of the material to be rendered.
[0025] In a possible implementation, rendering the material to be rendered according to the texture size includes:
[0026] Rendering the material to be rendered onto a canvas according to the texture size;
[0027] Render on screen based on the canvas rendering results.
[0028] In a possible implementation, determining a third scaling ratio of the second display size based on the second display size and the preset display size includes:
[0029] respectively calculating a third height scaling ratio between the height of the second display size and the height of the preset display size, and a third width scaling ratio between the width of the second display size and the width of the preset display size;
[0030] The third scaling ratio is determined based on the third width scaling ratio and the third height scaling ratio.
[0031] In a possible implementation, determining the third scaling ratio based on the third width scaling ratio and the third height scaling ratio includes:
[0032] In a case where the third width scaling ratio is greater than the third height scaling ratio, using the third height scaling ratio as the third scaling ratio;
[0033] When the third width scaling ratio is less than or equal to the third height scaling ratio, the third width scaling ratio is used as the third scaling ratio.
[0034] In a second aspect, an embodiment of the present disclosure further provides a device for rendering image material, comprising:
[0035] A determination module configured to determine a first display size of an editing area on a screen interface set for a material to be rendered;
[0036] A first calculation module is configured to determine a first scaling ratio for rendering the canvas to the editing area based on the canvas size of the to-be-rendered material and the area size of the editing area on the screen interface;
[0037] a second calculation module configured to determine, based on the first scaling ratio and the first display size, a second display size of the to-be-rendered material after it is rendered on the canvas;
[0038] The texture size determining module is configured to determine the texture size of the material to be rendered based on the second display size, and render the material to be rendered according to the texture size.
[0039] In a third aspect, an embodiment of the present disclosure further provides a computer device comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the computer device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the above-mentioned first aspect or any possible implementation of the first aspect are performed.
[0040] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, executes the steps of the above-mentioned first aspect or any possible implementation of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following briefly introduces the drawings required for use in the embodiments. The drawings herein are incorporated into and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and, together with the specification, are used to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For those of ordinary skill in the art, other relevant drawings can be obtained based on these drawings without inventive effort.
[0042] FIG1 shows a flowchart of a method for rendering image materials provided by an embodiment of the present disclosure;
[0043] FIG2 shows a schematic diagram of a device for rendering image materials provided by an embodiment of the present disclosure;
[0044] FIG3 shows a schematic structural diagram of a computer device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0045] In order to make the purpose, technical solutions and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings herein can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the present disclosure for protection, but merely represents selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present disclosure.
[0046] Texture size refers to the width and height of a texture image, typically expressed in pixels. In computer graphics, textures are used to add surface detail and complexity, so texture size directly impacts rendering quality and performance. Larger texture sizes provide greater detail and realism, but also increase computational complexity and memory usage, resulting in slower rendering speeds. Therefore, in practical applications, it's important to choose a reasonable texture size based on scene requirements and computing resource constraints.
[0047] In related technologies, a fixed texture size is generally used for rendering. During the rendering process, due to the difference between the canvas and screen resolutions, different degrees of upsampling or downsampling may be set during the rendering process, which ultimately affects the display effect.
[0048] Based on the above research, the present disclosure provides a rendering method, device, computer equipment and storage medium for image materials, which can determine a first scaling ratio in combination with the canvas size and the area size of the editing area, and then determine the second display size of the material to be rendered after it is rendered on the canvas based on the first scaling ratio and the first display size of the editing area of the material to be rendered on the screen interface, and then determine the texture size of the material to be rendered based on the second display size.
[0049] According to the technical solution disclosed in the present invention, since the second display size of the material to be rendered is related to the first display size of the material to be rendered in the editing area, when the user adjusts the first display size of the material to be rendered in the editing area, the texture size of the material to be rendered can be indirectly adjusted. Compared with using a fixed texture size, this method can improve the clarity of the material to be rendered during rendering; on the other hand, the second display size is related to the first scaling ratio of the canvas rendering to the editing area, that is, the scaling ratio of the material to be rendered from the canvas to the editing area on the screen interface is the same as the scaling ratio of the canvas to the editing area. Therefore, it can be ensured that the material to be rendered maintains a proportional scale with the canvas during the rendering process, thereby avoiding the influence of the canvas size on the display accuracy of the material to be rendered.
[0050] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, it does not need to be further defined or explained in subsequent drawings.
[0051] The term "and / or" in this disclosure merely describes an associative relationship, indicating that three relationships may exist. For example, "A and / or B" may represent three situations: the existence of A alone, the existence of both A and B, and the existence of B alone. In addition, the term "at least one" in this disclosure represents any combination of at least two of any one or more of a plurality of items. For example, "including at least one of A, B, and C" may represent including any one or more elements selected from the set consisting of A, B, and C.
[0052] It is understandable that before using the technical solutions disclosed in the various embodiments of this disclosure, the type, scope of use, usage scenarios, etc. of the personal information involved in this disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.
[0053] For example, in response to a user's active request, a prompt message is sent to the user to clearly inform the user that the operation requested will require the acquisition and use of the user's personal information. This allows the user to independently choose whether to provide personal information to the electronic device, application, server, storage medium, or other software or hardware that performs the operations of the disclosed technical solution based on the prompt message.
[0054] As an optional but non-limiting implementation, in response to receiving a user's active request, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. Furthermore, the pop-up window may also contain a selection control for the user to select "agree" or "disagree" to provide personal information to the electronic device.
[0055] It is understandable that the above notification and user authorization process are merely illustrative and do not limit the implementation of the present disclosure. Other methods that comply with relevant laws and regulations may also be applied to the implementation of the present disclosure.
[0056] To facilitate understanding of the embodiments of the present disclosure, a method for rendering image material disclosed in an embodiment of the present disclosure is first described in detail. The execution subject of the method for rendering image material provided in the embodiment of the present disclosure is generally a computer device with certain computing capabilities, such as a terminal device or a server or other processing device. The terminal device can be a user equipment (UE), a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (PDA), a handheld device, a computing device, an in-vehicle device, a wearable device, etc. In some possible implementations, the method for rendering image material can be implemented by a processor calling computer-readable instructions stored in a memory.
[0057] 1 is a flowchart of a method for rendering image materials according to an embodiment of the present disclosure. The method includes steps 101 to 104, wherein:
[0058] Step 101: Determine a first display size of an editing area on a screen interface set for a material to be rendered.
[0059] Step 102: Determine a first scaling ratio for rendering the canvas to the editing area based on the canvas size of the to-be-rendered material and the area size of the editing area of the screen interface.
[0060] Step 103: Determine a second display size of the to-be-rendered material after it is rendered on the canvas based on the first scaling ratio and the first display size.
[0061] Step 104: Determine a texture size of the material to be rendered based on the second display size, and render the material to be rendered according to the texture size.
[0062] In one embodiment of the present disclosure, for step 101, the material to be rendered may be a material constituting a target image, for example, a material in a poster design process.
[0063] In one embodiment of the present disclosure, for step 101, the editing area of the screen interface is an area that allows the user to perform editing operations, and the area size of the editing area is related to the size of the screen interface and the interface design of the screen interface. The interface design may include, for example, the position of the trigger button, the size of the trigger button, etc.
[0064] In one possible scenario, the method provided by the present disclosure can be applied to a scenario in which a user designs an image. In this scenario, the size of the user's screen interface is fixed. Since the interface design of the screen interface is also fixed, the area size of the editing area of the screen interface can also be determined based on the size of the screen interface.
[0065] The sizes of screen interfaces of different users may be different (ie, the screen resolutions are different). Therefore, during the design process, even for materials with the same first display size, the final calculated texture sizes may be different.
[0066] In one possible scenario, when editing a target image, a user can add a layer in the editing area of the screen interface and add the material to be rendered on the layer. Accordingly, the first display size of the material to be rendered can be adjusted in response to the editing operation on the material to be rendered.
[0067] The first display size of the material to be rendered in the editing area of the screen interface can be understood as the user-set or default display size of the material to be rendered in the editing area. In the embodiment of the present disclosure, the first display size is only the size during the editing process, not the actual size of the material to be rendered after rendering.
[0068] In one embodiment of the present disclosure, for step 102, the canvas size of the canvas where the material to be rendered is located can be pre-defined by the user, the canvas where different materials constituting the same target image are located can be the same canvas, and the canvas sizes of the canvas where different materials constituting the same target image are located can be the same.
[0069] In one possible implementation, when determining a first scaling ratio for rendering the canvas to the editing area based on the canvas size and the area size, a first height scaling ratio between the canvas height of the canvas size and the area height of the editing area can be calculated respectively; and a first width scaling ratio between the canvas width of the canvas size and the area width of the editing area can be calculated; and then, based on the first width scaling ratio and the first height scaling ratio, the first scaling ratio can be determined.
[0070] It should be noted that the first scaling ratio does not reflect the actual scale of the canvas when rendered to the editing interface. When rendering the canvas to the editing interface, the canvas's aspect ratio must be maintained to ensure the most realistic display of the canvas on the editing interface. The display size and scaling ratio of the canvas after rendering to the editing interface will be described below through several exemplary embodiments and will not be discussed in detail here.
[0071] Exemplarily, the first height scaling ratio and the first width scaling ratio may be calculated using the following formula: S grx =rx / gx. (1) S gry =ry / gy. (2)
[0072] Among them, S grx Indicates the first width scaling ratio, S gry Indicates the first height scaling ratio, gx indicates the width of the canvas, gy indicates the height of the canvas, rx indicates the width of the editing area, and ry indicates the height of the editing area.
[0073] In a possible implementation, when determining the first scaling ratio based on the first width scaling ratio and the first height scaling ratio, there are two cases:
[0074] Case 1
[0075] In a case where the first width scaling ratio is greater than the first height scaling ratio, the first height scaling ratio is used as the first scaling ratio.
[0076] Here, if the first width scaling ratio is greater than the first height scaling ratio, the first height scaling ratio is used as the first scaling ratio and the canvas is scaled to the editing area of the screen interface according to the first scaling ratio. The width and height of the scaled canvas can be calculated by the following formula: GSw = gx * S gry =gx*ry / gy, GS h =gy*S gry =gy*ry / gy=ry. (3)
[0077] Among them, GS w Indicates the width of the canvas after scaling, GS h Indicates the height of the canvas after scaling; S grx Indicates the first width scaling ratio, S gry Indicates the first height scaling ratio, gx indicates the width of the canvas before scaling, gy indicates the height of the canvas before scaling, rx indicates the width of the editing area, and ry indicates the height of the editing area.
[0078] It can be seen that after the canvas is scaled according to the first height scaling ratio, the aspect ratio of the canvas is unchanged because the length and width of the canvas are scaled proportionally. h It is the same as the height of the editing area.
[0079] Case 2
[0080] When the first width scaling ratio is less than or equal to the first height scaling ratio, the first width scaling ratio is used as the first scaling ratio.
[0081] Here, if the first width scaling ratio is less than or equal to the first height scaling ratio, the first width scaling ratio is used as the first scaling ratio and the canvas is scaled to the editing area of the screen interface according to the first scaling ratio. The width and height of the scaled canvas can be calculated by the following formula: GS w =gx*S grx =gx*rx / gx=rx,GS h =gy*S grx =gy*rx / gx. (4)
[0082] Among them, GS w Indicates the width of the canvas after scaling, GS h Indicates the height of the canvas after scaling; S grx Indicates the first width scaling ratio, S gry Indicates the first height scaling ratio, gx indicates the width of the canvas before scaling, gy indicates the height of the canvas before scaling, rx indicates the width of the editing area, and ry indicates the height of the editing area.
[0083] It can be seen from this that after the canvas is scaled according to the first width scaling ratio, the aspect ratio of the canvas is unchanged because the length and width of the canvas are scaled proportionally; after scaling according to the first width scaling ratio, the width of the canvas is the same as the width of the editing area.
[0084] According to an embodiment of the present disclosure, when the first width scaling ratio is greater than the first height scaling ratio, the first height scaling ratio is used as the first scaling ratio, and when the first width scaling ratio is less than or equal to the first height scaling ratio, the first width scaling ratio is used as the first scaling ratio, thereby ensuring that when the canvas is scaled to the editing area of the screen interface according to the first scaling ratio, the canvas can be completely displayed in the editing area of the screen interface.
[0085] In one embodiment of the present disclosure, when the first width scaling ratio is greater than the first height scaling ratio, after scaling the canvas according to the first height scaling ratio, the width after scaling is compared with the width of the editing area, and the following formula may be used:
[0086] Since the first width scaling ratio is greater than the first height scaling ratio, we have:
[0087] That is: rx*gy-ry*gr>0. (7)
[0088] Among them, GS w Indicates the width of the canvas after scaling, S grx Indicates the first width scaling ratio, S gry Indicates the first height scaling ratio, gx indicates the width of the canvas before scaling, gy indicates the height of the canvas before scaling, rx indicates the width of the editing area, and ry indicates the height of the editing area.
[0089] From the above formulas (5) and (7), it can be concluded that GS w -rx is less than 0, that is: the width GS after the canvas is scaled w is smaller than the width rx of the editing area. Therefore, if the first width scaling ratio is greater than the first height scaling ratio, after scaling the canvas according to the first height scaling ratio, the height after scaling is the same as the height of the editing area, and the width after scaling is smaller than the width of the editing area. Therefore, after scaling according to the first height scaling ratio, the entire canvas can be displayed in the editing area.
[0090] In contrast to the above-mentioned embodiment of the present disclosure, when the first width scaling ratio is greater than the first height scaling ratio, if the canvas is scaled according to the first width scaling ratio, the height of the canvas after scaling can be compared with the height of the editing area according to a similar approach as in the above formulas (5)-(7). Accordingly, it can be obtained that: when the first width scaling ratio is greater than the first height scaling ratio, if the canvas is scaled according to the first width scaling ratio, the width of the canvas after scaling is the same as the width of the editing area, and the height of the canvas after scaling is greater than the height of the editing area. Therefore, after scaling according to the first width scaling ratio, the entire canvas cannot be displayed in the editing area.
[0091] In another embodiment of the present disclosure, when the first width scaling ratio is less than or equal to the first height scaling ratio, after scaling according to the first width scaling ratio, the height after scaling is compared with the height of the editing area according to a similar approach to the above formulas (5)-(7), and it can be seen that the width after scaling is the same as the width of the editing area, and the height after scaling is less than or equal to the height of the editing area. Therefore, after scaling according to the first width scaling ratio, the entire canvas can be displayed in the editing area.
[0092] In summary, when the first width scaling ratio is greater than the first height scaling ratio, after the canvas is scaled according to the first height scaling ratio, the height of the scaled canvas is the same as the height of the editing area, and the width of the scaled canvas is smaller than the width of the editing area.
[0093] When the first width scaling ratio is less than or equal to the first height scaling ratio, after the canvas is scaled according to the first width scaling ratio, the width of the scaled canvas is the same as the width of the editing area, and the height of the scaled canvas is less than or equal to the height of the editing area.
[0094] In one possible implementation, for step 103, when determining the second display size after rendering the material to be rendered to the canvas based on the first scaling ratio and the first display size, the width and height of the first display size can be scaled according to the first scaling ratio to obtain the second display size.
[0095] For example, the width and height of the first display size may be scaled according to the first scaling ratio using the following formula:
[0096] Wherein, w1 and h1 represent the width and height of the first display size, w2 and h2 represent the width and height of the second display size, and s represents the first scaling ratio.
[0097] In a possible implementation, in step 104 , when determining the texture size of the material to be rendered based on the second display size, the second display size may be directly used as the texture size of the material to be rendered.
[0098] In another possible implementation, for step 104, due to different device performances, in order to adapt to all devices, the texture size of the material to be rendered may be limited. The device here refers to the main device that executes the rendering method of the embodiment of the present disclosure.
[0099] For example, the texture size of the material to be rendered may be limited based on a preset display size of a device.
[0100] Exemplarily, when determining the texture size of the material to be rendered based on the second display size, when the second display size is less than or equal to the preset display size, the second display size can be directly used as the texture size of the material to be rendered; when the second display size is larger than the preset display size, the second display size can be scaled to determine the texture size of the material to be rendered.
[0101] In one possible implementation, the preset display sizes corresponding to different devices may be the same, for example, all may be 2K resolution; or, in another possible implementation, the preset display sizes corresponding to different devices may be different.
[0102] Exemplarily, after user authorization, the operating status information and / or device memory usage of the user device may be obtained, and then a preset display size matching the operating status information and / or device memory usage of the user device may be determined.
[0103] In an optional embodiment, when scaling the second display size to determine the texture size of the material to be rendered, for example, a third scaling ratio of the second display size can be determined based on the second display size and the preset display size, and then the second display size can be scaled according to the third scaling ratio to determine the texture size of the material to be rendered.
[0104] In a possible implementation, a method for determining a third scaling ratio of the second display size based on the second display size and the preset display size may be similar to a method for determining the first scaling ratio based on the canvas size and the area size of the editing area, and will not be repeated here.
[0105] For example, a third height scaling ratio between the height of the second display size and the height of the preset display size, and a third width scaling ratio between the width of the second display size and the width of the preset display size can be calculated respectively, and then the third scaling ratio can be determined based on the third width scaling ratio and the third height scaling ratio.
[0106] For example, if the third width scaling ratio is greater than the third height scaling ratio, the third height scaling ratio is used as the third scaling ratio; if the third width scaling ratio is less than or equal to the third height scaling ratio, the third width scaling ratio is used as the third scaling ratio.
[0107] In an optional implementation, after the second display size is scaled according to the third scaling ratio, the scaled display size is smaller than or equal to the preset display size, and the scaled display size is the texture size of the material to be rendered.
[0108] It should be noted that the present disclosure is not limited to the above embodiments, and any other known method that can maintain the material ratio of the material to be rendered and scale the material to be rendered to a size smaller than the preset display size may also be adopted.
[0109] After determining the texture size of the material to be rendered, the material to be rendered may be rendered according to the texture size. For example, the material to be rendered may be rendered to a canvas according to the texture size, and then rendered on screen based on the canvas rendering result.
[0110] In a possible implementation manner, rendering the material to be rendered may be understood as rendering and displaying the current material to be rendered and other materials to be rendered as a whole after receiving an export instruction for the target image.
[0111] It should be noted that the aforementioned second display size is not the actual size of the rendered material on the canvas. Rather, it is the theoretical size of the rendered material on the canvas, when scaled proportionally with the canvas. In actual implementation, the rendered material is rendered to the canvas based on the texture size, which is not necessarily equal to the second display size.
[0112] If the texture size of the material to be rendered is not associated with the first scaling ratio, but a fixed material texture size is used regardless of the size of the canvas, then when the canvas size is small, the material to be rendered needs to be significantly downsampled and rendered off-screen to the canvas first, and then when it is rendered on the screen, it needs to be significantly upsampled and rendered to the screen. This will inevitably lead to serious loss of image information and unnecessary waste of texture memory. When the canvas is large, the material to be rendered needs to be significantly upsampled and rendered off-screen to the canvas first, which will inevitably cause a decrease in image clarity.
[0113] In the above method of the embodiment of the present disclosure, the texture size of the material to be rendered is associated with the first scaling ratio, and the scaling ratio between the texture size of the material to be rendered and the first display size of the material to be rendered in the editing area is consistent with the first scaling ratio between the canvas and the editing area. In this way, the matching of the material to be rendered and the canvas size can be achieved without up or down sampling, thereby improving the image clarity.
[0114] In addition, if the texture size of the material to be rendered is not associated with the first display size, and the material texture is not changed no matter how the user zooms in or out of the material to be rendered in the editing interface, but the projection transformation method (which also involves up and down sampling) is used to display it on the screen, then as the material is enlarged, the clarity of the material will decrease, and as the material is reduced, although the clarity will not become blurred, it will also cause unnecessary waste of texture memory (because a smaller texture size can achieve the same clarity).
[0115] In the above method of the embodiment of the present disclosure, the texture size of the material to be rendered is associated with the first display size of the material to be rendered in the editing area. When the user changes the first display size of the material to be rendered in the editing area, the texture size of the material to be rendered can be adjusted accordingly. This can achieve dynamic texture size adjustment, improve material clarity, and avoid waste of texture memory.
[0116] Those skilled in the art will understand that, in each exemplary embodiment of the above method, the writing order of each step does not mean a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.
[0117] Based on the same inventive concept, an embodiment of the present disclosure also provides a rendering device for image materials corresponding to the rendering method of the above-mentioned image materials. Since the principle of solving the problem by the device in the embodiment of the present disclosure is similar to the rendering method of the above-mentioned image materials in the embodiment of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0118] 2 , which is a schematic diagram of the architecture of a device for rendering image material according to an embodiment of the present disclosure, the device may include: a determination module 201 , a first calculation module 202 , a second calculation module 203 , a texture size determination module 204 , and a rendering module 205 .
[0119] The determination module 201 is configured to determine a first display size of an editing area on a screen interface set for a material to be rendered.
[0120] The first calculation module 202 is configured to determine a first scaling ratio for rendering the canvas to the editing area based on the canvas size of the to-be-rendered material and the area size of the editing area of the screen interface.
[0121] The second calculation module 203 is configured to determine a second display size of the to-be-rendered material after it is rendered on the canvas based on the first scaling ratio and the first display size.
[0122] The texture size determining module 204 is configured to determine the texture size of the material to be rendered based on the second display size, and render the material to be rendered according to the texture size.
[0123] In one possible implementation, the first calculation module 202, when determining the first scaling ratio for rendering the canvas to the editing area based on the canvas size of the to-be-rendered material and the area size of the editing area on the screen interface, is configured to:
[0124] respectively calculating a first height scaling ratio between a canvas height of the canvas size and a region height of the editing region, and a first width scaling ratio between a canvas width of the canvas size and a region width of the editing region;
[0125] The first scaling ratio is determined based on the first width scaling ratio and the first height scaling ratio.
[0126] In a possible implementation, when determining the first scaling ratio based on the first width scaling ratio and the first height scaling ratio, the first calculation module 202 is configured to:
[0127] In a case where the first width scaling ratio is greater than the first height scaling ratio, using the first height scaling ratio as the first scaling ratio;
[0128] When the first width scaling ratio is less than or equal to the first height scaling ratio, the first width scaling ratio is used as the first scaling ratio.
[0129] In one possible implementation, when the first width scaling ratio is greater than the first height scaling ratio, after the canvas is scaled according to the first height scaling ratio, the height of the scaled canvas is the same as the height of the editing area, and the width of the scaled canvas is smaller than the width of the editing area.
[0130] When the first width scaling ratio is less than or equal to the first height scaling ratio, after the canvas is scaled according to the first width scaling ratio, the width of the scaled canvas is the same as the width of the editing area, and the height of the scaled canvas is less than or equal to the height of the editing area.
[0131] In a possible implementation, when determining the texture size of the material to be rendered based on the second display size, the texture size determining module 204 is configured to:
[0132] When the second display size is smaller than or equal to the preset display size, using the second display size as the texture size of the material to be rendered;
[0133] In a case where the second display size is larger than the preset display size, scaling is performed on the second display size to determine a texture size of the material to be rendered.
[0134] In one possible implementation, when the second display size is larger than the preset display size, the texture size determination module 204, when scaling the second display size to determine the texture size of the to-be-rendered material, is configured to:
[0135] determining a third scaling ratio of the second display size based on the second display size and the preset display size;
[0136] The second display size is scaled according to the third scaling ratio to determine the texture size of the material to be rendered.
[0137] In a possible implementation, when determining the third scaling ratio of the second display size based on the second display size and the preset display size, the texture size determining module 204 is configured to:
[0138] respectively calculating a third height scaling ratio between the height of the second display size and the height of the preset display size, and a third width scaling ratio between the width of the second display size and the width of the preset display size;
[0139] The third scaling ratio is determined based on the third width scaling ratio and the third height scaling ratio.
[0140] In a possible implementation, the texture size determination module 204, when determining the third scaling ratio based on the third width scaling ratio and the third height scaling ratio, is configured to:
[0141] In a case where the third width scaling ratio is greater than the third height scaling ratio, using the third height scaling ratio as the third scaling ratio;
[0142] When the third width scaling ratio is less than or equal to the third height scaling ratio, the third width scaling ratio is used as the third scaling ratio.
[0143] In a possible implementation, the apparatus further includes a rendering module 205 configured to:
[0144] Rendering the material to be rendered onto a canvas according to the texture size;
[0145] Render on screen based on the canvas rendering results.
[0146] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference can be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.
[0147] The modules or units involved in the embodiments of the present disclosure may be implemented in software or hardware, wherein the name of a module or unit does not necessarily limit the module or unit itself.
[0148] Based on the same technical concept, an embodiment of the present disclosure also provides a computer device. Referring to Figure 3, it is a structural diagram of a computer device 300 provided in an embodiment of the present disclosure, which may include a processor 301, a memory 302 and a bus 303. In one possible implementation, the memory 302 is used to store execution instructions, including a memory 3021 and an external memory 3022; the memory 3021 here is also called an internal memory, which is used to temporarily store the calculation data in the processor 301, as well as the data exchanged with the external memory 3022 such as a hard disk. The processor 301 exchanges data with the external memory 3022 through the memory 3021. When the computer device 300 is running, the processor 301 communicates with the memory 302 through the bus 303, so that the processor 301 executes the following instructions:
[0149] Determine a first display size of an editing area on a screen interface set for the material to be rendered;
[0150] Determining a first scaling ratio for rendering the canvas to the editing area based on a canvas size of the to-be-rendered material and an area size of the editing area of the screen interface;
[0151] Determining, based on the first scaling ratio and the first display size, a second display size of the to-be-rendered material after it is rendered onto the canvas;
[0152] Based on the second display size, a texture size of the material to be rendered is determined, and the material to be rendered is rendered according to the texture size.
[0153] In one possible implementation, the instructions executed by the processor 301 include determining, based on the canvas size of the canvas where the material to be rendered is located and the area size of the editing area on the screen interface, a first scaling ratio for rendering the canvas to the editing area, including:
[0154] respectively calculating a first height scaling ratio between a canvas height of the canvas size and a region height of the editing region, and a first width scaling ratio between a canvas width of the canvas size and a region width of the editing region;
[0155] The first scaling ratio is determined based on the first width scaling ratio and the first height scaling ratio.
[0156] In a possible implementation, in the instructions executed by the processor 301, determining the first scaling ratio based on the first width scaling ratio and the first height scaling ratio includes:
[0157] In a case where the first width scaling ratio is greater than the first height scaling ratio, using the first height scaling ratio as the first scaling ratio;
[0158] When the first width scaling ratio is less than or equal to the first height scaling ratio, the first width scaling ratio is used as the first scaling ratio.
[0159] In one possible implementation, in the instructions executed by the processor 301, when the first width scaling ratio is greater than the first height scaling ratio, after the canvas is scaled according to the first height scaling ratio, the height of the scaled canvas is the same as the height of the editing area, and the width of the scaled canvas is less than the width of the editing area.
[0160] When the first width scaling ratio is less than or equal to the first height scaling ratio, after the canvas is scaled according to the first width scaling ratio, the width of the scaled canvas is the same as the width of the editing area, and the height of the scaled canvas is less than or equal to the height of the editing area.
[0161] In a possible implementation, in the instructions executed by the processor 301, determining the texture size of the to-be-rendered material based on the second display size includes:
[0162] When the second display size is smaller than or equal to the preset display size, using the second display size as the texture size of the material to be rendered;
[0163] In a case where the second display size is larger than the preset display size, scaling is performed on the second display size to determine a texture size of the material to be rendered.
[0164] In one possible implementation, the instructions executed by the processor 301, wherein, when the second display size is larger than the preset display size, scaling the second display size to determine the texture size of the to-be-rendered material, include:
[0165] determining a third scaling ratio of the second display size based on the second display size and the preset display size;
[0166] The second display size is scaled according to the third scaling ratio to determine the texture size of the material to be rendered.
[0167] In a possible implementation, in the instructions executed by the processor 301, determining a third scaling ratio of the second display size based on the second display size and the preset display size includes:
[0168] respectively calculating a third height scaling ratio between the height of the second display size and the height of the preset display size, and a third width scaling ratio between the width of the second display size and the width of the preset display size;
[0169] The third scaling ratio is determined based on the third width scaling ratio and the third height scaling ratio.
[0170] In a possible implementation, in the instructions executed by the processor 301, determining the third scaling ratio based on the third width scaling ratio and the third height scaling ratio includes:
[0171] In a case where the third width scaling ratio is greater than the third height scaling ratio, using the third height scaling ratio as the third scaling ratio;
[0172] When the third width scaling ratio is less than or equal to the third height scaling ratio, the third width scaling ratio is used as the third scaling ratio.
[0173] In a possible implementation, in the instructions executed by the processor 301, rendering the to-be-rendered material according to the texture size includes:
[0174] Rendering the material to be rendered onto a canvas according to the texture size;
[0175] Render on screen based on the canvas rendering results.
[0176] Embodiments of the present disclosure further provide a computer-readable storage medium having a computer program stored thereon. When executed by a processor, the computer program executes the steps of the method for rendering image material described in the above method embodiment. In possible implementations, the storage medium may be a volatile or non-volatile computer-readable storage medium.
[0177] An embodiment of the present disclosure further provides a computer program product, which carries program code. The instructions included in the program code can be used to execute the steps of the image material rendering method described in the above method embodiment. For details, please refer to the above method embodiment and will not be repeated here.
[0178] In possible implementations, the computer program product may be implemented in hardware, software, or a combination thereof. In one embodiment, the computer program product is implemented as a computer storage medium. In another embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).
[0179] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems and devices described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0180] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0181] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0182] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, 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. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present disclosure. 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), a random access memory (RAM), a magnetic disk or an optical disk.
[0183] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure has been described in detail with reference to the above-described embodiments, those skilled in the art should understand that any person skilled in the art can modify or easily conceive of changes to the technical solutions described in the above-described embodiments within the technical scope disclosed in the present disclosure, or replace some of the technical features therein with equivalents. Such modifications, changes, or replacements do not deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure shall be subject to the protection scope of the claims.
Claims
1. A method for rendering an image material, comprising: Determine a first display size of an editing area in a screen interface set for the material to be rendered; Determining a first scaling ratio for rendering the canvas to the editing area based on the canvas size of the canvas where the material to be rendered is located and the area size of the editing area of the screen interface; Determine, based on the first scaling ratio and the first display size, a second display size after the to-be-rendered material is rendered on the canvas; Based on the second display size, a texture size of the material to be rendered is determined, and the material to be rendered is rendered according to the texture size.
2. The method according to claim 1, wherein: The determining, based on the canvas size of the canvas where the material to be rendered is located and the area size of the editing area of the screen interface, a first scaling ratio for rendering the canvas to the editing area includes: respectively calculating a first height scaling ratio between a canvas height of the canvas size and a region height of the editing region, and a first width scaling ratio between a canvas width of the canvas size and a region width of the editing region; The first scaling ratio is determined based on the first width scaling ratio and the first height scaling ratio.
3. The method according to claim 2, wherein: The determining the first scaling ratio based on the first width scaling ratio and the first height scaling ratio includes: When the first width scaling ratio is greater than the first height scaling ratio, using the first height scaling ratio as the first scaling ratio; When the first width scaling ratio is less than or equal to the first height scaling ratio, the first width scaling ratio is used as the first scaling ratio.
4. The method according to claim 3, wherein: When the first width scaling ratio is greater than the first height scaling ratio, after the canvas is scaled according to the first height scaling ratio, the height of the scaled canvas is the same as the height of the editing area, and the width of the scaled canvas is less than the width of the editing area; When the first width scaling ratio is less than or equal to the first height scaling ratio, after the canvas is scaled according to the first width scaling ratio, the scaled canvas The width of the canvas is the same as the width of the editing area, and the height of the canvas after scaling is less than or equal to the height of the editing area.
5. The method according to any one of claims 1 to 4, wherein: The determining, based on the second display size, a texture size of the material to be rendered includes: When the second display size is smaller than or equal to the preset display size, using the second display size as the texture size of the material to be rendered; When the second display size is larger than the preset display size, scaling is performed on the second display size to determine the texture size of the material to be rendered.
6. The method according to claim 5, wherein: When the second display size is larger than the preset display size, scaling the second display size to determine the texture size of the material to be rendered includes: determining a third scaling ratio of the second display size based on the second display size and the preset display size; The second display size is scaled according to the third scaling ratio to determine the texture size of the material to be rendered.
7. The method according to claim 6, wherein: The determining, based on the second display size and the preset display size, a third scaling ratio of the second display size includes: respectively calculating a third height scaling ratio between the height of the second display size and the height of the preset display size, and a third width scaling ratio between the width of the second display size and the width of the preset display size; The third scaling ratio is determined based on the third width scaling ratio and the third height scaling ratio.
8. The method according to claim 7, wherein: The determining the third scaling ratio based on the third width scaling ratio and the third height scaling ratio includes: In a case where the third width scaling ratio is greater than the third height scaling ratio, using the third height scaling ratio as the third scaling ratio; When the third width scaling ratio is less than or equal to the third height scaling ratio, the third width scaling ratio is used as the third scaling ratio.
9. The method according to any one of claims 1 to 8, wherein: The rendering of the material to be rendered according to the texture size includes: Rendering the material to be rendered to a canvas according to the texture size; Render on screen based on the canvas rendering result.
10. A rendering device for image material, comprising: A determination module, configured to determine a first display size of an editing area in a screen interface set for a material to be rendered; A first calculation module is configured to determine a first scaling ratio for rendering the canvas to the editing area based on the canvas size of the canvas where the material to be rendered is located and the area size of the editing area of the screen interface; A second calculation module is configured to determine a second display size after the to-be-rendered material is rendered on the canvas based on the first scaling ratio and the first display size; as well as The texture size determination module is configured to determine the texture size of the material to be rendered based on the second display size, and render the material to be rendered according to the texture size.
11. A computer device comprising: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the computer device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the method for rendering image material according to any one of claims 1 to 9 are performed. 12 . A computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, performs the steps of the method for rendering image material according to any one of claims 1 to 9.
Citation Information
Patent Citations
Image rendering method and device, electronic equipment and storage medium
CN111161385A
Map generation method and map generation device
CN113393554A
Poster drawing method
CN113628295A
Data rendering method and device, electronic equipment and computer storage medium
CN114037748A
Image material rendering method and device, computer equipment and storage medium
CN116820646A
Cited By
Video playing method and related device
CN120075531A
Intelligent image processing method and device, computer equipment and storage medium
CN121095394A