Image generation method, image processing method, related equipment and medium

By obtaining element information of the target application page to generate graphic language code, the problem of poor effect of existing screenshot image generation methods is solved, and screenshot effects that are highly consistent with the application page are achieved, reducing development and resource costs.

CN113835597BActive Publication Date: 2024-11-08TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010595163.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-06-24
Publication Date
2024-11-08
Estimated Expiration
2040-06-24

AI Technical Summary

Technical Problem

The existing screenshot image generation method has limited CSS attributes supported by the extension component and difficult to debug Canvas drawing, resulting in a large gap between the screenshot image and the application page, which has poor results.

Method used

By obtaining element information of the target application page, generating graphic language code, and creating screenshot images based on the code to ensure that the screenshot image is highly similar to the application page.

Benefits of technology

The screenshot effect is significantly improved, making the generated screenshot images highly consistent with the application page, reducing development workload, and saving interactive resources between the target application and the server.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113835597B_ABST
    Figure CN113835597B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses an image generation method, an image processing method, related equipment and medium, wherein the image generation method comprises: in response to a screenshot instruction for an application page of a target application, obtaining element information of a target page element required for a screenshot image; the application page is rendered according to element information of multiple page elements, and the target page element is a part of or all of the multiple page elements; the element information of the target page element is used to generate a graphic language code of the screenshot image; and the screenshot image is created according to the graphic language code. The embodiment of the present invention can ensure that the screenshot image and the application page are highly similar, effectively improving the screenshot effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of Internet technology, specifically to the field of image processing technology, and in particular to an image generating method, an image processing method, an image generating device, an image processing device, a terminal and a computer storage medium. Background Art

[0002] With the development of science and technology, more and more applications support screenshot sharing functions; the screenshot sharing function here refers to the function of generating screenshot images similar to the application page displayed by the application, rather than the screenshot capability provided by the terminal or client itself. At present, the image generation methods used to generate screenshot images usually include the following: ① Using the extension components provided by the application (such as wxml-to-canvas components) to generate screenshot images by drawing canvas; ② Using third-party drawing components (such as Painter components) or directly using the official Canvas API (Application Programming Interface) to draw screenshot images.

[0003] Practice has shown that the above-mentioned image generation methods are usually difficult to achieve many rendering effects due to various factors (such as the extremely limited CSS (Cascading Style Sheets) properties supported by the extension component, and the difficulty in debugging Canvas drawing, etc.), which often results in a large gap between the generated screenshot image and the actual application page, and the screenshot effect is poor. Therefore, how to better generate screenshot images has become a research hotspot. Summary of the invention

[0004] The embodiments of the present invention provide an image generation method, an image generation method, related devices and media, which can ensure that the screenshot image and the application page are highly similar, and effectively improve the screenshot effect.

[0005] In one aspect, an embodiment of the present invention provides an image generation method, the image generation method comprising:

[0006] In response to a screenshot instruction for an application page of a target application, element information of a target page element required for a screenshot image is acquired; the application page is rendered according to element information of a plurality of page elements, and the target page element is a part of or all of the plurality of page elements;

[0007] Generate a graphic language code of the screenshot image using the element information of the target page element;

[0008] The screenshot image is created according to the graphics language code.

[0009] On the other hand, an embodiment of the present invention provides an image processing method, the image processing method comprising:

[0010] Displaying an information resource selection interface of a target application in a target client, wherein the target application refers to a sub-application that runs in the target client and does not need to be installed; the information resource selection interface includes a plurality of information resources;

[0011] According to a sharing operation for at least one information resource in the information resource selection interface, switching from the information resource selection interface to the information resource sharing interface of the target application; the information resource sharing interface belongs to an application page of the target application, the information resource sharing interface includes the at least one information resource and a screenshot trigger button, and the at least one information resource and the screenshot trigger button are rendered according to element information of multiple page elements;

[0012] If the screenshot trigger button is triggered, the screenshot image is displayed.

[0013] In one embodiment, the screenshot image is generated using the above-mentioned image generation method. Specifically, the screenshot image is generated by a graphic language code corresponding to at least one page element in the application page, and the graphic language code is generated using element information of the at least one page element.

[0014] In another aspect, an embodiment of the present invention provides an image generating device, the image generating device comprising:

[0015] an acquisition unit, configured to acquire element information of target page elements required for the screenshot image in response to a screenshot instruction for an application page of a target application; the application page is rendered based on element information of a plurality of page elements, and the target page elements are part of or all of the plurality of page elements;

[0016] A processing unit, configured to generate a graphic language code of the screenshot image using element information of the target page element;

[0017] The processing unit is further configured to create the screenshot image according to the graphic language code.

[0018] In another aspect, an embodiment of the present invention provides an image processing device, the image processing device comprising:

[0019] A display unit, configured to display an information resource selection interface of a target application in a target client, wherein the target application refers to a sub-application that runs in the target client and does not need to be installed; the information resource selection interface includes a plurality of information resources;

[0020] a switching unit, configured to switch from the information resource selection interface to the information resource sharing interface of the target application according to a sharing operation on at least one information resource in the information resource selection interface; the information resource sharing interface belongs to an application page of the target application, the information resource sharing interface includes the at least one information resource and a screenshot trigger button, and the at least one information resource and the screenshot trigger button are rendered according to element information of multiple page elements;

[0021] The display unit is further configured to display a screenshot image if the screenshot trigger button is triggered.

[0022] In one embodiment, the screenshot image is generated using the above-mentioned image generation method. Specifically, the screenshot image is generated by a graphic language code corresponding to at least one page element in the application page, and the graphic language code is generated using element information of the at least one page element.

[0023] In another aspect, an embodiment of the present invention provides a terminal, the terminal including an input device and an output device, the terminal further including:

[0024] a processor adapted to implement one or more instructions; and,

[0025] A computer storage medium storing one or more first instructions, wherein the one or more first instructions are suitable for being loaded by the processor and executing the following steps:

[0026] In response to a screenshot instruction for an application page of a target application, element information of a target page element required for a screenshot image is acquired; the application page is rendered according to element information of a plurality of page elements, and the target page element is a part of or all of the plurality of page elements;

[0027] Generate a graphic language code of the screenshot image using the element information of the target page element;

[0028] The screenshot image is created according to the graphics language code.

[0029] Alternatively, the computer storage medium stores one or more second instructions, and the one or more second instructions are suitable for being loaded by the processor and executing the following steps:

[0030] Displaying an information resource selection interface of a target application in a target client, wherein the target application refers to a sub-application that runs in the target client and does not need to be installed; the information resource selection interface includes a plurality of information resources;

[0031] According to a sharing operation for at least one information resource in the information resource selection interface, switching from the information resource selection interface to the information resource sharing interface of the target application; the information resource sharing interface belongs to an application page of the target application, the information resource sharing interface includes the at least one information resource and a screenshot trigger button, and the at least one information resource and the screenshot trigger button are rendered according to element information of multiple page elements;

[0032] If the screenshot trigger button is triggered, the screenshot image is displayed.

[0033] In one embodiment, the screenshot image is generated using the above-mentioned image generation method. Specifically, the screenshot image is generated by a graphic language code corresponding to at least one page element in the application page, and the graphic language code is generated using element information of the at least one page element.

[0034] On the other hand, an embodiment of the present invention provides a computer storage medium, wherein the computer storage medium stores one or more first instructions, and the one or more first instructions are suitable for being loaded by a processor and executing the above-mentioned image generation method; or, the computer storage medium stores one or more second instructions, and the one or more second instructions are suitable for being loaded by the processor and executing the above-mentioned image processing method.

[0035] The application page of the target application in the embodiment of the present invention is rendered based on the element information of multiple page elements; therefore, after detecting a screenshot instruction for the application page, the element information of some or all of the multiple page elements can be used to generate a graphic language code for the screenshot image, and the screenshot image can be created based on the graphic language code. Since the graphic language code can completely retain the element information of some or all of the page elements in the application page, the screenshot image created based on the graphic language code can be highly similar to the application page, effectively improving the screenshot effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.

[0037] Figure 1a is a schematic diagram of the architecture of an image processing system provided by an embodiment of the present invention;

[0038] Figure 1b is a schematic diagram of a screenshot principle provided by an embodiment of the present invention;

[0039] Figure 1c It is a schematic diagram of an interface document of an API interface of a target application provided by an embodiment of the present invention;

