Disclosure of Invention
In view of the above, the main objective of the present invention is to provide a method and an apparatus for implementing dynamic interface switching of a mobile terminal, which can implement dynamic interface switching during interface switching, and make interface switching more flexible and better meet personalized requirements.
In order to achieve the purpose, the technical scheme of the invention is realized as follows:
the invention provides a method for realizing dynamic switching of a mobile terminal interface, which comprises the following steps:
when an interface is created, setting special effect parameters of the interface and setting the frame number of the special effect;
when the interface is switched, acquiring images before switching and images after switching, and generating an intermediate image of each frame according to the set special effect parameters and the frame number of the special effect;
and refreshing the intermediate image and the switched image to a screen.
In the above scheme, the special effect parameters of the setting interface are as follows: setting a first special effect field in the window attribute of the interface, and setting a special effect parameter in the first special effect field;
the first special effects field includes the following special effects parameters: the image conversion method, the image motion direction and the image conversion parameter motion trail, and the image motion direction and the image conversion parameter motion trail format of the image conversion method is adopted.
In the above scheme, the generating each frame of intermediate image according to the set special effect parameter and the frame number of the special effect is: and taking the image before switching as a first frame and the image after switching as a last frame, generating image transformation parameters of an intermediate frame image according to the special effect parameters of the first special effect field and the frame number of the special effect of the image after switching, and generating the intermediate image of each frame by utilizing the image transformation parameters and the image transformation mode.
In the above scheme, the refreshing the intermediate image and the switched image to the screen is: and refreshing the intermediate image and the switched image to a screen according to an asynchronous screen refreshing mode.
In the above scheme, the method further comprises: when the interface is destroyed, setting a second special effect field in the window attribute of the interface;
the second special effects field includes the following special effects parameters: and setting an image transformation mode, the motion direction of the image and the motion track of an image transformation parameter according to the special effect attribute set during interface creation to generate the special effect of interface destruction.
In the above scheme, the method further comprises: and setting a special effect region field in the window attribute of the interface, wherein the special effect region field is used for providing a window for setting a special effect operation region.
The invention provides a device for realizing dynamic switching of mobile terminal interfaces, which comprises: the system comprises a special effect setting module, a special effect processing module and a screen refreshing module; wherein,
the special effect setting module is used for setting special effect parameters of the interface and setting the frame number of the special effect when the interface is created;
the special effect processing module is used for acquiring images before switching and images after switching when the interface is switched, and generating an intermediate image of each frame according to the set special effect parameters and the frame number of the special effect;
and the screen refreshing module is used for refreshing the intermediate image and the switched image to a screen.
In the above scheme, the step of refreshing the intermediate image and the switched image to the screen by the screen refreshing module is as follows: and the screen refreshing module refreshes the switched image and the generated intermediate image to a screen according to an asynchronous screen refreshing mode.
In the above scheme, the special effect setting module is further configured to set a second special effect field in the window attribute of the interface when the interface is destroyed.
In the above scheme, the special effect setting module is further configured to set a special effect region field in a window attribute of the interface, and is configured to provide a window for setting a special effect operation region.
The method and the device for realizing the dynamic switching of the mobile terminal interface provided by the invention have the advantages that when the interface is established, the special effect parameters of the interface are set, and the frame number of the special effect is set; when the interface is switched, acquiring images before switching and images after switching, and generating an intermediate image of each frame according to the set special effect parameters and the frame number of the special effect; refreshing the intermediate image and the switched image to a screen according to an asynchronous screen refreshing mode; therefore, when the interface is switched, the visual effect of dynamic switching can be realized, the interface switching is more flexible, and the personalized requirements are better met; the sensory experience of the user can be effectively improved, the added value and the attraction of the product are increased, and the competitiveness of the product is improved. In addition, different visual effects can be generated by setting different image conversion modes, the moving directions of the images, the moving tracks of image conversion parameters and the frame number of special effects, and the switching method is flexible and various.
Detailed Description
The basic idea of the invention is: when an interface is created, setting special effect parameters of the interface and setting the frame number of the special effect; when the interface is switched, acquiring images before switching and images after switching, and generating an intermediate image of each frame according to the set special effect parameters and the frame number of the special effect; and refreshing the intermediate image and the switched image to a screen according to an asynchronous screen refreshing mode.
The invention is further described in detail below with reference to the figures and the specific embodiments.
The method for dynamically switching the interfaces of the mobile terminal comprises the following steps as shown in figure 1:
step 101: when an interface is created, setting special effect parameters of the interface and setting the frame number of the special effect;
specifically, when an interface is created, a first special effect field is set in a window attribute of the interface, and special effect parameters in the first special effect field are set; the first special effect field comprises the following special effect parameters: the image transformation mode, the image motion direction, the image transformation parameter motion track and the format of the image transformation mode image motion direction image transformation parameter motion track are adopted. Such as: the image flies in linearly from below the screen and the value of the first special effects field may be "WIPE _ UP _ line". The motion trail of the image transformation parameters is changed in a linear mode by default; in addition, a frame number field is also set in the window attribute of the interface, which is used for setting the frame number of the special effect, the frame number can be set to be a little less for the special effect with complex calculation, and the frame number can be set to be a little more for the special effect with simple calculation, generally 6 to 8 frames are preferable.
Here, the image conversion method includes: translation, scaling, 2D/3D rotation, image color gradient, superposition of several image transformation modes and the like, such as image scaling with color gradient and the like; the moving direction of the image can be eight directions of moving upwards, downwards, leftwards, rightwards, upwards leftwards, downwards leftwards, upwards rightwards, downwards rightwards and the like, and moving from the center to the periphery, moving from the periphery to the center and the like.
The motion trail of the image transformation parameters comprises: linear motion, uniform acceleration motion, uniform deceleration motion, Sin curve motion, rebound motion, and linear combination of several motion modes, and the like, and the image transformation parameters are parameters specified by the image transformation mode and parameters included in the motion direction of the image.
The conversion mode of the image, the motion direction of the image, the motion track of the image conversion parameter and the frame number of the special effect can be displayed on an interface in a menu form for a user to select according to the requirement.
Further, the method also comprises the following steps: when the interface is destroyed, a second special effect field is set in the window attribute of the interface, and the second special effect field comprises the following special effect parameters: the image transformation mode, the image motion direction and the image transformation parameter motion track are set according to the special effect attribute set during interface creation, so that the special effect of interface destruction is generated, for example: when the interface linearly flies in from the upper part of the screen to the lower part of the screen during creation, the interface can be linearly flown out from the lower part of the screen during destruction, and some special settings can be made according to needs.
Further, the method also comprises the following steps: setting a special effect area field in the window attribute of the interface, wherein the special effect area field is used for providing a window for setting a special effect operation area, the special effect area can be set as a certain sub-area of a screen in the window according to requirements, and the default setting is full screen.
Step 102: when the interface is switched, acquiring images before switching and images after switching, and generating an intermediate image according to special effect parameters and special effect frame numbers of the switched images;
specifically, when the interface is switched, the current screen image is acquired as a pre-switching image, the image to be refreshed on the screen is redirected to a specified cache as a switched image, the pre-switching image is used as a first frame, the switched image is used as a last frame, an image transformation parameter of an intermediate frame image is generated according to a special effect parameter of a first special effect field of the switched image and the frame number of a special effect, the intermediate frame image is generated by using the image transformation parameter and an image transformation mode, and the generated intermediate image is cached to a specified position.
Step 103: refreshing the intermediate image and the switched image to a screen in sequence according to an asynchronous screen refreshing mode;
specifically, an independent DSP chip is generally provided on an existing mobile terminal platform for screen rendering and refreshing, and a system bus supports copying of display contents from a Memory to a screen display Memory in a Direct Memory Access (DMA) manner. The whole process basically does not need the participation of a CPU, and the CPU is in an idle state for most of time. According to measurement, the time for refreshing the screen data once is about 20ms to 80ms, but the time for calculating the intermediate image of one frame is generally not more than 20ms, and the calculation time for many intermediate images is even less than 10 ms. In the process of refreshing the screen by the DSP, the CPU can also complete the calculation of the subsequent one to two frames of images, therefore, after generating one frame of intermediate image, the CPU can refresh the intermediate image to the screen and then generate the next frame of intermediate image, namely: and an asynchronous screen refreshing mode is adopted.
Compared with a synchronous screen refreshing method for refreshing a frame by calculating the idle time of the CPU, the asynchronous screen refreshing method has the advantages that the idle time of the CPU can be effectively utilized, the calculation time is reduced, and the utilization efficiency of the CPU is improved. Compared with the synchronous screen refreshing method, the asynchronous screen refreshing method can completely set one more intermediate image from one frame to two frames, and the transition is more natural. And because the calculated amount of each frame is different, the consumed time is more or less, the problem that the playing of the intermediate image is suddenly and suddenly slow can be caused by using the synchronous screen refreshing method, and the refreshing speed is completely controllable by using the asynchronous screen refreshing method. As for the synchronization problem between the special effect calculation and the screen refresh, a semaphore approach can be used.
In order to implement the above method, the present invention further provides a device for implementing dynamic interface switching of a mobile terminal, as shown in fig. 2, the device includes: the system comprises a special effect setting module 21, a special effect processing module 22 and a screen refreshing module 23; wherein,
the special effect setting module 21 is configured to set a special effect parameter of the interface and set a frame number of the special effect when the interface is created;
the special effect setting module 21 sets special effect parameters of the interface, specifically: the special effect setting module 21 sets a first special effect field in the window attribute of the interface, and sets a special effect parameter in the first special effect field; the first special effect field comprises the following special effect parameters: the image transformation mode, the image motion direction, the image transformation parameter motion track and the format of the image transformation mode image motion direction image transformation parameter motion track are adopted.
The special effect processing module 22 is configured to, when the interface is switched, acquire an image before switching and an image after switching, and generate an intermediate image of each frame according to a set special effect parameter and a frame number of a special effect;
a screen refreshing module 23, configured to refresh the intermediate image and the switched image to a screen;
specifically, the screen refreshing module 23 refreshes the switched image and the generated intermediate image to the screen according to an asynchronous screen refreshing mode;
the special effect setting module 21 is further configured to set a second special effect field in the window attribute of the interface when the interface is destroyed, where the second special effect field includes the following special effect parameters: setting the second special effect field according to the default special effect attribute set during interface creation so as to generate the special effect of interface destruction, wherein the second special effect field can also be flexibly set according to the requirement;
the special effect setting module 21 is further configured to set a special effect area field in a window attribute of the interface, to provide a window for setting a special effect operation area, and to set the special effect area as a certain sub-area of the screen on the window as required, and to set the special effect area as a full screen by default;
the apparatus further includes a plurality of buffer modules 24 for buffering the pre-switch image, the post-switch image, and the intermediate image of each frame acquired by the special effect processing module.
The following detailed description of the implementation and principles of the method of the present invention is provided in connection with specific embodiments.
The first embodiment is as follows: a method for implementing dynamic switching of an interface with color gradual changes and gradually increasing or decreasing, as shown in fig. 3, the method includes the following steps:
step 301: when a short message application interface is created, setting special effect parameters of the short message application interface and setting the frame number of the special effect;
specifically, when a short message application interface is created, a first special effect field is set in a window attribute of the short message application interface, and special effect parameters in the first special effect field are set; the first effect field includes the following effect parameters: the image transformation mode, the image motion direction, the image transformation parameter motion track and the format of the image transformation mode image motion direction image transformation parameter motion track; the image conversion mode is color gradual change, the motion direction of the image is gradually increased from the center of the screen to the periphery, the motion track of the image conversion parameter is LINEAR, namely the first special effect field is ZOOMWITHREADE _ OUT _ LINEAR; and a frame number field is also set in the window attribute of the short message application interface, and is used for setting the frame number of the special effect, and the frame number is set to be six frames.
Further, the method also comprises the following steps: setting a special effect area field in the window attribute of the short message application interface for providing a window for setting a special effect operation area, wherein the special effect operation area is set to be an area except an indication bar above a screen and a soft key bar below the screen.
Step 302: when the interface switching is triggered, acquiring images before switching and images after switching, and generating an intermediate image according to special effect parameters and special effect frame numbers of the images after switching;
specifically, in the process of clicking a short message icon from the nine-grid menu to enter a short message application, interface switching is triggered, and a main menu interface before switching is intercepted as an image before switching, as shown in (1) in fig. 2; redirecting the short message application interface to a specified cache as a switched image, as shown in (6) in fig. 2; taking an image before switching as a first frame, taking an image after switching as a last frame, and obtaining an image conversion mode of a special effect according to a special effect attribute 'ZOOMWITHREADE _ OUT _ LINEAR' of a first special effect field of a short message application interface, wherein the image conversion mode of the special effect is color gradual change, gradual increase from the center of a screen to the periphery and LINEAR change of parameters, ZOOMWITHREADE represents that the image conversion mode is gradual increase and color gradual change, OUT represents that the motion direction of the image is from the center of the screen to the periphery, LINEAR represents that the motion trajectory of image conversion parameters is LINEAR change, and the special effect has the following four changed image conversion parameters: the upper left point of the enlarged area moves from the center of the area to the upper left point of the special effect area, the width and the height of the image are increased from 0 to fill the whole special effect area, the transparency of the image is changed from 0 to 255, and the motion tracks of the four parameters are linearly changed. Generally, the first intermediate frame of the image is calculated: calculating values of four parameters of a first frame intermediate image of the required four frame intermediate images by using linear change of a motion track, generating the first frame intermediate image by using the values of the four parameters of the first frame intermediate image and an image conversion mode specified in a special effect field, storing the first frame intermediate image into a first block intermediate cache, and then executing step 303; in the process of executing step 303, the CPU continues to generate the next frame image and store it in the next intermediate buffer.
Step 303: and refreshing the intermediate image and the switched image to a screen in sequence according to an asynchronous screen refreshing mode.
The effect diagram of this embodiment is shown in fig. 4, where (2), (3), (4), and (5) are intermediate images of four frames sequentially refreshed to the screen, it can be seen that the short message application interface gradually enlarges from the center of the screen to the periphery, the color gradually deepens, and the covered squared menu gradually blurs.
Example two: when a password input interface is created, setting special effect parameters of the password input interface to be translated from the right side of a screen to the left, setting the frame number of a special effect to be six frames, and triggering interface switching in the process of switching from a short message application interface to the password input interface; after triggering the switching, acquiring images before switching and images after switching, as shown in (1) and (6) in fig. 5; then, an intermediate image is generated according to the special effect parameter and the frame number of the special effect of the switched image, as shown in (2), (3), (4), (5) in fig. 5; and refreshing the intermediate image and the switched image to a screen in sequence according to an asynchronous screen refreshing mode.
Example three: when a Sudoku menu interface is created, setting special effect parameters of the Sudoku menu interface as 3D (three-dimensional) rightward rotation, setting the frame number of a special effect as six frames, and triggering interface switching in the process of switching from a main interface to the Sudoku menu interface; after triggering the switching, acquiring images before switching and images after switching, as shown in (1) and (6) in fig. 6; then, an intermediate image is generated according to the special effect parameter and the frame number of the special effect of the switched image, as shown in (2), (3), (4), (5) in fig. 6; and refreshing the intermediate image and the switched image to a screen in sequence according to an asynchronous screen refreshing mode.
The above description is only exemplary of the present invention and should not be taken as limiting the scope of the present invention, and any modifications, equivalents, improvements, etc. that are within the spirit and principle of the present invention should be included in the present invention.