Disclosure of Invention
The invention aims to provide a method and a device for generating an image by an application program view, so as to solve the problem that no unified view synthesis logic and interface exist in the application program.
The technical scheme adopted by the invention is that the method for generating the image by the application program view is applied to an image generation interface of a client, and the method comprises the following steps:
receiving the view and image synthesis parameters transmitted by an application program when calling the image generation interface aiming at the view to be synthesized;
when the view is judged to accord with the synthesis condition, judging whether manual editing is needed by a user, if so, synthesizing the view based on a first user instruction transmitted by an application program and the image synthesis parameter, otherwise, synthesizing the view according to the image synthesis parameter;
and returning the result of the synthesis processing to the application program.
Further, the image synthesis parameters include: rendering parameters, quality parameters, and number of views; the quality parameters include: resolution, definition, and storage size;
the number of the views is one or more;
the first user instruction comprises: setting instructions of view position, size and presentation form by a user.
Further, the method further comprises:
before judging whether the view meets the synthesis condition, judging whether the received image synthesis parameter exceeds a limited range, if so, prompting a user to modify the image synthesis parameter and judging whether the image synthesis parameter exceeds the limited range again, otherwise, judging whether the view meets the synthesis condition.
Further, the synthesizing the view according to the image synthesis parameter includes:
determining an applicable image synthesis model according to the number of views; the image synthesis model comprises the horizontal and vertical typesetting conditions of the view;
and under a CoreGraphic framework, synthesizing the view according to the image synthesis parameters and the determined image synthesis model.
Further, the determining whether the view meets the synthesis condition includes:
parsing a hierarchy of the view to determine a depth of the view;
and judging whether the depth of the view reaches a set depth threshold value, if so, judging that the view meets the synthesis condition, and otherwise, judging that the view does not meet the synthesis condition.
Further, the method further comprises:
and when the view does not accord with the synthesis condition, prompting a user and carrying out synthesis processing on the view according to a second user instruction and the image synthesis parameter transmitted by the application program.
The invention also provides a device for generating images by using the application program view, which is applied to an image generation interface of a client, and the device comprises:
the starting module is used for receiving the view and the image synthesis parameters transmitted when an application program calls the image generation interface aiming at the view to be synthesized;
the processing module is used for judging whether manual editing is needed by a user or not when the view is judged to accord with the synthesis condition, if so, synthesizing the view based on a first user instruction transmitted by an application program and the image synthesis parameter, and otherwise, synthesizing the view according to the image synthesis parameter;
and the return module is used for returning the result of the synthesis processing to the application program.
Further, the image synthesis parameters include: rendering parameters, quality parameters, and number of views; the quality parameters include: resolution, definition, and storage size;
the number of the views is one or more;
the first user instruction comprises: setting instructions of view position, size and presentation form by a user.
Further, the processing module is further configured to:
before judging whether the view meets the synthesis condition, judging whether the received image synthesis parameter exceeds a limited range, if so, prompting a user to modify the image synthesis parameter and judging whether the image synthesis parameter exceeds the limited range again, otherwise, judging whether the view meets the synthesis condition.
Further, under the condition that a user does not need to manually edit, the processing module is specifically configured to: determining an applicable image synthesis model according to the number of views; the image synthesis model comprises the horizontal and vertical typesetting conditions of the view;
and under a CoreGraphic framework, synthesizing the view according to the image synthesis parameters and the determined image synthesis model.
Further, the processing module is specifically configured to:
parsing a hierarchy of the view to determine a depth of the view;
and judging whether the depth of the view reaches a set depth threshold value, if so, judging that the view meets the synthesis condition, and otherwise, judging that the view does not meet the synthesis condition.
Further, the processing module is further configured to: and when the view does not accord with the synthesis condition, prompting a user to carry out synthesis processing on the view according to a second user instruction and the image synthesis parameters transmitted by the application program.
By adopting the technical scheme, the invention at least has the following advantages:
according to the method and the device for generating the image by the application program view, the synthesis function of the app is packaged, so that the method and the device are convenient for developers to use, and a more convenient image processing function is provided for users. According to the invention, through dynamic processing and reasonable parameter configuration, great flexibility and operability are provided for a user, an APP developer can self-define the synthesis effect of the view according to the own requirement, and the view which the user wants to process can be simply and conveniently generated into the image. Because the invention encapsulates the internal logic well, the user can call the interface conveniently only by inputting the corresponding image synthesis parameters, thereby reducing the complexity of use and having high program flexibility.
Detailed Description
To further explain the technical means and effects of the present invention adopted to achieve the intended purpose, the present invention will be described in detail with reference to the accompanying drawings and preferred embodiments.
A first embodiment of the present invention provides a method for generating an image by using an application view, which is applied to an image generation interface of a client, and as shown in fig. 1, the method includes the following specific steps:
step S101, receiving the view and image synthesis parameters transmitted when an application program calls the image generation interface for the view to be synthesized;
specifically, the image synthesis parameters include: rendering parameters, quality parameters, and number of views; the quality parameters include: resolution, definition, and storage size; the number of views to be synthesized is one or more.
Step S102, when the view is judged to accord with the synthesis condition, judging whether manual editing by a user is needed, if so, synthesizing the view based on a first user instruction transmitted by an application program and the image synthesis parameter, otherwise, synthesizing the view according to the image synthesis parameter;
specifically, the first user instruction includes: setting instructions of view position, size and presentation form by a user.
In step S102, determining whether the view meets the composition condition includes:
parsing a hierarchy of the view to determine a depth of the view;
and judging whether the depth of the view reaches a set depth threshold value, if so, judging that the view meets the synthesis condition, and otherwise, judging that the view does not meet the synthesis condition.
Further, in step S102, the synthesizing the view according to the image synthesis parameter includes:
determining an applicable image synthesis model according to the number of views; the image synthesis model comprises the horizontal and vertical typesetting conditions of the view;
and under a CoreGraphic framework, synthesizing the view according to the image synthesis parameters and the determined image synthesis model.
In step S103, the result of the composition processing is returned to the application.
A second embodiment of the present invention is a method for generating an image by using a view of an application, and the method of this embodiment is substantially the same as the method of the first embodiment, except that, as shown in fig. 2, before determining whether the view meets a synthesis condition in step S102, the method of this embodiment further includes the following specific steps:
and S102-A, judging whether the received image synthesis parameters exceed the limited range, if so, prompting a user to modify the image synthesis parameters and judging whether the image synthesis parameters exceed the limited range again, otherwise, executing the step S102.
A third embodiment of the present invention is a method for generating an image by using a program view, which is substantially the same as the first embodiment, except that, as shown in fig. 3, in the method of this embodiment, step S102 further includes:
and when the view does not accord with the synthesis condition, prompting the user and carrying out synthesis processing on the view according to a second user instruction and the image synthesis parameter transmitted by the application program.
Specifically, since there are views that do not meet the composition condition at this time, the second user instruction needs to indicate that the views that do not meet the composition condition do not participate in the composition, or that all the views participate in the composition.
A fourth embodiment of the present invention, which corresponds to the first embodiment, introduces an apparatus for generating an image by using a view of an application, which is applied to an image generation interface of a client, as shown in fig. 4, and the apparatus includes the following components:
1) a starting module 401, configured to receive the view and the image synthesis parameter that are transmitted when an application calls the image generation interface for a view to be synthesized;
specifically, the image synthesis parameters include: rendering parameters, quality parameters, and number of views; the quality parameters include: resolution, definition, and storage size;
the number of the views is one or more.
2) A processing module 402, configured to determine whether manual editing by a user is needed when it is determined that the view meets a synthesis condition, if so, perform synthesis processing on the view based on a first user instruction and the image synthesis parameter that are transmitted by an application program, otherwise perform synthesis processing on the view according to the image synthesis parameter;
specifically, the first user instruction includes: setting instructions of view position, size and presentation form by a user.
The processing module 402 is specifically configured to:
parsing a hierarchy of the view to determine a depth of the view;
and judging whether the depth of the view reaches a set depth threshold value, if so, judging that the view meets the synthesis condition, and otherwise, judging that the view does not meet the synthesis condition.
Further, the processing module 402 is specifically configured to, without requiring manual editing by a user: determining an applicable image synthesis model according to the number of views; the image synthesis model comprises the typesetting conditions of the transverse direction and the longitudinal direction of the view. And under a CoreGraphic framework, synthesizing the view according to the image synthesis parameters and the determined image synthesis model.
3) A returning module 403, configured to return the result of the composition processing to the application program.
A fifth embodiment of the present invention is an apparatus for generating an image by using a program view, which is substantially the same as the fourth embodiment, except that in the apparatus of the present embodiment, the processing module 402 is further configured to: before judging whether the view meets the synthesis condition, judging whether the received image synthesis parameter exceeds a limited range, if so, prompting a user to modify the image synthesis parameter and judging whether the image synthesis parameter exceeds the limited range again, otherwise, judging whether the view meets the synthesis condition.
A sixth embodiment of the present invention is an apparatus for generating an image by using a program view, which is substantially the same as the fourth embodiment, except that in the apparatus of the present embodiment, the processing module 402 is further configured to: and when the view does not accord with the synthesis condition, prompting a user to carry out synthesis processing on the view according to a second user instruction and the image synthesis parameters transmitted by the application program.
A seventh embodiment of the present invention, which is based on the above embodiments, is described with reference to fig. 5.
As shown in fig. 5, an image generation interface for generating an image in an application view according to an embodiment of the present invention is disposed on a client side, and the image generation interface includes: an image composition module (similar to the processing module in the fourth embodiment of the present invention) and an image management module (similar to the startup module and the return module in the fourth embodiment of the present invention). The external application program can achieve the purposes of view processing and image synthesis only by calling the image management module in the image generation interface.
The execution flow of the image generation interface of the embodiment of the invention is as follows:
step 1, when an external application calls an image generation interface, an image management module in the image generation interface transmits a view and an image synthesis parameter which need to be processed.
And 2, judging whether the view meets the synthesis condition, if so, executing the step 3, otherwise, prompting a user to execute the step 3 according to the instruction of the user for synthesis. At this time, the user may select a view meeting the synthesis condition for synthesis through an instruction, or may still select all incoming views for synthesis.
In particular, a hierarchy of the view is parsed to determine a depth of the view;
and judging whether the depth of the view reaches a set depth threshold value, if so, judging that the view meets the synthesis condition, and otherwise, judging that the view does not meet the synthesis condition.
The depth of the view can reflect whether the view is loaded completely, if the loading is completed, the depth of the view can reach the set depth threshold, otherwise, the depth of the view cannot reach the set depth threshold.
Step 3, judging whether the input image synthesis parameters (including rendering parameters, quality parameters and view number) accord with synthesis rules (the synthesis rules are the rules which are defined by developers and used by users, and the synthesis rules can be determined by setting the maximum numerical range of the input parameters), if so, calling synthesis logic, and synthesizing the views according to the image model under a CoreGraphics framework to generate the required images; if not, other composition logic is invoked, i.e., the associated view is composed according to the user's instructions.
For example, if the user wants to synthesize an image with three views, but the image loading of one view is not completed, and the view which is not loaded is found to be invalid when the view validity judgment is performed in step 2, the user is prompted by exception handling whether to continue, and if the user continues to select to synthesize an image with two views which are already loaded or to synthesize an image with three views which are not already loaded. And when view synthesis is carried out, judging whether the input image synthesis parameters meet the synthesis rules, if so, continuing synthesis to generate the image required by the user, and if not, prompting the user to modify the image synthesis parameters and judging whether the image synthesis parameters meet the synthesis rules again.
For another example: the user needs to carry out quality compression on the changed image, the corresponding image can be generated as long as the corresponding quality parameter and resolution parameter are transmitted, if the transmitted parameter exceeds the limit or range, the condition that the parameter does not conform to the logic rule is judged, the abnormity is reported, and the parameter error is reported to the user.
Through the flow, the external application can well process and obtain the required view image, the development workload existing in the development is solved, and the external application can be easily integrated into the application.
The embodiment of the invention utilizes a CoreGraphic framework, generates the required image from a simple or complex view through a series of image processing logics, and can be used for saving and using.
The embodiment of the invention realizes the function of generating the required image at the client and does not need a server to participate in processing.
The embodiment of the invention successfully provides the basic logic requirements of the integral synthesis of the view, can process the dynamic layout and the image generation of 1 to nine pictures with different numbers on the interface, and the user can dynamically edit the picture position and the size and the display form of the picture according to the requirements of the user. Most view synthesis requirements in app development can be met, a generation mechanism is perfected, and the use complexity is reduced.
The embodiment of the invention can reduce the storage size of the view by compressing the view on the premise of ensuring the resolution ratio of the view, and flexibly change the resolution ratio by inputting the parameter value of the resolution ratio.
The embodiment of the invention improves and encapsulates the functions, other applications can conveniently and simply transplant the technology into the application, the development cost is reduced, and the image synthesis and processing capability is improved.
While the invention has been described in connection with specific embodiments thereof, it is to be understood that it is intended by the appended drawings and description that the invention may be embodied in other specific forms without departing from the spirit or scope of the invention.