[0040] Figure 1d It is a code schematic diagram of a custom attribute statement of each page element in a page code provided by an embodiment of the present invention;

[0041] Figure 1e It is a code schematic diagram of a rendering attribute in a page code provided by an embodiment of the present invention;

[0042] Figure 1f It is a schematic diagram of a screenshot component provided by an embodiment of the present invention generating a screenshot image according to a graphic language code with the help of a server;

[0043] Figure 2 is a flow chart of an image generating method provided by an embodiment of the present invention;

[0044] Figure 3a It is a schematic diagram of a code for amplifying the attribute information of a root element to simulate the pixel ratio of a device provided by an embodiment of the present invention;

[0045] Figure 3b is a code schematic diagram of a graphic language code provided by an embodiment of the present invention;

[0046] Figure 3c A schematic diagram of a code for creating a screenshot image according to a graphic language code provided by an embodiment of the present invention;

[0047] Figure 3d is another code schematic diagram of creating a screenshot image according to a graphic language code provided by an embodiment of the present invention;

[0048] Figure 4 is a flowchart of an image processing method provided by an embodiment of the present invention;

[0049] Figure 5a is a schematic diagram of an information resource selection interface provided by an embodiment of the present invention;

[0050] Figure 5b It is a schematic diagram of displaying the number of selected information resources in an information resource selection interface provided by an embodiment of the present invention;

[0051] Figure 5c is a schematic diagram of outputting a recommendation list of information resources provided by an embodiment of the present invention;

[0052] Figure 5d It is a schematic diagram of switching from an information resource selection interface to an information resource sharing interface provided by an embodiment of the present invention;

[0053] Figure 5e is a schematic diagram of generating a screenshot image provided by an embodiment of the present invention;

[0054] Figure 5f is a schematic diagram of an output image sharing prompt window provided by an embodiment of the present invention;

[0055] Figure 5g is a schematic diagram of another output image sharing prompt window provided by an embodiment of the present invention;

[0056] Figure 5h is a schematic diagram of an output image storage prompt provided by an embodiment of the present invention;

[0057] Figure 6 is a structural schematic diagram of an image generating device provided by an embodiment of the present invention;

[0058] Figure 7 is a structural schematic diagram of an image processing device provided by an embodiment of the present invention;

[0059] Figure 8 It is a schematic diagram of the structure of a terminal provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0060] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention.

[0061] In an embodiment of the present invention, it relates to an image processing system; see Figure 1a As shown, the image processing system may include a server 11 and a terminal 12. The server 11 here may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and basic cloud computing services such as big data and artificial intelligence platforms, etc. The terminal 12 here may include but is not limited to: portable devices such as smart phones, laptops and tablets, or terminal devices such as desktop computers, etc. The target application can be run in the terminal 12, and the target application can be any client application (hereinafter referred to as the client) or a sub-application of any client; the sub-application here refers to an application that can be used without downloading and installing, such as WeChat applets, QQ applets, etc.

[0062] Any page displayed by the target application can be called an application page, that is, the application page can be an information resource selection interface, an information resource sharing interface, etc. displayed by the target application. Among them, the information resource selection interface refers to an interface including multiple information resources to be selected, and the information resource sharing interface refers to an interface including multiple information resources to be shared; the information resources here may include but are not limited to: commodity information resources of each commodity in a commodity purchase application (such as QQ Huigou applet), user information resources of each user in an instant messaging application, etc. Each application page can be obtained by rendering the element information of each page element in a recursive order from the outer layer to the inner layer; among them, the outermost page element is the root element, the second outermost page element is the child element of the root element, and so on. The page element here can also be called a structural element, which can be understood as a display area in the application page for displaying the content of each page; for example, a header (header area) element, a footer (footer area) element, etc. The element information of any page element may include the attribute information of any page element; or include: the attribute information of any page element and the image resource of any page element. Among them, the attribute information of any page element may include: attribute values ​​of element attributes and attribute values ​​of rendering attributes. The element attributes here may include at least one of the following: element size (Size), element style (computed Style), element type, element level, the number of sub-elements of any page element, and text information of any page element, etc.; the rendering attribute here may be a CSS attribute, and the so-called CSS is a computer language used to express file styles such as HTML (an application of standard generalized markup language) or XML (a subset of standard generalized markup language). Optionally, if any page element has an image resource, the attribute information of any page element may also include the resource location of the image resource of any page element; the resource location here may include but is not limited to: canvas canvas, image src (path), background image (background-image), etc.

[0063] In order to be able to better generate screenshot images similar to the application page of the target application, an embodiment of the present invention proposes a screenshot component; the so-called component refers to an object obtained by encapsulating data and methods, and the screenshot component can be used to convert the application page of the target application (such as WeChat applet, QQ applet, browser client, etc.) into a graphic language code, and generate a screenshot image that is highly similar to the application page according to the graphic language code. The graphic language code here refers to the code used to define vector graphics; it may specifically include but is not limited to SVG (a language defined in XML, used to describe two-dimensional vectors and vector / raster graphics) code, Flash (interactive vector graphics and Web animation standard) code, and so on. For ease of explanation, the following description will take the graphic language code as SVG code as an example. In a specific implementation, the screenshot component can be installed in the target application; the screenshot principle can be roughly referred to. Figure 1b As shown, the details are as follows:

[0064] Step S101, obtaining the page structure and style of the application page of the target application.

[0065] The page structure and style here refer to the attribute information of all or part of the page elements in the application page, such as the attribute values ​​of element attributes and the attribute values ​​of rendering attributes; for page elements with image resources, the page structure and style (i.e., attribute information) may also include the resource location of the image resources. Specifically, the native code of the application page of the target application may include the attribute values ​​of the element attributes of each page element and the attribute values ​​of the rendering attributes; but since the storage locations of the attribute values ​​of each element attribute of each page element in the native code are relatively scattered, it may result in fewer attribute values ​​of the element attributes when obtaining the attribute information of the page element from the native code through the API interface provided by the target application. For example, see Figure 1c The interface document of the API interface shown in the figure shows that the API interface provided by the target application can only obtain the attribute values ​​of the element style (computed Style) and the element size (Size) from the native code of the application page; while the attribute values ​​of the element type of the page element and the attribute values ​​of the key element attributes (such as the text information of the target page element, the element level, etc.) cannot be directly obtained from the native code through the API interface. Based on this, before the target application displays the application page, the screenshot component of the embodiment of the present invention can also parse the native code of the application page of the target application to obtain the attribute values ​​of the element attributes of each page element. Then, the attribute values ​​of the element attributes of each page element are used to optimize the native code of the application page to obtain the page code; specifically, the attribute values ​​of the element attributes of each page element can be added to the custom attribute statement of each page element, and the custom attribute statement of each page element can be added to the native code to obtain the page code, such as Figure 1dAs shown. In this way, when the target application renders and displays the application page by running the page code, the screenshot component can directly obtain relatively complete attribute values ​​of element attributes from the custom attribute statements of all or part of the page elements in the page code when executing step S101.

[0066] See also Figure 1d As shown, for any page element, data-name can be used to represent the element type, and the attribute value of the element type of any page element and data-name are associated and added to the custom attribute statement of any page element. data-len can be used to represent the number of sub-elements of any page element, and the attribute value of the number of sub-elements of any page element (i.e., the specific value) and data-len are associated and added to the custom attribute statement of any page element. data-texts can be used to represent the text information of any page element, and the attribute value of the text information of any page element (i.e., the specific content) and data-texts are associated and added to the custom attribute statement of any page element. Data-level can be used to represent the element level, and the element-level attribute value and data-level association of any page element can be added to the custom attribute statement of any page element; wherein, if any page element is a root element, the element-level attribute value of any page element can be 0; if any page element is the first child element of the root element, the element-level attribute value of any page element can be 0-0; if any page element is the second child element of the root element, the element-level attribute value of any page element can be 0-1, and so on.

[0067] It should be noted that, optionally, when generating page codes, the screenshot component proposed in the embodiment of the present invention can also specify the page elements that need to be screenshotted according to business needs. Specifically, an element class name (such as screenshot) can be added to the custom attribute statement of the page element that needs to be screenshotted, and the element class name is used to mark that the page element needs to be screenshotted; in this way, when the screenshot component executes step S101, it can obtain the attribute values ​​of the more complete element attributes of the corresponding page element from the custom attribute statement containing the element class name. In addition, the page code can also include the attribute values ​​of the rendering attributes (i.e., CSS attributes) of each page element; excluding experimental CSS attributes, the page code of the embodiment of the present invention considers as many as 267 rendering attributes for any page element; the relevant code schematic diagram can be shown as follows. Figure 1e Based on this, when executing step S101, the screenshot component can also obtain the attribute values ​​of the rendering attributes of all or part of the page elements from the page code.

