A method, apparatus, device, and storage medium for generating an image.
By combining graphic elements and performing graphic transformation, the problem of low image generation efficiency in existing technologies is solved, achieving automated image generation and cross-platform adaptability, thus improving drawing efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-09
- Publication Date
- 2026-03-10
AI Technical Summary
Current technologies for generating images are inefficient, especially when using the Graphics2D tool in Java's native classes, which requires users to manually draw all elements each time, resulting in low drawing efficiency.
By combining graphic elements through electronic devices, a preliminary image is generated, and graphic transformation is performed according to configuration information. The drawing tools and EPD conversion service in the Java.awt package are used to automatically perform drawing and graphic transformation, replacing manual drawing by the user.
It improves drawing efficiency, enables automated image generation, adapts to different display needs, and supports cross-platform and generation of various basic graphics.
Smart Images

Figure CN115049755B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer application technology, and in particular to a method, apparatus, device, and storage medium for generating images. Background Technology
[0002] With increasing environmental awareness and the accelerated pace of information technology development, the concept of paperless office has gradually been applied to daily life. For example, companies and enterprises are using electronic signage instead of paper signage. The content of electronic signage is usually displayed in the form of images, which are generally generated by calling third-party drawing tools. However, these third-party drawing tools are usually not integrated with application services. Thus, application services face the need to integrate image generation functionality.
[0003] Currently, it's also possible to draw directly using the Graphics2D tool from Java's native classes within application services. However, because this drawing method is similar to a drawing board, all elements in the image need to be redrawn by the user each time, resulting in low drawing efficiency. Summary of the Invention
[0004] This disclosure provides an image generation method, apparatus, device, and storage medium to at least solve the problem of low efficiency in image generation in the prior art. The technical solution of this disclosure is as follows:
[0005] According to a first aspect of this disclosure, an image generation method is provided, applied to an electronic device. The image generation method includes: the electronic device responding to a drawing instruction to acquire graphic elements and configuration information; then, the electronic device combining the graphic elements to generate a preliminary image, and performing graphic transformation on the preliminary image according to the configuration information to obtain a target image. The graphic elements include the shape of the element and the attributes of the element.
[0006] In the above solution, the electronic device combines graphic elements to generate a preliminary image, and then transforms the preliminary image according to the configuration information to obtain the target image. It can automatically perform drawing and graphic transformation, replacing the image generation method of manual drawing by users and improving drawing efficiency.
[0007] Optionally, the above method for "obtaining graphic elements" includes: the electronic device obtaining basic elements and attribute information of the basic elements, and generating graphic elements based on the basic elements and attribute information. The basic elements include the shape of the elements, and the attribute information includes the attributes of the elements.
[0008] In the above scheme, the electronic device generates graphic elements based on basic elements and attribute information, so that images can be automatically generated based on the graphic elements in the future, thereby improving drawing efficiency.
[0009] Optionally, the above-mentioned method for "obtaining basic elements and attribute information of basic elements" includes: the electronic device obtains the template file of the image, parses the template file, and obtains the basic elements and attribute information of the basic elements.
[0010] In the above scheme, the electronic device parses the template file to obtain the basic elements and their attribute information, so as to generate graphic elements based on the basic elements and attribute information, and automatically generate images based on the graphic elements, which can improve drawing efficiency.
[0011] Optionally, the image generation method further includes: rendering the target object by an electronic device. The target object includes at least one of a graphic element and a target image.
[0012] In the above solution, the electronic device can render graphic elements before generating the image, thus decoupling business logic processing from automatic image generation. Furthermore, the electronic device can render the target image after image generation and graphic transformation, demonstrating strong scalability.
[0013] Optionally, the above method for "rendering the target object" includes: when the target object is a graphic element, the electronic device loads a first renderer to render the graphic element; when the target object is a target image, the electronic device calls a second renderer through a first interface to render the graphic elements in the target image.
[0014] In the above solution, the electronic device can load the corresponding renderer to render the target object according to the user's needs, which improves drawing efficiency and better meets the user's needs.
[0015] Optionally, the configuration information includes at least one of graphic transformation and electrophoretic display EPD conversion.
[0016] Optionally, if the configuration information includes graphic transformation, the above method of "performing graphic transformation on the preliminary image according to the configuration information to obtain the target image" includes: the electronic device uses the graphics processing tools in the Java.awt package to perform graphic transformation on the preliminary image to obtain the target image.
[0017] Optionally, if the configuration information includes EPD conversion, the above method of "performing graphic conversion on the preliminary image according to the configuration information to obtain the target image" includes: the electronic device calling the EPD conversion service through the target interface to perform graphic conversion on the preliminary image to obtain the target image.
[0018] In the above solution, the electronic device can perform graphic transformation or EPD conversion on the preliminary image to adapt to the image display requirements, and has good adaptability.
[0019] Optionally, the above method of "combining graphic elements to generate a preliminary image" includes: the electronic device combines graphic elements using drawing tools in the Java.awt package to generate a preliminary image.
[0020] In the above scheme, the electronic device uses drawing tools (such as Graphics2D) in the Java.awt package to generate images. Since the Graphics2D tool is a class in the native JDK, it has good cross-platform performance and can support the generation of various basic graphics, making it highly functional.
[0021] According to a second aspect of this disclosure, an image generation apparatus is provided, applied to an electronic device. The image generation apparatus includes an acquisition module, an execution module, and a conversion module. The acquisition module is used to acquire graphic elements and configuration information in response to drawing instructions; the execution module is used to combine the graphic elements to generate a preliminary image; the conversion module is used to perform graphic conversion on the preliminary image obtained by the execution module according to the configuration information acquired by the acquisition module, to obtain a target image. The graphic elements include the shape of the element and the attributes of the element.
[0022] Optionally, the acquisition module is specifically used to: acquire basic elements and their attribute information; the basic elements include the shape of the elements, and the attribute information includes the attributes of the elements; and generate graphic elements based on the basic elements and attribute information.
[0023] Optionally, the acquisition module is specifically used for: acquiring the template file of the image; parsing the template file to obtain the basic elements and their attribute information.
[0024] Optionally, the image generation apparatus further includes a rendering module. The rendering module is used to render the target object; the target object includes at least one of a graphic element and a target image.
[0025] Optionally, a rendering module is used to load a first renderer to render the graphic element when the target object is a graphic element; and to call a second renderer through a first interface to render the graphic elements in the target image when the target object is a target image.
[0026] Optionally, the configuration information includes at least one of graphic transformation and electrophoretic display EPD conversion.
[0027] Optionally, if the configuration information includes image transformation, the conversion module is specifically used to perform image transformation on the initial image using the image processing tools in the Java.awt package to obtain the target image.
[0028] Optionally, if the configuration information includes EPD conversion, the conversion module is specifically used to call the EPD conversion service through the target interface to perform graphic conversion on the preliminary image to obtain the target image.
[0029] Optionally, an execution module is used to combine graphic elements using drawing tools in the java.awt package to generate a preliminary image.
[0030] According to a third aspect of this disclosure, an electronic device is provided, comprising: a processor and a memory for storing processor-executable instructions; wherein the processor is configured to execute the instructions to implement the image generation method as described in the first aspect above.
[0031] According to a fourth aspect of this disclosure, a non-transient computer-readable storage medium is provided, on which instructions are stored, such that when the instructions in the non-transient computer-readable storage medium are executed by a processor of an electronic device, the electronic device is able to perform any of the optional image generation methods of the first aspect described above.
[0032] According to a fifth aspect of this disclosure, a computer program product is provided, comprising instructions that, when executed by a processor of an electronic device, implement any of the optional image generation methods described in the first aspect above.
[0033] For a detailed description of aspects three through five and their various implementations in this disclosure, please refer to the detailed description in aspect one and its various implementations; and for a detailed description of the beneficial effects of aspects two through five and their various implementations, please refer to the analysis of the beneficial effects in aspect one and its various implementations, which will not be repeated here.
[0034] According to a sixth aspect of this disclosure, a method for acquiring an image is provided, applied to an electronic device. The method includes: in response to a request to acquire a target image, the electronic device determines a target service, invokes the target service, and obtains the target image. The target service is configured to implement any of the optional image generation methods described in the first aspect.
[0035] In the above solution, when the electronic device receives a request to obtain the target image, it can obtain the target image by calling the target service, thus avoiding the problem that all elements in the image need to be drawn manually by the user during the drawing process, and improving the drawing efficiency.
[0036] Optionally, before determining the target service in response to a request to retrieve the target image, the retrieval method may further include: constructing the target service based on the image generation method using the Spring Boot framework. Here, the target service may be a service interface or a dependency file.
[0037] The above solution, using the Spring Boot framework, treats the target service as a service interface or a dependency file to achieve automatic image generation. This allows users to integrate the target service as a dependency file into other projects or run it independently as a service in different use cases, thus meeting the needs of application services integrating image generation functionality.
[0038] According to a seventh aspect of this disclosure, an image acquisition apparatus is provided, applied to an electronic device. The acquisition apparatus includes a determining module and a processing module. The determining module is configured to determine a target service in response to a request to acquire a target image; the target service is configured to implement any of the optional image generation methods in the first aspect; the processing module is configured to invoke the target service to obtain the target image.
[0039] Optionally, the processing module is also used to build the target service based on the image generation method using the Spring Boot framework. The target service can be either a service interface or a dependency file.
[0040] According to an eighth aspect of this disclosure, an electronic device is provided, comprising: a processor and a memory for storing processor-executable instructions; wherein the processor is configured to execute the instructions to implement an image acquisition method as described in any of the optional methods in the sixth aspect above.
[0041] According to a ninth aspect of this disclosure, a non-transient computer-readable storage medium is provided, on which instructions are stored, such that when the instructions in the non-transient computer-readable storage medium are executed by a processor of an electronic device, the electronic device is able to perform an image acquisition method as selected in any of the sixth aspects above.
[0042] According to a tenth aspect of this disclosure, a computer program product is provided, comprising instructions that, when executed by a processor of an electronic device, implement any of the optional image acquisition methods described in the sixth aspect above.
[0043] The detailed descriptions of aspects eight through ten and their various implementations in this disclosure can be found in the detailed descriptions of aspect six and its various implementations; furthermore, the beneficial effects of aspects seven through ten and their various implementations can be found in the beneficial effect analysis of aspect six and its various implementations, and will not be repeated here. These or other aspects of this disclosure will become clearer and more understandable in the following description. It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this disclosure. Attached Figure Description
[0044] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure, and are not intended to unduly limit this disclosure.
[0045] Figure 1 This is a schematic diagram of the structure of an electronic device according to an exemplary embodiment;
[0046] Figure 2 This is one of the flowcharts illustrating an image generation method according to an exemplary embodiment;
[0047] Figure 3 This is an image containing two graphic elements, as shown in an exemplary embodiment.
[0048] Figure 4 This is a second flowchart illustrating an image generation method according to an exemplary embodiment;
[0049] Figure 5 This is the third flowchart illustrating an image generation method according to an exemplary embodiment;
[0050] Figure 6 This is a flowchart illustrating a method for acquiring an image according to an exemplary embodiment;
[0051] Figure 7 This is a structural block diagram of an image generation apparatus according to an exemplary embodiment;
[0052] Figure 8 This is a structural block diagram of an image acquisition device according to an exemplary embodiment. Detailed Implementation
[0053] To enable those skilled in the art to better understand the technical solutions of this disclosure, the technical solutions in the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings.
[0054] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The data involved in this disclosure may be user-authorized or fully authorized by the parties. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.
[0055] It should also be understood that the term "comprising" indicates the presence of the described feature, whole, step, operation, element and / or component, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements and / or components.
[0056] Electronic signage typically displays content in the form of images, which are usually generated using third-party drawing tools such as Photoshop and ProcessOn. However, these third-party drawing tools often cannot be integrated with application services. Therefore, application services face the need to integrate image generation functionality.
[0057] Java-based third-party drawing tools (such as JViews and Edraw) can meet the communication needs between application services and drawing tools. However, these drawing tools are usually not open source or require payment, and they are generally quite independent, making them difficult to integrate with application services.
[0058] Alternatively, you can use the Graphics2D tool from Java's native classes to draw directly within the application service. However, because this drawing method is similar to a drawing board tool, all elements in the image need to be redrawn by the user each time, resulting in low drawing efficiency.
[0059] To address the aforementioned problems, this disclosure provides an image generation method applied to electronic devices. The electronic device combines graphic elements to generate a preliminary image and performs graphic transformation based on configuration information to obtain the target image. This method automates the drawing and graphic transformation processes, replacing the manual drawing method used by users and improving drawing efficiency.
[0060] Figure 1 This is an electronic device illustrated according to an exemplary embodiment. The electronic device may include a processor 102, which is configured to execute application code to implement the image generation method and image acquisition method of this disclosure.
[0061] Processor 102 may include one or more processing cores, such as a quad-core processor, an octa-core processor, etc. Processor 102 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a central processing unit (CPU), a controller, memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0062] like Figure 1 As shown, the electronic device may further include a memory 103. The memory 103 stores application code that executes the present disclosure and is controlled by the processor 102 for execution.
[0063] The memory 103 may be a read-only memory (ROM) or other type of static storage device capable of storing static information and instructions, random access memory (RAM) or other type of dynamic storage device capable of storing information and instructions, or electrically erasable programmable read-only memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but not limited thereto. The memory 103 may exist independently and be connected to the processor 102 via bus 104. The memory 103 may also be integrated with the processor 102.
[0064] like Figure 1As shown, the electronic device may also include a communication interface 101, wherein the communication interface 101, the processor 102, and the memory 103 may be coupled to each other, for example, through a bus 104. The communication interface 101 is used for information interaction with other devices, for example, supporting information interaction between the electronic device and other devices.
[0065] It should be pointed out that, Figure 1 The device structure shown does not constitute a limitation on the electronic device, except... Figure 1 In addition to the components shown, the electronic device may include more or fewer components than illustrated, or combine certain components, or have different component arrangements.
[0066] The image generation method and image acquisition method provided in the embodiments of this disclosure will now be described with reference to the accompanying drawings.
[0067] Figure 2 This is an exemplary embodiment illustrating an image generation method applied to an electronic device. For example... Figure 2 As shown, the method may include the following steps.
[0068] Step 21: The electronic device responds to the drawing instructions and acquires the graphic elements and configuration information.
[0069] Graphical elements include the shape of the element (also known as basic elements, such as triangles, squares, etc.) and the attributes of the element (also known as attribute information, such as position attributes, color attributes, font attributes, etc.).
[0070] Specifically, electronic devices can acquire graphic elements in two ways: either by directly acquiring different graphic elements, or by acquiring basic elements and their attribute information, and then generating graphic elements based on these basic elements and attribute information. The basic elements include the shape of the element, and the attribute information includes the element's properties.
[0071] For example, an image might have two basic elements: a square and a circle. Both the square and the circle have positional attributes. The square's positional attributes are: 10 units from the left, 50 units from the right, 10 units from the top, and 50 units from the bottom of the background image. The circle's positional attributes are also: 50 units from the left, 10 units from the right, 50 units from the top, and 10 units from the bottom of the background image. The square and its positional attributes together form a square element (graphical element), and the circle and its positional attributes together form a circle element (graphical element). Thus, an image containing these two graphic elements (square and circle elements) would look like this: Figure 3As shown, square element 31 is located in the upper left corner of background image 30, and circular element 32 is located in the lower right corner of background image 30. The length of one unit in the attribute information is preset based on the corresponding side length in the background image. For example, if the left side length of the background image is 100 centimeters (cm), and the left side length of a basic element is 5 units, then the left side length of that basic element is 5cm.
[0072] In the above scheme, the electronic device generates graphic elements based on basic elements and attribute information, so that images can be automatically generated based on the graphic elements in the future, thereby improving drawing efficiency.
[0073] The electronic device can obtain basic elements and their attribute information in two ways: either by directly acquiring the basic elements and their attribute information, or by acquiring an image template file, parsing the template file, and then obtaining the basic elements and their attribute information. The template file is pre-defined, for example, a system default template file, or a template file generated according to user requirements. The template file should be in a parsable format, such as Extensible Markup Language (XML) or JSON.
[0074] In the above scheme, the electronic device parses the template file to obtain the basic elements and their attribute information, so as to generate graphic elements based on the basic elements and attribute information, and automatically generate images based on the graphic elements, which can improve drawing efficiency.
[0075] Optionally, the configuration information includes at least one of graphic transformation and electrophoretic display (EPD) conversion. Graphic transformation and EPD conversion are used to instruct the electronic device to perform graphic transformation on the preliminary image generated based on graphic elements to adapt to image display requirements, offering good adaptability.
[0076] Optionally, the configuration information also includes the number of threads and file paths.
[0077] The thread count indicates the number of images the electronic device can generate simultaneously. Specifically, upon receiving multiple drawing commands, the electronic device, based on the thread count in the configuration information, activates multiple threads (corresponding to the thread count) through a thread pool to process these multiple drawing commands simultaneously, thereby enabling image generation in multiple threads. Therefore, this electronic device supports concurrent drawing, improving image generation efficiency.
[0078] The file path is used to indicate the image cache path, or the storage path of the target service, or the calling path of the target service, wherein the target service is used to implement the image generation method in this disclosure.
[0079] Step 22: The electronic device combines graphic elements to generate a preliminary image.
[0080] Specifically, graphical elements are combined using drawing tools in the java.awt package to generate a preliminary image. For example, the Graphics2D tool in the java.awt package.
[0081] For example, an electronic device can use the following code to call the Graphics2D tool to generate the background color of an image.
[0082] if(getBgColor()!=null){ / / If the background color property is not empty.
[0083] g2d.setBackground(getBgColor());}
[0084] / / Generate background color based on background color attributes.
[0085] In the above scheme, the electronic device uses drawing tools (such as Graphics2D) in the Java.awt package to generate images. Since the Graphics2D tool is a class in the native JDK, it has good cross-platform performance and can support the generation of various basic graphics, making it highly functional.
[0086] Step 23: The electronic device performs graphic conversion on the preliminary image based on the configuration information to obtain the target image.
[0087] Specifically, when the configuration information includes image transformation, the electronic device uses image processing tools in the java.awt package to perform image transformation on the initial image to obtain the target image. For example, the BufferedImage tool in the java.awt package.
[0088] For example, the following code can be used to rotate the initial image.
[0089] if (null != image.getRotate()) { / / If the rotation rule is not empty / /
[0090] bi=rotateImage(bi,image.getRotate());}
[0091] / / Rotate the initial image using the rotation rules.
[0092] In the above solution, the electronic device can perform graphic transformations on the initial image to adapt to the image display requirements, and has good adaptability.
[0093] When the configuration information includes EPD conversion, the electronic device calls the EPD conversion service through the target interface to perform graphic conversion on the preliminary image and obtain the target image.
[0094] Specifically, since different EPD devices use different data formats, different EPD conversions may be required depending on the device. To address this, electronic devices can define a target interface and call the corresponding EPD conversion service to perform image conversion on the initial image to obtain the target image.
[0095] For example, the target interface can be defined using the following code.
[0096] public interface EpdHandleService{
[0097] String getHandledBase64(String imageBase64);}.
[0098] / / Define the target interface.
[0099] In this way, electronic devices can call the target interface through the following code to achieve graphics conversion.
[0100] String result=epdHandleService.getHandledBase64(imageBase64Str).
[0101] / / Call the target interface.
[0102] In the above solution, the electronic device can perform EPD conversion on the initial image to meet the image display requirements, and has good adaptability.
[0103] Optionally, in this image generation method, the electronic device can also render the target object.
[0104] Specifically, the electronic device loads the renderer corresponding to the target object and renders the target object. The renderer is generated based on user requirements, and the target object includes graphic elements and target images.
[0105] For example, a user requirement might include changing the color of a cell based on the number it contains; for instance, a cell with a number less than 10 would be displayed in red, and one with a number greater than 10 would be displayed in green. In this case, a renderer corresponding to the user's requirement would be generated to fulfill that requirement.
[0106] In the above solution, the electronic device can load the corresponding renderer to render the target object according to the user's needs, which improves drawing efficiency and better meets the user's needs.
[0107] Optionally, if the target object is a graphic element, such as Figure 4 As shown, after step 21, the image generation method further includes step 24a.
[0108] Step 24a: The electronic device loads the first renderer corresponding to the graphic element and renders the graphic element.
[0109] The first renderer is generated based on user requirements.
[0110] In the above solution, the electronic device can render graphic elements before generating images, thus decoupling business logic processing from automatic image generation.
[0111] Optionally, if the target object is a target image, such as Figure 5 As shown, after step 23, the image generation method further includes step 24b.
[0112] Step 24b: The electronic device calls the second renderer through the first interface to render the graphic elements in the target image.
[0113] The second renderer is generated based on user requirements.
[0114] Specifically, after obtaining the target image, based on the user's needs, the second renderer can be called from the first interface by inheriting the Section class to render the graphic elements in the target image. For example, if the user's requirement is that different rows of a table need to be filled with different colors, then the first interface (defined as SectionRenderer) can be customized.
[0115] For example, the definition of the first interface can be implemented using the following code.
[0116] public interface SectionRenderer<T extendsSection> {
[0117] T renderPolicy(Tsection);}. / / Define the first interface.
[0118] Then, the electronic device calls the second renderer through the first interface to render the graphic elements in the target image.
[0119] In the above scheme, the electronic device can render the target image after generating the image and converting the graphics, and it has strong scalability.
[0120] Optionally, in this disclosure, graphic elements can also be customized by inheriting the Section class. For example, a base element can be defined in the template file as a triangle, with attributes for the length, color, and position of each side, and its base class can be the Section class. When the electronic device parses the customized graphic element in the template file, it can determine whether to generate the graphic element (triangle element) based on whether the triangle element inherits from the Section class in its declaration. This achieves automatic generation of custom graphic elements.
[0121] The technical solutions provided in this disclosure offer at least the following beneficial effects:
[0122] In the above solution, the electronic device combines graphic elements to generate a preliminary image, and then transforms the preliminary image according to the configuration information to obtain the target image. It can automatically perform drawing and graphic transformation, replacing the image generation method of manual drawing by users and improving drawing efficiency.
[0123] Figure 6 This is an exemplary embodiment illustrating a method for acquiring an image, which is applied to an electronic device. For example... Figure 6 As shown, the method may include the following steps.
[0124] Step 31: The electronic device responds to the request to acquire the target image and determines the target service.
[0125] The target service is used to achieve the above. Figure 2 , Figure 4 ,or Figure 5 The image generation method shown in any of the options.
[0126] Optionally, this disclosure can be based on the Spring Boot framework, constructing a target service according to the image generation method to encapsulate the image generation functionality. Here, the target service can be a service interface or a dependency file.
[0127] Specifically, based on the Spring Boot framework, a target service can be built according to the image generation method. A drawing interface can be provided in the Controller so that other application services can call the image generation method through the drawing interface, thereby achieving automatic image generation without a visual interface.
[0128] Alternatively, based on the Spring Boot framework, a target service can be built according to the image generation method, generating a JAR file. This JAR file can then be used as a dependency file to provide drawing support for other projects, thereby achieving the function of automatically generating images.
[0129] The above solution, using the Spring Boot framework, treats the target service as a service interface or a dependency file to achieve automatic image generation. This allows users to integrate the target service as a dependency file into other projects or run it independently as a service in different use cases, thus meeting the needs of application services integrating image generation functionality.
[0130] Step 32: The electronic device calls the target service to obtain the target image.
[0131] The technical solutions provided in this disclosure offer at least the following beneficial effects:
[0132] In the above solution, when the electronic device receives a request to obtain the target image, it can obtain the target image by calling the target service, thus avoiding the problem that all elements in the image need to be drawn manually by the user during the drawing process, and improving the drawing efficiency.
[0133] The above combination Figures 2-5 This disclosure details the image generation method provided by embodiments of the present disclosure. To achieve the above functions, the image generation apparatus includes hardware structures and / or software modules corresponding to each function, and these hardware structures and / or software modules can constitute an electronic device. Those skilled in the art will readily recognize that, based on the algorithm steps of the examples described in conjunction with the embodiments disclosed herein, this disclosure can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this disclosure.
[0134] This disclosure embodiment can divide an electronic device into functional modules based on the above-described image generation method example. For example, the electronic device may include an image generation device, which can be divided into functional modules corresponding to various functions, or two or more functions can be integrated into one processing module. The integrated module can be implemented in hardware or as a software functional module. It should be noted that the module division in this disclosure embodiment is illustrative and only represents one logical functional division; in actual implementation, there may be other division methods.
[0135] The following, combined with Figure 7 This disclosure provides a detailed description of the image generation apparatus provided in the embodiments. It should be understood that the descriptions of the apparatus embodiments correspond to the descriptions of the method embodiments; therefore, any content not described in detail here can be found in the above method embodiments, and for the sake of brevity, will not be repeated here.
[0136] Figure 7 This is a schematic diagram illustrating the structure of an image generation apparatus according to an exemplary embodiment, applied to an electronic device. See also... Figure 7 As shown, the image generation device includes: an acquisition module 71, an execution module 72, and a conversion module 73.
[0137] Module 71 is used to acquire graphic elements and configuration information in response to drawing instructions. The graphic elements include the shape and attributes of the elements. For example, refer to... Figure 2 As shown, the acquisition module 71 is used to execute step 21. The execution module 72 is used to combine the graphic elements acquired by the acquisition module 71 to generate a preliminary image. For example, refer to... Figure 2 As shown, execution module 72 is used to execute step 22. Conversion module 73 is used to perform image conversion on the preliminary image obtained by execution module 72 based on the configuration information obtained by acquisition module 71, to obtain the target image. For example, refer to... Figure 2 As shown, the conversion module 73 is used to perform step 23.
[0138] Optionally, module 71 is used to: obtain basic elements and attribute information of basic elements; basic elements include the shape of the elements, and attribute information includes the attributes of the elements; and generate graphic elements based on basic elements and attribute information.
[0139] Optionally, module 71 is used to: obtain the template file of the image; parse the template file to obtain the basic elements and their attribute information.
[0140] Optionally, the image generation apparatus further includes a rendering module 74. The rendering module 74 is used to render a target object; the target object includes at least one of a graphic element and a target image.
[0141] Optionally, rendering module 74 is specifically used to load a first renderer to render the graphic element when the target object is a graphic element; and to call a second renderer through a first interface to render the graphic elements in the target image when the target object is a target image. For example, refer to... Figure 4 and Figure 5 As shown, the rendering module 74 is specifically used to execute steps 24a and 24b.
[0142] Optionally, the configuration information includes at least one of graphic transformation and EPD conversion.
[0143] Optionally, if the configuration information includes graphic transformation, the conversion module 73 is specifically used to perform graphic transformation on the preliminary image using the graphics processing tools in the Java.awt package to obtain the target image.
[0144] Optionally, if the configuration information includes EPD conversion, the conversion module 73 is specifically used to call the EPD conversion service through the target interface to perform graphic conversion on the preliminary image to obtain the target image.
[0145] Optionally, execution module 72 is specifically used to combine the graphic elements using drawing tools in the Java.awt package to generate a preliminary image.
[0146] Regarding the image generation apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0147] The above combination Figure 6 This disclosure details a method for acquiring images according to embodiments of the present invention. To achieve the above-described functions, the image acquisition device includes hardware structures and / or software modules corresponding to each function, and these hardware structures and / or software modules can constitute an electronic device. Those skilled in the art will readily recognize that, based on the algorithm steps of the examples described in conjunction with the embodiments disclosed herein, this disclosure can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this disclosure.
[0148] This disclosure embodiment can divide the electronic device into functional modules based on the above-described image acquisition method example. For example, the electronic device may include an image acquisition device, which can be divided into functional modules corresponding to various functions, or two or more functions can be integrated into one processing module. The integrated module can be implemented in hardware or as a software functional module. It should be noted that the module division in this disclosure embodiment is illustrative and only represents one logical functional division; other division methods may be used in actual implementation.
[0149] The following, combined with Figure 8 This disclosure provides a detailed description of the image acquisition apparatus provided in the embodiments. It should be understood that the descriptions of the apparatus embodiments correspond to the descriptions of the method embodiments; therefore, any content not described in detail here can be found in the above method embodiments, and for the sake of brevity, will not be repeated here.
[0150] Figure 8 This is a schematic diagram illustrating the structure of an image acquisition device according to an exemplary embodiment, applied to an electronic device. See also... Figure 8 As shown, the image acquisition device includes: a determination module 81 and a processing module 82.
[0151] Module 81 is used to determine the target service in response to a request to acquire the target image; wherein the target service is used to implement, for example... Figure 2 , Figure 4 ,or Figure 5 Any of the image generation methods shown. For example, refer to... Figure 6 As shown, module 81 is used to execute step 31. Processing module 82 is used to call the target service to obtain the target image. For example, refer to... Figure 6 As shown, the processing module 82 is used to execute step 32.
[0152] Optionally, processing module 82 is also used to construct the target service based on the image generation method using the Spring Boot framework. The target service can be either a service interface or a dependency file.
[0153] Regarding the image acquisition device in the above embodiments, the specific methods by which each module performs its operations have been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0154] Another embodiment of this disclosure also provides a non-transitory computer-readable storage medium storing instructions. When the instructions in the non-transitory computer-readable storage medium are executed on an electronic device, the electronic device performs the above-described actions. Figure 2 , Figure 4 ,or Figure 5 The image generation method of the embodiment described above, or the electronic device performing the above-described method. Figure 6 The method for obtaining images in the embodiment of the present invention.
[0155] In another embodiment of this disclosure, a computer program product is also provided, comprising computer-executable instructions stored in a computer-readable storage medium. A processor of an electronic device can read the computer-executable instructions from the computer-readable storage medium and execute the computer-executable instructions to cause the electronic device to perform actions such as... Figure 2 , Figure 4 ,or Figure 5 The image generation method shown in the embodiment, or the electronic device performing the above-described method. Figure 6 The method for obtaining images in the embodiment of the present invention.
[0156] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0157] It should be understood that in the various embodiments of this disclosure, the sequence number of each process does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this disclosure.
[0158] In the several embodiments provided in this disclosure, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, multiple modules or components may be combined or integrated into another system, or some features may be omitted or not performed. Furthermore, the couplings or direct couplings or communication connections shown or discussed may be indirect couplings or communication connections through interfaces, devices, or modules, and may be electrical, mechanical, or other forms.
[0159] The modules described as separate components may or may not be physically separate. Similarly, the components shown as modules may or may not be physical modules; they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment, depending on actual needs.
[0160] In addition, the functional modules in the various embodiments of this disclosure can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module.
[0161] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this disclosure, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this disclosure. The aforementioned storage medium includes: USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, optical disks, and other media capable of storing program code.
[0162] The above description is merely a specific embodiment of this disclosure, but the scope of protection of this disclosure is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this disclosure should be included within the scope of protection of this disclosure. Therefore, the scope of protection of this disclosure should be determined by the scope of the appended claims.
Claims
1. An image generation method, applied to electronic devices, characterized in that, The picture generation method comprises: In response to a drawing instruction, a template file and configuration information of a picture are acquired, the configuration information comprising at least one of graphic transformation and electrophoretic display (EPD) conversion; the configuration information further comprises a thread number and a file path, the thread number being used to indicate the number of pictures generated by the electronic device at the same time; the file path being used to indicate a cache path of the picture, or a storage path of a target service, or a calling path of the target service; The template file is parsed to obtain a basic element and attribute information of the basic element; the basic element comprises a shape of an element, and the attribute information comprises an attribute of the element, the attribute of the element comprising a position attribute of the element; A graphic element is generated according to the basic element and the attribute information; the graphic element comprises a shape of an element and an attribute of the element; The graphic elements are combined to generate a preliminary picture; The preliminary picture is subjected to graphic conversion according to the configuration information to obtain a target picture, and in the case that the configuration information comprises EPD conversion, the preliminary picture is subjected to graphic conversion by calling an EPD conversion service through a target interface.
2. The picture generating method of claim 1, wherein, The picture generation method further comprises: A target object is rendered; the target object comprises at least one of the graphic element and the target picture.
3. The picture generating method of claim 2, wherein, The rendering of the target object comprises: In the case that the target object is the graphic element, a first renderer is loaded to render the graphic element; In the case that the target object is the target picture, a second renderer is called through a first interface to render the graphic element in the target picture.
4. The picture generating method of claim 1, wherein, In the case that the configuration information comprises graphic transformation, the graphic conversion of the preliminary picture according to the configuration information to obtain the target picture comprises: The graphic conversion of the preliminary picture is performed using a graphic processing tool in a Java.awt package to obtain the target picture.
5. The picture generating method of any of claims 1-4, wherein, The combination of the graphic elements to generate the preliminary picture comprises: The graphic elements are combined using a drawing tool in the Java.awt package to generate the preliminary picture.
6. An image acquisition method applied to an electronic device, comprising: The acquisition method comprises: In response to an acquisition request for a target picture, a target service is determined; the target service is used to implement the picture generation method in any one of claims 1-5; The target service is called to obtain the target picture.
7. The acquisition method of claim 6, wherein, Before determining the target service in response to the acquisition request for the target picture, the acquisition method further comprises: According to the picture generation method, the target service is constructed based on a springboot framework, wherein the target service is a service interface, or the target service is a dependent file.
8. An image generation apparatus applied to an electronic device, characterized in that, The picture generation apparatus comprises: An acquisition module is configured to acquire a template file and configuration information of a picture in response to a drawing instruction, the configuration information comprising at least one of graphic transformation and electrophoretic display (EPD) conversion; the configuration information further comprises a thread number and a file path, the thread number being used to indicate the number of pictures generated by the electronic device at the same time; the file path being used to indicate a cache path of the picture, or a storage path of a target service, or a calling path of the target service; The obtaining module is configured to parse the template file to obtain a basic element and attribute information of the basic element; the basic element comprises a shape of an element, and the attribute information comprises an attribute of the element, and the attribute of the element comprises a position attribute of the element; The obtaining module is further configured to generate a graphic element according to the basic element and the attribute information; the graphic element comprises a shape of an element and an attribute of the element; The execution module is further configured to combine the graphic elements obtained by the obtaining module to generate a preliminary picture. The conversion module is configured to perform graphic conversion on the preliminary picture obtained by the execution module according to the configuration information obtained by the obtaining module to obtain a target picture, and in a case where the configuration information comprises EPD conversion, perform graphic conversion on the preliminary picture by calling an EPD conversion service through a target interface.
9. An apparatus for acquiring a picture, applied to an electronic device, characterized in that, The obtaining device comprises: A determination module configured to determine a target service in response to an obtaining request for a target picture; the target service is used to implement the picture generation method of any one of claims 1-5. A processing module configured to call the target service to obtain the target picture.
10. An electronic device, comprising: The electronic device comprises: A processor; A memory configured to store instructions executable by the processor; The processor is configured to execute the instructions to implement the picture generation method of any one of claims 1-5, or implement the picture obtaining method of any one of claims 6-7.
11. A non-transitory computer-readable storage medium, comprising: The non-transitory computer-readable storage medium has instructions stored thereon, and when the instructions in the non-transitory computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the picture generation method of any one of claims 1-5, or implement the picture obtaining method of any one of claims 6-7.
12. A computer program product, characterised in that, The computer instructions comprise computer instructions, and when the computer instructions are executed by a processor of an electronic device, the picture generation method of any one of claims 1-5 is implemented, or the picture obtaining method of any one of claims 6-7 is implemented.
Citation Information
Patent Citations
Image processing method, related equipment and computer storage medium
CN110347463A
Image data processing method and device, computer equipment and storage medium
CN111223155A
Graph painting method, device and electronic equipment
CN111666318A
Image processing method and image processing system
CN112004115A
Generation of a modified UI element tree
US20170286371A1