[0068] Step S102, loading related resources.

[0069] Specifically, after obtaining the page structure and style, the screenshot component can load related resources; the related resources here may include at least one image resource of a page element. Optionally, in order to improve resource loading efficiency, the embodiment of the present invention can also support resource preloading; that is, before executing step S101, the target application can preload related resources into the cache space, and when the screenshot component is initialized, the related resources cached in the cache space can be directly transferred to the screenshot component.

[0070] Step S103: Generate graphic language code using attribute information and image resources of all or part of the page elements in the application page of the target application.

[0071] Step S104: Generate a screenshot image highly similar to the application page according to the graphic language code through the target application or server.

[0072] Specifically, if the target application supports rendering of the graphic language code, the screenshot image can be directly generated according to the graphic language code in the target application; if the target application does not support rendering of the graphic language code, the graphic language code can be sent to the server, so that the server can generate the screenshot image according to the graphic language code, such as Figure 1f It should be understood that if the target application's application page does not have image resources, after executing step S101, step S102 can be skipped to directly execute steps S103-S104; and in step S103, the attribute information of all or part of the page elements in the target application's application page can be directly used to generate the graphic language code.

[0073] Research has shown that the screenshot principle of the above screenshot component can have the following beneficial effects: ① Since the graphic language code can completely retain the element information of some or all page elements in the application page, the screenshot image created according to the graphic language code can be highly similar to the application page, effectively improving the screenshot effect; ② It can significantly reduce the development workload of developers. ③ In the case where the target application supports graphic language code rendering, it can effectively reduce the interaction between the target application and the server, which can effectively save resources and costs.

[0074] Based on the description of the screenshot principle of the screenshot component, an embodiment of the present invention proposes an image generation method. The image generation method can be executed by the screenshot component mentioned above, or by a target application installed with the screenshot component; for ease of explanation, the following description will take the screenshot component executing the image generation method as an example. Figure 2 , the image generation method may include the following steps S201-S203:

[0075] S201 , in response to a screenshot instruction for an application page of a target application, acquiring element information of target page elements required for a screenshot image.

[0076] In an embodiment of the present invention, an application page is rendered based on the element information of multiple page elements; the target page element here may be part of the multiple page elements or all of the page elements, and the element information of the target page element may include the attribute information of the target page element. The attribute information of the target page element may include: the attribute value of the element attribute of the target page element and the attribute value of the rendering attribute of the target page element; the element attribute of the target page element here may include but is not limited to: element size, element style, element type, element level, number of sub-elements of the target page element, text information of the target page element, and the like.

[0077] As can be seen from the above, the application page of the target application is rendered by running the page code of the application page, and the page code is generated by optimizing the native code of the application page according to the attribute values ​​of the element attributes of each page element. The page code may include the attribute values ​​of the rendering attributes of each page element and the custom attribute statements of each page element. The custom attribute statement of any page element is used to record the attribute values ​​of the element attributes of any page element; if the custom attribute statement of any page element also includes an element class name, and the element class name is used to mark any page element to be screenshotted, then any page element can be a target page element. Based on this, when executing step S201, the screenshot component can respond to the screenshot instruction for the application page of the target application, and call the application program interface (i.e., API interface) of the target application to read the attribute information of the target page element from the page code. Among them, the attribute values ​​of the element attributes of the target page element included in the attribute information of the target page element are read from the custom attribute statement of the target page element in the page code.

[0078] Optionally, the element information of the target page element may also include the target image resource of the target page element. In this case, the screenshot component may also load the target image resource of the target page element when executing step S201. In one embodiment, as can be seen from the above, when the target page element has a target image resource, the attribute information of the target page element may include the resource location of the target image resource in addition to the attribute values ​​of each element attribute and the attribute value of the rendering attribute. Therefore, the screenshot component may obtain the resource location of the target image resource from the attribute information of the target page element; and then load the target image resource from the resource location. In another embodiment, if the application page is an information resource sharing interface, the target application may also preload the target image resource into the cache space. Specifically, before displaying the information resource sharing interface, the target application may display an information resource selection interface; the information resource selection interface includes multiple information resources, each of which corresponds to at least one image resource; then, according to the selection operation for multiple information resources, the image resource corresponding to the selected information resource may be added to the cache space as the target image resource. It can be seen that the target image resource under this implementation mode is preloaded into the cache space by the target application before the screenshot instruction is detected; then the screenshot component can directly obtain the target image resource from the cache space.

[0079] S202: Generate a graphic language code of the screenshot image using the element information of the target page element.

[0080] In a specific implementation, the screenshot component may obtain a code template for creating a screenshot image; then, the element information of the target page element is added to the code template to obtain the graphic language code of the screenshot image. If the number of target page elements is one, the screenshot component may directly add the element information of the target page element to the code template to obtain the graphic language code of the screenshot image. If the number of target page elements is multiple, since the element information of each target page element may include the attribute information of each target page element, and the attribute information of each target page element at least includes the attribute value of the element level; therefore, when the screenshot component adds the element information of the target page element to the code template to obtain the graphic language code of the screenshot image, the attribute value of the element level of each target page element may be obtained from the attribute information of each target page element. Secondly, the parent-child relationship between each target page element may be determined according to the attribute value of the element level of each target page element. Then, according to the parent-child relationship and the recursive order from the parent element to the child element, the element information of each target page element may be added to the code template to obtain the graphic language code of the screenshot image. Specifically, since the root element is located at the outermost layer of the application page, the root element can be determined from multiple target page elements based on the parent-child relationship, and the element information of the root element can be added to the code template; then, the child elements of the root element are determined from the multiple target page elements, and the element information of the child elements of the root element is added to the code template, and so on; thereby, the graphic language code is generated in a recursive order from the outer layer to the inner layer.

[0081] In one implementation, in order to ensure that the screenshot image subsequently created according to the graphic language code is not blurred, when the root element is added to the code template, the attribute information included in the element information of the root element can be enlarged to simulate the device pixel ratio by using the transform scale method, such as Figure 3a Specifically, the attribute values ​​(such as width value, length value, etc.) of the rendering attributes in the attribute information included in the element information of the root element can be scaled according to the device pixel ratio, and the scaled element information is added to the code template. The device pixel ratio refers to the ratio between the device physical pixels and the device independent pixels.

[0082] In another embodiment, when adding the element information of each target page element to the code template, it is also necessary to consider some rendering attributes that are only set on the parent element and will affect the rendering effect of the child element but the child element does not inherit from the parent element (i.e. Figure 3a). The attribute values ​​of these non-inherited rendering attributes usually only exist in the relevant code of the parent element, and the attribute values ​​cannot be read from the relevant code of the child element. This may cause the attribute information included in the element information of the child element to be missing this part of the attribute value, thereby affecting the integrity of the graphic language code, resulting in poor image effects of the screenshot image created according to the graphic language code. Therefore, in order to ensure the image effect of the screenshot image created according to the graphic language code in the future, in the process of adding the element information of each target page element to the code template according to the parent-child relationship and the recursive order from the parent element to the child element to obtain the graphic language code of the screenshot image: for any target page element to be added, if any target page element has a target parent element, the attribute value of the first rendering attribute can be obtained from the attribute information of the target parent element; the first rendering attribute here may include: rendering attributes that affect the rendering effect of any target page element and are not inherited from the target parent element; for example, filter, transform, transparency, etc. Then, the attribute value of the first rendering attribute and the element information of any target page element may be associated and added to the code template to obtain the graphic language code of the screenshot image.

[0083] Among them, one implementation method of associating the attribute value of the first rendering attribute and the element information of any target page element and adding them to the code template to obtain the graphic language code of the screenshot image may be: adding the attribute value of the first rendering attribute to the attribute information included in the element information of any target page element to update the element information of any target page element; then, adding the updated element information of any target page element to the code template to obtain the graphic language code of the screenshot image. Furthermore, since the attribute information included in the element information of the target parent element itself includes the attribute value of the first rendering attribute; if the attribute value of the first rendering attribute is added to the attribute information included in the element information of any target page element, then after adding the element information of the target parent element and the element information of any target page element to the graphic language code, the attribute value of the first rendering attribute will be repeatedly included in the graphic language code, resulting in a large amount of code in the graphic language code.

[0084] Based on this, the screenshot component can extract the attribute value of the first rendering attribute from the attribute information included in the element information of the target parent element, and add the attribute value of the first rendering attribute to the inline style sheet; then, establish a first mapping relationship between the inline style sheet and the target parent element, and add the inline style sheet, the extracted element information of the target parent element, and the first mapping relationship to the code template. In this case, the attribute value of the first rendering attribute and the element information of any target page element are added to the code template in an associated manner to obtain the graphic language code of the screenshot image. Another implementation method can be: establish a second mapping relationship between the inline style sheet and any target page element, and add the second mapping relationship and the element information of any target page element to the code template to obtain the graphic language code of the screenshot image.

[0085] It should be understood that, in addition to the attribute value of the first rendering attribute, if there are other identical attribute values ​​of the rendering attribute between the target parent element and any target page element, the above-mentioned inline style relationship table can also be used to realize the sharing of other identical attribute values ​​of the rendering attribute between the target parent element and any target page element. Specifically, before establishing the first mapping relationship between the inline style sheet and the target parent element, the attribute values ​​of other identical rendering attributes can also be extracted from the attribute information included in the element information of the target parent element, and the attribute values ​​of other identical rendering attributes can be added to the inline style sheet; then the first mapping relationship between the inline style sheet and the target parent element is established, and the inline style sheet, the extracted element information of the target parent element and the first mapping relationship are added to the code template. Correspondingly, the attribute values ​​of other identical rendering attributes can also be deleted from the attribute information included in the element information of any target page element, and then the second mapping relationship between the inline style sheet and any target page element and the element information of any page element after deleting the attribute values ​​of other identical rendering attributes are added to the code template to obtain the graphic language code of the screenshot image. It can be seen that the embodiment of the present invention can use an inline style sheet to share the attribute values ​​of the same rendering attributes between various target page elements, so as to effectively reduce the amount of graphics language code.

[0086] In another embodiment, when adding the element information of each target page element to the code template, it is also necessary to consider some second rendering attributes that can be read from the page code but need to be excluded; the second rendering attributes include: rendering attributes that cause the rendering position of any target page element to be disordered, such as the root node spacing margin, positioning position, top top, bottom bottom, left left, right right and other rendering attributes. Since these second rendering attributes determine the position of the root element relative to its child elements, but the root element is the outermost page element when taking a screenshot; if these second rendering attributes are considered, the rendering position of the root element may be disordered, affecting the image effect of the screenshot image. Therefore, in order to ensure the image effect of the screenshot image created according to the graphic language code later, in the process of adding the element information of each target page element to the code template according to the parent-child relationship and the recursive order from the parent element to the child element, and obtaining the graphic language code of the screenshot image: for any target page element to be added, if the target parent element does not exist for any target page element, it indicates that the target page element is a root element. At this time, it can be detected whether there is an attribute value of the second rendering attribute in the attribute information included in the element information of any target page element; if there is an attribute value of the second rendering attribute, the attribute value of the second rendering attribute can be removed from the attribute information included in the element information of any target page element to update the element information of any target page element; then, the updated element information of any target page element is added to the code template to obtain the graphic language code of the screenshot image. The schematic diagram of the graphic language code can be seen in Figure 3b shown.

[0087] S203, creating a screenshot image according to the graphic language code.

[0088] In a specific implementation, if the target application where the screenshot component is located supports rendering of graphic language codes, a screenshot image can be created directly in the target application according to the graphic language code, and an image index of the screenshot image can be set so that the screenshot image can be found again according to the image index later, such as Figure 3c If the target application where the screenshot component is located does not support the rendering of the graphic language code, the graphic language code can be sent to the server, and the server creates a screenshot image according to the graphic language code. Specifically, after receiving the graphic language code, the server can call Figure 3d The cloud function shown creates a screenshot image according to the graphic language code and sets the image index of the screenshot image; then the image index is returned to the screenshot component so that the screenshot component can obtain the screenshot image according to the image index. Figure 3d As can be seen from the cloud function shown, when it is necessary to use the server to generate screenshot images, only a small amount of server-side code is required, which is easy to maintain and can reduce security issues.

[0089] The application page of the target application in the embodiment of the present invention is rendered based on the element information of multiple page elements; therefore, after detecting a screenshot instruction for the application page, the element information of some or all of the multiple page elements can be used to generate a graphic language code for the screenshot image, and the screenshot image can be created based on the graphic language code. Since the graphic language code can completely retain the element information of some or all of the page elements in the application page, the screenshot image created based on the graphic language code can be highly similar to the application page, effectively improving the screenshot effect.

[0090] In practical applications, the above-mentioned image generation method can be used in application scenarios such as user sharing and recommendation. Based on these application scenarios and the relevant description of the image generation method embodiment, the embodiment of the present invention also proposes a flowchart of an image processing method. The image processing method can be executed by the target application mentioned above, or by a terminal running the target application. For the sake of convenience, the embodiment of the present invention mainly takes the target application executing the image processing method as an example for explanation. Please refer to Figure 4 , the image processing method may include the following steps S401-S403:

[0091] S401, displaying an information resource selection interface of a target application in a target client.

[0092] In an embodiment of the present invention, the target application may refer to a sub-application that runs in the target client and does not need to be installed. The information resource selection interface may include but is not limited to: multiple information resources, selection buttons corresponding to each information resource, resource sharing buttons, and a list display entry for the information resource recommendation list. The information resources here may include but are not limited to: commodity information resources of each commodity in a commodity purchase application (such as the QQ Huigou applet), user information resources of each user in an instant messaging application, and so on. Taking the information resource as commodity information resource 11 as an example, the corresponding selection button may be Figure 5a The "+" button 12 in the information resource selection interface shown in the figure, the resource sharing button can be Figure 5a The "Photo Sharing" button 13 in the information resource selection interface shown in the figure can be a list display entry. Figure 5a “My Recommendations” 14 in the information resource selection interface shown.

[0093] After the information resource selection interface is displayed, the target user can select his / her favorite information resources from multiple information resources to add to the information resource recommendation list; specifically, the target user can perform a trigger operation (such as pressing operation, clicking operation, etc.) on the selection button corresponding to the information resource he / she likes to perform a selection operation on the information resource in the information resource selection interface. Accordingly, the target application can add the information resource corresponding to the triggered selection button to the information resource recommendation list, and display the number of information resources in the information resource recommendation list in real time at the list display entrance of the information resource recommendation list in the information resource selection interface, such as 15. Figure 5b If the target user wants to view the information resource recommendation list, he can click on the list display entry 14 to trigger the target application to output the information resource recommendation list 16, as shown. Figure 5c shown.

[0094] S402: Switching from the information resource selection interface to the information resource sharing interface of the target application according to a sharing operation on at least one information resource in the information resource selection interface.

[0095] In a specific implementation, after the target user has selected information resources, he can enter the information resource sharing interface by performing a trigger operation (such as a click operation, a press operation, etc.) on the resource sharing button in the information resource selection interface; accordingly, if the target application detects that the resource sharing button is triggered, it can be determined that a sharing operation for at least one information resource in the information resource selection interface is detected. In this case, the target application can switch from the information resource selection interface to the target application's information resource sharing interface, such as Figure 5d The information resource sharing interface belongs to the application page of the target application, and the information resource sharing interface includes at least one information resource and a screenshot trigger button; the at least one information resource and the screenshot trigger button are rendered according to the element information of multiple page elements. Among them, the screenshot trigger button may include a share screenshot button and a store screenshot button; the so-called share screenshot button may be Figure 5d The "Share to" button 17 in the information resource sharing interface shown in the figure, the screenshot storage button can be Figure 5d The "Save Image" button 18 in the information resource sharing interface shown. It should be understood that Figure 5d The schematic diagram is only an exemplary representation of the information resource sharing interface and does not limit it; for example, the number of screenshot trigger buttons may be only one, such as only including a “share to” button 17 or a “save picture” button 18 .

[0096] S403: If the screenshot trigger button is triggered, the screenshot image is displayed.

[0097] In a specific implementation, if the target user wants to share the content in the information resource sharing interface in the form of an image to other users or other social platforms (such as WeChat Moments, QQ Space, etc.), or store the content in the information resource sharing interface in the form of an image in the local album folder of the terminal, the screenshot trigger button in the information resource sharing interface can be triggered. Correspondingly, if the target application detects that the screenshot trigger button is triggered, it can call the internal screenshot component to use the following method: Figure 2 The image generation method shown generates a screenshot image, such as Figure 5e As shown; then, the screenshot image is displayed.

[0098] In one embodiment, if the user performs a trigger operation on the share screenshot button (i.e., the "Share to" button) in the information resource sharing interface, that is, the share screenshot button in the information resource sharing interface is triggered, the target application can output an image sharing prompt window 19 and display the screenshot image 20 in the image sharing prompt window. In a specific implementation, if the target client to which the target application belongs is a social client, the target client may store the user ID of at least one contact user related to the target user. Then, the target application may also display the user ID 21 of at least one contact user in the image sharing prompt window, such as Figure 5f It should be understood that the user identification here may not be limited to Figure 5f The user avatar shown may also include a user name, etc. In this case, the target user may perform an identifier selection operation on at least one contact user identifier; if the target application detects the identifier selection operation, it may notify the target client to send the screenshot image to the contact user indicated by the selected contact user identifier. In another specific implementation, if the target client to which the target application belongs is not a social client, the target client may not store the user identifier of the contact user related to the target user. Then, the target application may display a shortcut entry 22 of the social client in the image sharing prompt window, such as Figure 5g As shown. In this case, the target user can perform a trigger operation on the quick entrance to trigger the switch from the target application to the social client, and send the screenshot image to other contact users through the social client. It should be understood that in other embodiments, the target application can also display the platform entrance of other social platforms (such as WeChat Moments, QQ Space, etc.) in the image sharing prompt window. The display diagram of the platform entrance can be similar to the schematic diagram of the quick entrance of the social client, which will not be repeated here; the target user can perform a trigger operation on the platform entrance to directly publish the screenshot image on the social platform through the platform entrance.

[0099] In another embodiment, if the user performs a trigger operation on the Save Screenshot button (i.e., the "Save Picture" button) in the information resource sharing interface, that is, the Save Screenshot button in the information resource sharing interface is triggered, the target application can save the screenshot image to the album folder in the local space of the terminal; so that when it is subsequently detected that the target user opens the screenshot image through the album folder, the screenshot image is displayed on the terminal screen. Optionally, after saving the screenshot image to the album folder in the local space of the terminal, the target application can also output an image storage prompt that the screenshot image has been stored; such as Figure 5h The prompt message 23 shown in the figure: "The screenshot image has been saved to the album."

[0100] The application page of the target application in the embodiment of the present invention is rendered based on the element information of multiple page elements; therefore, after detecting a screenshot instruction for the application page, the element information of some or all of the multiple page elements can be used to generate a graphic language code for the screenshot image, and the screenshot image can be created based on the graphic language code. Since the graphic language code can completely retain the element information of some or all of the page elements in the application page, the screenshot image created based on the graphic language code can be highly similar to the application page, effectively improving the screenshot effect.

[0101] Based on the description of the above-mentioned image generation method embodiment, the embodiment of the present invention further discloses an image generation device, which may be a computer program (including program code) running in a terminal. The image generation device may execute Figure 1b and Figure 2 See the method shown in Figure 6 , the image generation device may run the following units:

[0102] The acquisition unit 601 is used to acquire element information of target page elements required for the screenshot image in response to a screenshot instruction for an application page of a target application; the application page is rendered according to element information of multiple page elements, and the target page elements are part of or all of the multiple page elements;

[0103] The processing unit 602 is used to generate a graphic language code of the screenshot image using the element information of the target page element;

[0104] The processing unit 602 is further configured to create the screenshot image according to the graphic language code.

[0105] In one embodiment, the element information of any page element includes the attribute information of any page element; or includes: the attribute information of any page element and the image resources of any page element; wherein the attribute information of any page element includes: the attribute values ​​of the element attributes and the attribute values ​​of the rendering attributes; the element attributes include at least one of the following: element size, element style, element type, element level, the number of sub-elements of any page element, and text information of any page element.

[0106] In another embodiment, the application page of the target application is rendered by running the page code of the application page, and the page code is generated after code optimization of the native code of the application page according to the attribute values ​​of the element attributes of each page element; wherein the page code includes the attribute values ​​of the rendering attributes of each page element and the custom attribute statements of each page element, and the custom attribute statement of any page element is used to record the attribute values ​​of the element attributes of any page element; if the custom attribute statement of any page element also includes an element class name, and the element class name is used to mark any page element that needs to be screenshotted, then any page element is the target page element.

[0107] In another embodiment, the element information of the target page element includes the attribute information of the target page element; accordingly, when the acquisition unit 601 is used to respond to a screenshot instruction for an application page of a target application and acquire the element information of the target page element required for the screenshot image, it can be specifically used to: respond to a screenshot instruction for an application page of a target application and call the application program interface of the target application to read the attribute information of the target page element from the page code.

[0108] In another embodiment, the element information of the target page element also includes the target image resource of the target page element, and the attribute information of the target page element includes the resource location of the target image resource; accordingly, when the acquisition unit 601 is used to respond to a screenshot instruction for an application page of a target application and acquire the element information of the target page element required for the screenshot image, it can also be used to: acquire the resource location of the target image resource from the attribute information of the target page element; and load the target image resource from the resource location.

[0109] In another embodiment, the application page is an information resource sharing interface, and the element information of the target page element also includes a target image resource of the target page element; accordingly, when the acquisition unit 601 is used to respond to a screenshot instruction for an application page of a target application and acquire the element information of the target page element required for the screenshot image, it can also be used to: acquire the target image resource from a cache space, wherein the target image resource is preloaded into the cache space by the target application before the screenshot instruction is detected; wherein the process of the target application preloading the target image resource into the cache space includes: displaying the information resource selection interface before displaying the information resource sharing interface; the information resource selection interface includes multiple information resources, each information resource corresponds to at least one image resource; and according to a selection operation for the multiple information resources, adding the image resource corresponding to the selected information resource as a target image resource to the cache space.

[0110] In another embodiment, when the processing unit 602 is used to generate the graphic language code of the screenshot image using the element information of the target page element, it can be specifically used to: obtain a code template for creating the screenshot image; add the element information of the target page element to the code template to obtain the graphic language code of the screenshot image.

[0111] In another embodiment, the number of the target page elements is multiple, and the element information of each target page element includes the attribute information of each target page element, and the attribute information of each target page element includes at least the attribute value of the element level; accordingly, when the processing unit 602 is used to add the element information of the target page element to the code template to obtain the graphic language code of the screenshot image, it can be specifically used to: obtain the element level attribute value of each target page element from the attribute information of each target page element; determine the parent-child relationship between the each target page element according to the element level attribute value of each target page element; add the element information of each target page element to the code template according to the parent-child relationship and the recursive order from the parent element to the child element to obtain the graphic language code of the screenshot image.

[0112] In another embodiment, when the processing unit 602 is used to add the element information of each target page element to the code template according to the parent-child relationship and the recursive order from the parent element to the child element to obtain the graphic language code of the screenshot image, it can be specifically used to: for any target page element to be added, if any target page element has a target parent element, obtain the attribute value of the first rendering attribute from the attribute information of the target parent element, the first rendering attribute including: the rendering attribute that affects the rendering effect of any target page element and is not inherited from the target parent element; the attribute value of the first rendering attribute and the element information of any target page element are associated and added to the code template to obtain the graphic language code of the screenshot image.

[0113] In another embodiment, when the processing unit 602 is used to associate the attribute value of the first rendering attribute and the element information of any target page element and add them to the code template to obtain the graphic language code of the screenshot image, it can be specifically used to: add the attribute value of the first rendering attribute to the attribute information included in the element information of any target page element to update the element information of any target page element; add the updated element information of any target page element to the code template to obtain the graphic language code of the screenshot image.

[0114] In another embodiment, before the processing unit 602 is used to associate the attribute value of the first rendering attribute with the element information of any target page element and add them to the code template to obtain the graphic language code of the screenshot image, it can also be used to: extract the attribute value of the first rendering attribute from the attribute information included in the element information of the target parent element, and add the attribute value of the first rendering attribute to an inline style sheet; establish a first mapping relationship between the inline style sheet and the target parent element, and add the inline style sheet, the extracted element information of the target parent element, and the first mapping relationship to the code template;

[0115] Correspondingly, when the processing unit 602 is used to associate the attribute value of the first rendering attribute and the element information of any target page element and add them to the code template to obtain the graphic language code of the screenshot image, it can be specifically used to: establish a second mapping relationship between the inline style sheet and any target page element, and add the second mapping relationship and the element information of any target page element to the code template to obtain the graphic language code of the screenshot image.

[0116] In another embodiment, when the processing unit 602 is used to add the element information of each target page element to the code template according to the parent-child relationship and the recursive order from the parent element to the child element to obtain the graphic language code of the screenshot image, it can also be used to: if the target parent element does not exist in any of the target page elements, detect whether there is an attribute value of a second rendering attribute in the attribute information included in the element information of the any of the target page elements, the second rendering attribute including: a rendering attribute that causes the rendering position of any of the target page elements to be disordered; if there is an attribute value of the second rendering attribute, remove the attribute value of the second rendering attribute from the attribute information included in the element information of the any of the target page elements to update the element information of the any of the target page elements; add the updated element information of the any of the target page elements to the code template to obtain the graphic language code of the screenshot image.

[0117] According to one embodiment of the present invention, Figure 1b and Figure 2 Each step involved in the method shown can be performed by Figure 6 The image generation device shown in the figure is executed by each unit. For example, Figure 1b The steps S101-S102 shown in FIG. 1 can be performed by Figure 6 The acquisition unit 601 shown in FIG. 1 is used to perform the steps S103-S104. Figure 6 The processing unit 602 is shown to execute. Figure 2 The step S201 shown in FIG. 1 can be performed by Figure 6 The acquisition unit 601 shown in FIG. 1 is executed, and steps S202-S203 can be performed by Figure 6 The processing unit 602 shown in FIG. 6 is used to execute the above-mentioned process.

[0118] According to another embodiment of the present invention, Figure 6 The various units in the image generating device shown can be separately or completely combined into one or several other units to form, or one (some) of the units can be further divided into multiple functionally smaller units to form, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present invention. The above-mentioned units are divided based on logical functions. In practical applications, the functions of one unit can also be implemented by multiple units, or the functions of multiple units can be implemented by one unit. In other embodiments of the present invention, other units can also be included based on the image generating device. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented by the collaboration of multiple units.

[0119] According to another embodiment of the present invention, the program can be executed by running a program on a general computing device such as a computer including a central processing unit (CPU), a random access memory medium (RAM), a read-only memory medium (ROM), and other processing elements and storage elements. Figure 1b and Figure 2 A computer program (including program code) for each step involved in the corresponding method shown in Figure 6 The image generation device shown in the figure can realize the image generation method of the embodiment of the present invention. The computer program can be recorded on a computer-readable recording medium, for example, and loaded into the above-mentioned computing device through the computer-readable recording medium and run therein.

[0120] The application page of the target application in the embodiment of the present invention is rendered based on the element information of multiple page elements; therefore, after detecting a screenshot instruction for the application page, the element information of some or all of the multiple page elements can be used to generate a graphic language code for the screenshot image, and the screenshot image can be created based on the graphic language code. Since the graphic language code can completely retain the element information of some or all of the page elements in the application page, the screenshot image created based on the graphic language code can be highly similar to the application page, effectively improving the screenshot effect.

[0121] Based on the description of the above-mentioned image processing method embodiment, the embodiment of the present invention further discloses an image processing device, which may be a computer program (including program code) running in a terminal. The image processing device may execute Figure 4 See the method shown in Figure 7 , the image processing device can run the following units:

[0122] The display unit 701 is used to display an information resource selection interface of a target application in a target client, wherein the target application refers to a sub-application that runs in the target client and does not need to be installed; the information resource selection interface includes a plurality of information resources;

[0123] A switching unit 702 is used to switch from the information resource selection interface to the information resource sharing interface of the target application according to a sharing operation on at least one information resource in the information resource selection interface; the information resource sharing interface belongs to an application page of the target application, the information resource sharing interface includes the at least one information resource and a screenshot trigger button, and the at least one information resource and the screenshot trigger button are rendered according to element information of multiple page elements;

[0124] The display unit 701 is further configured to display a screenshot image if the screenshot trigger button is triggered, wherein the screenshot image is generated using the above-mentioned image generation method.

[0125] According to one embodiment of the present invention, Figure 4 Each step involved in the method shown can be performed by Figure 7 The image processing device shown in FIG. 1 is executed by each unit in the image processing device shown in FIG. Figure 4 The steps S401 and S403 shown in FIG. 4 can be performed by Figure 7 The display unit 701 shown in FIG. 1 is used to perform the step S402. Figure 7 According to another embodiment of the present invention, Figure 7 The various units in the image processing device shown can be individually or completely combined into one or several other units to form, or one (some) of the units can be further divided into multiple functionally smaller units to form, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present invention. The above-mentioned units are divided based on logical functions. In practical applications, the function of one unit can also be implemented by multiple units, or the functions of multiple units can be implemented by one unit. In other embodiments of the present invention, other units can also be included based on the image processing device. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented by the collaboration of multiple units.

[0126] According to another embodiment of the present invention, the program can be executed by running a program on a general computing device such as a computer including a central processing unit (CPU), a random access memory medium (RAM), a read-only memory medium (ROM), and other processing elements and storage elements. Figure 4 A computer program (including program code) for each step involved in the corresponding method shown in Figure 7 The image processing apparatus shown in the figure can realize the image processing method of the embodiment of the present invention. The computer program can be recorded on a computer-readable recording medium, for example, and loaded into the above-mentioned computing device through the computer-readable recording medium and run therein.

[0127] The application page of the target application in the embodiment of the present invention is rendered based on the element information of multiple page elements; therefore, after detecting a screenshot instruction for the application page, the element information of some or all of the multiple page elements can be used to generate a graphic language code for the screenshot image, and the screenshot image can be created based on the graphic language code. Since the graphic language code can completely retain the element information of some or all of the page elements in the application page, the screenshot image created based on the graphic language code can be highly similar to the application page, effectively improving the screenshot effect.

[0128] Based on the description of the above method embodiment and device embodiment, the embodiment of the present invention further provides a terminal. Figure 8, the terminal at least includes a processor 801, an input device 802, an output device 803 and a computer storage medium 804. The processor 801, the input device 802, the output device 803 and the computer storage medium 804 in the terminal can be connected via a bus or other means. The computer storage medium 804 can be stored in the memory of the terminal, the computer storage medium 804 is used to store a computer program, the computer program includes program instructions, and the processor 801 is used to execute the program instructions stored in the computer storage medium 804. The processor 801 (or CPU (Central Processing Unit)) is the computing core and control core of the terminal, which is suitable for implementing one or more instructions, and is specifically suitable for loading and executing one or more instructions to implement the corresponding method flow or corresponding function.

[0129] In one embodiment, the processor 801 described in the embodiment of the present invention can be used to be controlled by the terminal to perform a series of image generation processing, including: in response to a screenshot instruction for an application page of a target application, obtaining element information of a target page element required for the screenshot image; the application page is rendered based on element information of multiple page elements, and the target page element is part of or all of the multiple page elements; using the element information of the target page element to generate a graphic language code for the screenshot image; creating the screenshot image according to the graphic language code, and so on.

[0130] In another embodiment, the processor 801 described in the embodiment of the present invention can be used to be controlled by the terminal to perform a series of image processing, including: displaying an information resource selection interface of a target application in a target client, wherein the target application refers to a sub-application that runs in the target client and does not need to be installed; the information resource selection interface includes multiple information resources; according to a sharing operation for at least one information resource in the information resource selection interface, switching from the information resource selection interface to the information resource sharing interface of the target application; the information resource sharing interface belongs to an application page of the target application, and the information resource sharing interface includes the at least one information resource and a screenshot trigger button, wherein the at least one information resource and the screenshot trigger button are rendered based on element information of multiple page elements; if the screenshot trigger button is triggered, a screenshot image is displayed, and the screenshot image is taken using Figure 2 The image generation method shown is generated, and so on.

[0131] The embodiment of the present invention also provides a computer storage medium (Memory), which is a memory device in the terminal for storing programs and data. It is understandable that the computer storage medium here can include both the built-in storage medium in the terminal and the extended storage medium supported by the terminal. The computer storage medium provides a storage space, which stores the operating system of the terminal. In addition, one or more instructions suitable for being loaded and executed by the processor 801 are also stored in the storage space, and these instructions can be one or more computer programs (including program codes). It should be noted that the computer storage medium here can be a high-speed RAM memory, or a non-volatile memory (non-volatile memory), such as at least one disk storage; optionally, it can also be at least one computer storage medium located away from the aforementioned processor.

[0132] In one embodiment, the computer storage medium may store one or more first instructions; and the processor 801 may load and execute the one or more first instructions stored in the computer storage medium to implement the corresponding steps in the above-mentioned image generation method embodiment; in a specific implementation, the one or more first instructions in the computer storage medium are loaded by the processor 801 and the following steps are executed:

[0133] In response to a screenshot instruction for an application page of a target application, element information of a target page element required for a screenshot image is acquired; the application page is rendered according to element information of a plurality of page elements, and the target page element is a part of or all of the plurality of page elements;

[0134] Generate a graphic language code of the screenshot image using the element information of the target page element;

[0135] The screenshot image is created according to the graphics language code.

[0136] In one embodiment, the element information of any page element includes the attribute information of any page element; or includes: the attribute information of any page element and the image resources of any page element; wherein the attribute information of any page element includes: the attribute values ​​of the element attributes and the attribute values ​​of the rendering attributes; the element attributes include at least one of the following: element size, element style, element type, element level, the number of sub-elements of any page element, and text information of any page element.

[0137] In another embodiment, the application page of the target application is rendered by running the page code of the application page, and the page code is generated after code optimization of the native code of the application page according to the attribute values ​​of the element attributes of each page element; wherein the page code includes the attribute values ​​of the rendering attributes of each page element and the custom attribute statements of each page element, and the custom attribute statement of any page element is used to record the attribute values ​​of the element attributes of any page element; if the custom attribute statement of any page element also includes an element class name, and the element class name is used to mark any page element that needs to be screenshotted, then any page element is the target page element.

[0138] In another embodiment, the element information of the target page element includes the attribute information of the target page element; accordingly, when responding to a screenshot instruction for an application page of a target application and obtaining the element information of the target page element required for the screenshot image, the one or more first instructions are loaded and specifically executed by the processor 801: in response to the screenshot instruction for the application page of the target application, the application program interface of the target application is called to read the attribute information of the target page element from the page code.

[0139] In another embodiment, the element information of the target page element also includes the target image resource of the target page element, and the attribute information of the target page element includes the resource location of the target image resource; accordingly, when responding to a screenshot instruction for an application page of a target application and obtaining the element information of the target page element required for the screenshot image, the one or more first instructions can also be loaded and specifically executed by the processor 801: obtaining the resource location of the target image resource from the attribute information of the target page element; and loading the target image resource from the resource location.

[0140] In another embodiment, the application page is an information resource sharing interface, and the element information of the target page element also includes a target image resource of the target page element; accordingly, in response to a screenshot instruction for an application page of a target application, when obtaining the element information of the target page element required for the screenshot image, the one or more first instructions can also be loaded and specifically executed by the processor 801: obtaining the target image resource from the cache space, the target image resource being preloaded into the cache space by the target application before the screenshot instruction is detected; wherein the process of the target application preloading the target image resource into the cache space includes: displaying the information resource selection interface before displaying the information resource sharing interface; the information resource selection interface includes multiple information resources, each information resource corresponding to at least one image resource; and according to the selection operation for the multiple information resources, adding the image resource corresponding to the selected information resource as the target image resource to the cache space.

[0141] In another embodiment, when the element information of the target page element is used to generate the graphic language code of the screenshot image, the one or more first instructions are loaded and specifically executed by the processor 801: obtaining a code template for creating the screenshot image; adding the element information of the target page element to the code template to obtain the graphic language code of the screenshot image.

[0142] In another embodiment, the number of the target page elements is multiple, and the element information of each target page element includes attribute information of each target page element, and the attribute information of each target page element includes at least attribute values ​​at the element level; accordingly, when the element information of the target page element is added to the code template to obtain the graphic language code of the screenshot image, the one or more first instructions are loaded and specifically executed by the processor 801: obtaining the element-level attribute values ​​of each target page element from the attribute information of each target page element; determining the parent-child relationship between each target page element according to the element-level attribute values ​​of each target page element; adding the element information of each target page element to the code template according to the parent-child relationship and the recursive order from the parent element to the child element to obtain the graphic language code of the screenshot image.

[0143] In another embodiment, when the element information of each target page element is added to the code template according to the parent-child relationship and the recursive order from the parent element to the child element to obtain the graphic language code of the screenshot image, the one or more first instructions can be loaded and specifically executed by the processor 801: for any target page element to be added, if any target page element has a target parent element, obtain the attribute value of the first rendering attribute from the attribute information of the target parent element, and the first rendering attribute includes: a rendering attribute that affects the rendering effect of any target page element and is not inherited from the target parent element; the attribute value of the first rendering attribute and the element information of any target page element are associated and added to the code template to obtain the graphic language code of the screenshot image.

[0144] In another embodiment, when the attribute value of the first rendering attribute and the element information of any target page element are associated and added to the code template to obtain the graphic language code of the screenshot image, the one or more first instructions are loaded and specifically executed by the processor 801: the attribute value of the first rendering attribute is added to the attribute information included in the element information of any target page element to update the element information of any target page element; the updated element information of any target page element is added to the code template to obtain the graphic language code of the screenshot image.

[0145] In another embodiment, before associating the attribute value of the first rendering attribute and the element information of any target page element and adding them to the code template to obtain the graphic language code of the screenshot image, the one or more first instructions may also be loaded and specifically executed by the processor 801: extracting the attribute value of the first rendering attribute from the attribute information included in the element information of the target parent element, and adding the attribute value of the first rendering attribute to an inline style sheet; establishing a first mapping relationship between the inline style sheet and the target parent element, and adding the inline style sheet, the extracted element information of the target parent element, and the first mapping relationship to the code template;

[0146] Correspondingly, when the attribute value of the first rendering attribute and the element information of any target page element are associated and added to the code template to obtain the graphic language code of the screenshot image, the one or more first instructions are loaded and specifically executed by the processor 801: a second mapping relationship between the inline style sheet and any target page element is established, and the second mapping relationship and the element information of any target page element are added to the code template to obtain the graphic language code of the screenshot image.

[0147] In another embodiment, when the element information of each target page element is added to the code template according to the parent-child relationship and the recursive order from the parent element to the child element to obtain the graphic language code of the screenshot image, the one or more first instructions can also be loaded and specifically executed by the processor 801: if the target parent element does not exist in any of the target page elements, then detect whether there is an attribute value of a second rendering attribute in the attribute information included in the element information of any of the target page elements, and the second rendering attribute includes: a rendering attribute that causes the rendering position of any of the target page elements to be disordered; if there is an attribute value of the second rendering attribute, then remove the attribute value of the second rendering attribute from the attribute information included in the element information of any of the target page elements to update the element information of any of the target page elements; add the updated element information of any of the target page elements to the code template to obtain the graphic language code of the screenshot image.

[0148] In another embodiment, the computer storage medium may store one or more second instructions; and the processor 801 may load and execute the one or more second instructions stored in the computer storage medium to implement the corresponding steps in the above-mentioned image processing method embodiment; in a specific implementation, the one or more second instructions in the computer storage medium are loaded by the processor 801 and execute the following steps:

[0149] Displaying an information resource selection interface of a target application in a target client, wherein the target application refers to a sub-application that runs in the target client and does not need to be installed; the information resource selection interface includes a plurality of information resources;

[0150] According to a sharing operation for at least one information resource in the information resource selection interface, switching from the information resource selection interface to the information resource sharing interface of the target application; the information resource sharing interface belongs to an application page of the target application, the information resource sharing interface includes the at least one information resource and a screenshot trigger button, and the at least one information resource and the screenshot trigger button are rendered according to element information of multiple page elements;

[0151] If the screenshot trigger button is triggered, a screenshot image is displayed. The screenshot image is Figure 2 The image generation method shown is generated.

[0152] The application page of the target application in the embodiment of the present invention is rendered based on the element information of multiple page elements; therefore, after detecting a screenshot instruction for the application page, the element information of some or all of the multiple page elements can be used to generate a graphic language code for the screenshot image, and the screenshot image can be created based on the graphic language code. Since the graphic language code can completely retain the element information of some or all of the page elements in the application page, the screenshot image created based on the graphic language code can be highly similar to the application page, effectively improving the screenshot effect.

[0153] The above disclosure is only the preferred embodiment of the present invention, which certainly cannot be used to limit the scope of the present invention. Therefore, equivalent changes made according to the claims of the present invention are still within the scope of the present invention.

Claims

1. An image generation method, characterized in that: include: In response to a screenshot instruction for an application page of a target application, acquiring element information of target page elements required for a screenshot image; The application page is rendered according to the element information of multiple page elements, and the target page elements are some or all of the page elements in the multiple page elements; There are multiple target page elements, and the element information of each target page element includes attribute information of each target page element, and the attribute information of each target page element includes at least an attribute value at the element level; Generate a graphic language code of the screenshot image using the element information of the target page element; The generation method includes: acquiring an element-level attribute value of each target page element from the attribute information of each target page element; determining the parent-child relationship between each target page element according to the element-level attribute value of each target page element; for any target page element to be added, if any target page element has a target parent element, acquiring an attribute value of a first rendering attribute from the attribute information of the target parent element, wherein the first rendering attribute includes: a rendering attribute that affects the rendering effect of any target page element and is not inherited from the target parent element; associating the attribute value of the first rendering attribute with the element information of any target page element and adding it to a code template used to create the screenshot image, so as to obtain a graphic language code of the screenshot image; The screenshot image is created according to the graphics language code.

2. The method according to claim 1, characterized in that The element information of any page element includes the attribute information of the any page element; or includes: the attribute information of the any page element and the image resource of the any page element; Among them, the attribute information of any page element includes: attribute values ​​of element attributes and attribute values ​​of rendering attributes; the element attributes include at least one of the following: element size, element style, element type, element level, the number of sub-elements of any page element, and text information of any page element.

3. The method according to claim 2, characterized in that The application page of the target application is rendered by running the page code of the application page, wherein the page code is generated by optimizing the native code of the application page according to the attribute values ​​of the element attributes of each page element; Among them, the page code includes the attribute values ​​of the rendering attributes of each page element and the custom attribute statements of each page element. The custom attribute statement of any page element is used to record the attribute values ​​of the element attributes of any page element. If the custom attribute statement of any page element also includes an element class name, and the element class name is used to mark any page element that needs to be screenshotted, then any page element is the target page element.

4. The method according to claim 3, characterized in that The element information of the target page element includes attribute information of the target page element; The step of obtaining element information of target page elements required for the screenshot image in response to a screenshot instruction for the application page of the target application includes: In response to a screenshot instruction for an application page of a target application, an application program interface of the target application is called to read attribute information of the target page element from the page code.

5. The method according to claim 4, characterized in that The element information of the target page element also includes the target image resource of the target page element, and the attribute information of the target page element includes the resource location of the target image resource; The step of obtaining element information of target page elements required for the screenshot image in response to a screenshot instruction for the application page of the target application includes: Acquire the resource location of the target image resource from the attribute information of the target page element; The target image resource is loaded from the resource location.

6. The method according to claim 4, characterized in that The application page is an information resource sharing interface, and the element information of the target page element also includes a target image resource of the target page element; The step of obtaining element information of target page elements required for the screenshot image in response to a screenshot instruction for the application page of the target application includes: Acquire the target image resource from the cache space, where the target image resource is preloaded into the cache space by the target application before the screenshot instruction is detected; Among them, the process of the target application preloading the target image resource into the cache space includes: displaying an information resource selection interface before displaying the information resource sharing interface; the information resource selection interface includes multiple information resources, each information resource corresponds to at least one image resource; according to the selection operation for the multiple information resources, the image resource corresponding to the selected information resource is added to the cache space as the target image resource.

7. The method according to claim 1, characterized in that The associating and adding the attribute value of the first rendering attribute and the element information of any target page element to the code template to obtain the graphic language code of the screenshot image includes: Adding the attribute value of the first rendering attribute to the attribute information included in the element information of any target page element to update the element information of any target page element; The updated element information of any target page element is added to the code template to obtain the graphic language code of the screenshot image.

8. The method according to claim 1, characterized in that Before associating and adding the attribute value of the first rendering attribute and the element information of any target page element to the code template to obtain the graphic language code of the screenshot image, the method further includes: Extracting an attribute value of a first rendering attribute from the attribute information included in the element information of the target parent element, and adding the attribute value of the first rendering attribute to an inline style sheet; Establishing a first mapping relationship between the inline style sheet and the target parent element, and adding the inline style sheet, the extracted element information of the target parent element, and the first mapping relationship to the code template; The associating and adding the attribute value of the first rendering attribute and the element information of any target page element to the code template to obtain the graphic language code of the screenshot image includes: A second mapping relationship between the inline style sheet and any target page element is established, and the second mapping relationship and element information of any target page element are added to the code template to obtain a graphic language code of the screenshot image.

9. The method according to claim 1, characterized in that The method further comprises: If any of the target page elements does not have the target parent element, detecting whether there is an attribute value of a second rendering attribute in the attribute information included in the element information of any of the target page elements, where the second rendering attribute includes: a rendering attribute that causes a rendering position of any of the target page elements to be disordered; If the attribute value of the second rendering attribute exists, the attribute value of the second rendering attribute is removed from the attribute information included in the element information of any target page element, so as to update the element information of any target page element; The updated element information of any target page element is added to the code template to obtain the graphic language code of the screenshot image.

10. An image processing method, characterized in that: include: Displaying the information resource selection interface of the target application in the target client; The information resource selection interface includes multiple information resources; According to a sharing operation on at least one information resource in the information resource selection interface, switching from the information resource selection interface to the information resource sharing interface of the target application; The information resource sharing interface belongs to the application page of the target application, and the information resource sharing interface includes the at least one information resource and a screenshot trigger button, and the at least one information resource and the screenshot trigger button are rendered according to the element information of multiple page elements; If the screenshot trigger button is triggered, a screenshot image is displayed, and the screenshot image is generated by using the image generation method according to any one of claims 1 to 9.

11. An image generating device, characterized in that: include: an acquisition unit, configured to acquire element information of target page elements required for the screenshot image in response to a screenshot instruction for an application page of a target application; The application page is rendered according to the element information of multiple page elements, and the target page elements are some or all of the page elements in the multiple page elements; There are multiple target page elements, and the element information of each target page element includes attribute information of each target page element, and the attribute information of each target page element includes at least an attribute value at the element level; A processing unit, configured to generate a graphic language code of the screenshot image using element information of the target page element; The generation method includes: acquiring an element-level attribute value of each target page element from the attribute information of each target page element; determining the parent-child relationship between each target page element according to the element-level attribute value of each target page element; for any target page element to be added, if any target page element has a target parent element, acquiring an attribute value of a first rendering attribute from the attribute information of the target parent element, wherein the first rendering attribute includes: a rendering attribute that affects the rendering effect of any target page element and is not inherited from the target parent element; associating the attribute value of the first rendering attribute with the element information of any target page element and adding it to a code template used to create the screenshot image, so as to obtain a graphic language code of the screenshot image; The processing unit is further configured to create the screenshot image according to the graphic language code.

12. A terminal comprising an input device and an output device, characterized in that: Also includes: a processor adapted to implement one or more instructions; as well as, A computer storage medium storing one or more first instructions, wherein the one or more first instructions are suitable for being loaded by the processor and executing the image generation method as described in any one of claims 1 to 9; or, the computer storage medium storing one or more second instructions, wherein the one or more second instructions are suitable for being loaded by the processor and executing the image processing method as described in claim 10.

13. An image processing device, characterized in that: include: A display unit, used to display an information resource selection interface of a target application in a target client, wherein the target application refers to a sub-application that runs in the target client and does not need to be installed; The information resource selection interface includes multiple information resources; A switching unit, configured to switch from the information resource selection interface to the information resource sharing interface of the target application according to a sharing operation on at least one information resource in the information resource selection interface; The information resource sharing interface belongs to the application page of the target application, and the information resource sharing interface includes the at least one information resource and a screenshot trigger button, and the at least one information resource and the screenshot trigger button are rendered according to the element information of multiple page elements; The display unit is further used to display a screenshot image if the screenshot trigger button is triggered, and the screenshot image is generated using the image generation method according to any one of claims 1 to 9.

14. A computer storage medium, characterized in that: The computer storage medium stores one or more first instructions, and the one or more first instructions are suitable for being loaded by a processor and executing the image generation method as described in any one of claims 1 to 9; or, the computer storage medium stores one or more second instructions, and the one or more second instructions are suitable for being loaded by the processor and executing the image processing method as described in claim 10.