Frame animation processing method and apparatus, electronic device, and storage medium
By switching the display content of the dynamic view component from a static image to a sequence frame image of frame animation on the Android platform, and running the dynamic view component in a non-main thread, the problem of lag or flickering during frame animation playback is solved, and smooth image switching and improved user experience is achieved.
Patent Information
- Application Number
- PCT/CN2024/102007
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-08-30
- Filing Date
- 2024-06-27
- Publication Date
- 2025-03-06
AI Technical Summary
On the Android platform, when playing frame animation, there is a problem of lag or flickering when switching from a static image to a frame animation.
By setting the display content of the dynamic view component as the first frame image of a static image or a frame animation, and running the dynamic view component in a non-main thread, when receiving the trigger event of playing the frame animation, the display content is switched from the static image or the first frame image to the sequence frame image of a frame animation, and rendering and displaying frame by frame.
It realizes smooth switching from static images to frame animation, avoids the problem of lag or flickering during the switching process, reduces the burden on the main thread, improves the response speed and fluency, and improves the user experience.
Smart Images

Figure CN2024102007_06032025_PF_FP_ABST
Abstract
Description
Frame animation processing method, device, electronic device and storage medium
[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office on August 30, 2023, with application number 202311104807.5 and application name “A frame animation processing method, device, electronic device and storage medium”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of computer technology, and in particular to a frame animation processing method, device, electronic device and storage medium in the field of computer technology. Background Art
[0003] In Android app development, there are many scenarios where you initially display a static image and then, at some point, play a frame animation. Frame animation is a common animation effect that simulates an animation by displaying a series of images frame by frame. However, because frame animation requires parsing a large number of image resources during playback, this can cause lag or flickering when switching from a static image to a frame animation.
[0004] Summary of the Invention
[0005] The present application provides a frame animation processing method, device, electronic device and storage medium. The frame animation processing method can avoid the problem of freeze or flicker when a static image switches to a frame animation.
[0006] In a first aspect, the present application provides a frame animation processing method, the frame animation processing method comprising:
[0007] Set the display content of the dynamic view component to a static image; the dynamic view component runs in a non-main thread;
[0008] When a trigger event for playing a frame animation is received, the display content of the dynamic view component is switched from a static image to a sequence of frame images of the frame animation.
[0009] In one possible implementation, switching the display content of the dynamic view component from a static image to a sequence of frame images of a frame animation includes:
[0010] Traverse and parse the sequence frame images of frame animation through dynamic view components;
[0011] The display content of the dynamic view component is switched from a static image to a sequence of frame images of a frame animation; the sequence of frame images of the frame animation is rendered and displayed frame by frame on the dynamic view component.
[0012] In a second aspect, the present application provides a frame animation processing method, the frame animation processing method comprising:
[0013] Set the display content of the static view component to a static image;
[0014] Set the display content of the dynamic view component to the first frame image of the frame animation; the dynamic view component runs in a non-main thread;
[0015] When a trigger event for playing a frame animation is received, the display state of the static view component is switched from the visible state to the hidden state, and the display state of the dynamic view component is switched from the hidden state to the visible state;
[0016] Switch the display content of the dynamic view component from the first frame image of the frame animation to the remaining sequence frame images of the frame animation.
[0017] In one possible implementation, setting the display content of the dynamic view component to the first frame image of the frame animation includes:
[0018] Get the first frame image of the frame animation;
[0019] After the rendering unit in the dynamic view component is initialized, the display content of the dynamic view component is set to the first frame image of the frame animation, and the display state of the dynamic view component is set to the hidden state.
[0020] In one possible implementation, setting the display content of the dynamic view component to before the first frame image of the frame animation includes:
[0021] Create dynamic view components;
[0022] Set the display state of the dynamic view component to visible to create and initialize the rendering unit in the dynamic view component.
[0023] In a possible implementation, switching the display content of the dynamic view component from the first frame image of the frame animation to the remaining sequence frame images of the frame animation includes:
[0024] Traverse and parse the remaining sequence frame images of the frame animation through the dynamic view component;
[0025] The display content of the dynamic view component is switched from the first frame image of the frame animation to the remaining sequence frame images of the frame animation; the remaining sequence frame images of the frame animation are rendered and displayed frame by frame on the dynamic view component.
[0026] In a third aspect, the present application provides a frame animation processing device, the frame animation processing device comprising:
[0027] The first preset module is used to set the display content of the dynamic view component to a static image; the dynamic view component runs in a non-main thread;
[0028] The first switching module is configured to switch the display content of the dynamic view component from a static image to a sequence of frame images of the frame animation upon receiving a trigger event for playing the frame animation.
[0029] In a possible implementation, the first switching module is specifically configured to:
[0030] When receiving the trigger event of playing frame animation, the sequence frame images of the frame animation are traversed and parsed through the dynamic view component;
[0031] The display content of the dynamic view component is switched from a static image to a sequence of frame images of a frame animation; the sequence of frame images of the frame animation is rendered and displayed frame by frame on the dynamic view component.
[0032] In a fourth aspect, the present application provides a frame animation processing device, the frame animation processing device comprising:
[0033] A second preset module is used to set the display content of the static view component to a static image;
[0034] The third preset module is used to set the display content of the dynamic view component to the first frame image of the frame animation; the dynamic view component runs in a non-main thread;
[0035] The second switching module is used to switch the display state of the static view component from the visible state to the hidden state and the display state of the dynamic view component from the hidden state to the visible state when receiving the trigger event of playing the frame animation;
[0036] The third switching module is used to switch the display content of the dynamic view component from the first frame image of the frame animation to the remaining sequence frame images of the frame animation.
[0037] In one possible implementation, the third preset module is specifically configured to:
[0038] Get the first frame image of the frame animation;
[0039] After the rendering unit in the dynamic view component is initialized, the display content of the dynamic view component is set to the first frame image of the frame animation, and the display state of the dynamic view component is set to the hidden state.
[0040] In a possible implementation, the device further includes an initialization module, configured to:
[0041] Create dynamic view components;
[0042] Set the display state of the dynamic view component to visible to create and initialize the rendering unit in the dynamic view component.
[0043] In a possible implementation, the third switching module is specifically configured to:
[0044] Traverse and parse the remaining sequence frame images of the frame animation through the dynamic view component;
[0045] The display content of the dynamic view component is switched from the first frame image of the frame animation to the remaining sequence frame images of the frame animation; the remaining sequence frame images of the frame animation are rendered and displayed frame by frame on the dynamic view component.
[0046] In a fifth aspect, the present application provides an electronic device comprising a memory and a processor. The memory is configured to store executable program code, and the processor is configured to retrieve and execute the executable program code from the memory, so that the electronic device executes the method of the first aspect or any possible implementation of the first aspect, or the second aspect or any possible implementation of the second aspect.
[0047] In a sixth aspect, the present application provides a computer program product, which includes: computer program code, which, when the computer program code runs on a computer, enables the computer to execute the method in the above-mentioned first aspect or any possible implementation of the first aspect, or the second aspect or any possible implementation of the second aspect.
[0048] In the seventh aspect, the present application provides a computer-readable storage medium, which stores a computer program code. When the computer program code runs on a computer, the computer executes the method in the above-mentioned first aspect or any possible implementation of the first aspect, or the second aspect or any possible implementation of the second aspect.
[0049] In summary, in the embodiments of the present application, the display content of the dynamic view component is set to a static image or the first frame of a frame animation; the dynamic view component runs in a non-main thread; and upon receiving a trigger event to play a frame animation, the display content of the dynamic view component is switched from a static image to a sequence of frame images of the frame animation, or from the first frame of the frame animation to the remaining sequence of frame images of the frame animation. This method can smoothly achieve the switch from static image to frame animation, avoiding the problem of lag or flickering during the switching process. Moreover, running the dynamic view component in a non-main thread can reduce the burden on the main thread, improve the response speed and smoothness, avoid lag in the frame animation playback, and enhance the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] FIG1 is a schematic diagram showing a change in a view component provided by an embodiment of the present application, wherein the view component switches from a static image to a frame animation;
[0051] FIG2 is a schematic flow chart of a frame animation processing method provided in an embodiment of the present application;
[0052] FIG3 is a schematic flow chart of another frame animation processing method provided in an embodiment of the present application;
[0053] FIG4 is a schematic diagram showing another change in a view component provided by an embodiment of the present application, in which a static image is switched to a frame animation;
[0054] FIG5 is a schematic flow chart of another frame animation processing method provided in an embodiment of the present application;
[0055] FIG6 is a schematic diagram showing a process of creating a view component according to an embodiment of the present application;
[0056] FIG7 is a schematic diagram showing another switching process of a view component provided in an embodiment of the present application;
[0057] FIG8 is a schematic structural diagram of a frame animation processing device provided in an embodiment of the present application;
[0058] FIG9 is a schematic structural diagram of another frame animation processing device provided in an embodiment of the present application;
[0059] FIG10 is a schematic structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0060] An embodiment of the present application provides a frame animation processing method. The frame animation processing method can be implemented by a computer program and can be run on a frame animation processing device or system based on the von Neumann architecture. The computer program can be integrated into an application or run as a standalone tool application. The frame animation processing device can be an electronic device, including but not limited to: a personal computer, a tablet computer, a handheld device, an in-vehicle device, a wearable device, a computing device, or other processing device connected to a wireless modem.
[0061] When developing or using applications on the Android platform, there are many scenarios where a static image is displayed at the beginning, and then a frame animation needs to be played at a certain time. Since the frame animation needs to traverse and parse a large number of image resources during playback, if an ordinary View (the entity of the visual UI component in Android) is used to draw the frame animation on the main thread (UI thread), it may be stuck. Therefore, a non-main thread view component can be used to play the frame animation, such as using TextureView to play the frame animation. Among them, TextureView is a special view component in Android that is used for asynchronous rendering surfaces. It can render and draw frame animations in a non-main thread without occupying the main thread, thus avoiding the phenomenon of frame animation stuck.
[0062] As shown in Figure 1, in some embodiments, the static image 111 can be presented using a normal View (that is, the static view 110 in Figure 1), and the frame animation 121 can be played using TextureView (that is, the dynamic view 120 in Figure 1). When switching from the static image 111 to the frame animation 121, it can be achieved by hiding the static view 110 and displaying the dynamic view 120. After the dynamic view 120 is displayed, it still takes a certain amount of time for the dynamic view 120 to parse the frame animation image and other steps, and the display content cannot be drawn in time, resulting in the display content being empty. Therefore, after the static view 110 is hidden, the dynamic view 120 that is immediately displayed has no display content, and then the first frame image of the frame animation 121 is played, causing the user to visually see flickering.
[0063] To this end, an embodiment of the present application provides a frame animation processing method that can further avoid the problem of lag or flickering when a static image switches to a frame animation. For example, FIG2 is a schematic flow chart of a frame animation processing method provided by an embodiment of the present application, which can be executed by an electronic device. As shown in FIG2 , the method includes:
[0064] S201: Set the display content of the dynamic view component as the target image.
[0065] Specifically, the dynamic view component refers to the view component used to play frame animations in the embodiments of this application. It is a view component running on a non-main thread, such as TextureView in Android, which can be used to render and display complex graphical content, such as displaying images or playing frame animations. Because the dynamic view component runs on a non-main thread (UI thread), using it to play frame animations does not interfere with the operation of the main thread, which helps improve the smoothness of the application.
[0066] The target image may be a static image or the first frame image of a frame animation.
[0067] When the display content of a dynamic view component is set to a static image, the static image is displayed by the dynamic view component, that is, the static image and the frame animation are displayed using the same view component.
[0068] When the display content of the dynamic view component is set to the first frame image of the frame animation, the static image can be displayed by the static view component (other view component), that is, the static image and the frame animation are displayed using different view components.
[0069] It should be noted that in the embodiment of the present application, the display content of the dynamic view component needs to be set before playing the frame animation, so that the dynamic view component pre-loads and displays an image to avoid displaying a blank image when the frame animation needs to be played.
[0070] S202 : When a trigger event for playing a frame animation is received, the display content of the dynamic view component is switched from the target image to a sequence of frame images of the frame animation.
[0071] Specifically, upon receiving a trigger event for playing frame animation, the switch from the static image to the frame animation begins. The trigger event can be a signal or command, such as a user interaction (such as clicking a button), a program logic judgment, or a system notification. The trigger event is used to notify the system when to switch the static view to the frame animation, so that the dynamic view component can start playing the frame animation.
[0072] In the embodiments of the present application, the system receives a trigger event for playing a frame animation only after the user interface displays a static image. For example, in a vehicle condition monitoring or dashboard application, when the system detects that a part of the vehicle needs inspection or repair, it first displays a static image of that part. Once the static image appears, the user can click on it (triggering the event) to trigger the display of a more detailed frame animation explaining the specific situation.
[0073] When the target image displayed by the dynamic view component is a static image, the entire process of switching from the static image to the frame animation is carried out within the same view component (dynamic view component). There is no need to switch between two different view components. The switching transition will be very smooth, and the user will not feel any discontinuity or flickering when observing, which enhances the overall visual experience.
[0074] When the target image displayed by the dynamic view component is the first frame of a frame animation, the static image is displayed by the static view component. When switching from a static image to a frame animation, it is necessary to switch between different view components, that is, it is necessary to hide the static view component and display the dynamic view component. Since the dynamic view component pre-displays the first frame of the frame animation before the switching process is executed, even if the dynamic view component takes a long time to initialize or parse and render the frame animation, the dynamic view component will not display blank content. Therefore, when switching from a static view component to a dynamic view component, you can directly see the first frame of the frame animation, and then continue to play the sequence of frame images of the frame animation frame by frame. The user will not feel any discontinuity or flickering when observing, which enhances the overall visual experience.
[0075] The sequence of frame images of a frame animation is a series of frame images (static images) used to constitute the animation. These frame images are displayed one by one in a specific order and rate, thereby reflecting the animation effect.
[0076] In an embodiment of the present application, the display content of a dynamic view component is set to a target image; the dynamic view component runs in a non-main thread, and the target image is a static image or the first frame of a frame animation. Upon receiving a trigger event to play a frame animation, a switch is performed from the static image to the frame animation, switching the display content of the dynamic view component from the target image to a sequence of frame images of the frame animation, displayed frame by frame. This method enables smooth switching from a static image to a frame animation, avoiding issues such as lag or flickering during the switching process. Furthermore, running the dynamic view component in a non-main thread reduces the burden on the main thread, improving response speed and smoothness, avoiding lag in the frame animation playback, and enhancing the user experience.
[0077] For example, FIG3 is a schematic flow chart of another frame animation processing method provided by an embodiment of the present application, which can be executed by an electronic device. As shown in FIG3 , the method includes:
[0078] S301, setting the display content of the dynamic view component to a static image.
[0079] Specifically, the dynamic view component refers to the view component used to play frame animations in the embodiments of this application. It is a view component running on a non-main thread, such as TextureView in Android. In the embodiments of this application, when a static image is needed, the display content of the dynamic view component can be directly set to a static image. When a frame animation is needed, the display content is replaced, so that the static image and frame animation are displayed using the same view component.
[0080] It should be noted that in the embodiments of this application, the frame animation is played after the static image is displayed. Therefore, it is necessary to set the static image as the display content of the dynamic view component before playing the frame animation to meet the needs of displaying static images in the application scenario. Specifically, the dynamic view component can be created and the display content set when the user interface is first displayed. This user interface is used to display static images and frame animations.
[0081] S302 : When a trigger event for playing a frame animation is received, the display content of the dynamic view component is switched from a static image to a sequence of frame images of the frame animation.
[0082] Specifically, when the system receives a trigger event to play a frame animation, it begins switching from a static image to a frame animation. The dynamic view component traverses and parses the sequence of frame images of the frame animation, then switches the dynamic view component's display content from the static image to the sequence of frame images of the frame animation. The sequence of frame images of the frame animation can be rendered and displayed frame by frame on the dynamic view component.
[0083] For example, as shown in FIG4 , the display of a static image 411 and the playback of a frame animation 412 are presented through a TextureView (i.e., the dynamic view component 410 in FIG4 ). When a static image 411 needs to be displayed, a static image 411 is placed in the TextureView and set as the display content. When it is necessary to switch to the frame animation 412, the sequence frame images of the frame animation 412 are traversed and parsed, the first frame image of the frame animation 412 is rendered and replaced with the static image 411 in the TextureView for display, and then the sequence frame images of the frame animation 412 are rendered and displayed frame by frame, for example, the second frame image of the frame animation 412 is rendered and replaced with the first frame image in the TextureView for display, the third frame image of the frame animation 412 is rendered and replaced with the second frame image in the TextureView for display... This ensures that in the process of switching from a static image to a frame animation, there is always image content in the TextureView, so that in the process of replacing the display content in the TextureView, the flickering problem in the process of switching from a static image to a frame animation is avoided.
[0084] It should be noted that TextureView in Android uses SurfaceTexture to render and display content. SurfaceTexture can be regarded as a subcomponent (rendering unit) within the TextureView component. Specifically, SurfaceTexture is a surface containing a texture that can be used to render images generated by OpenGL ES and other hardware-accelerated APIs, while TextureView provides a way to display such content in a regular view hierarchy. In regular usage scenarios, content (such as video streams or 3D graphics) can be rendered to SurfaceTexture and then displayed in the application interface through the associated TextureView.
[0085] In an embodiment of the present application, the display content of a dynamic view component is set to a static image; the dynamic view component runs in a non-main thread; and upon receiving a trigger event to play a frame animation, a switch is performed from the static image to the frame animation, switching the display content of the dynamic view component from the static image to a sequence of frame images of the frame animation. This method uses the same dynamic view component to display both the static image and the frame animation, enabling smooth switching from the static image to the frame animation, avoiding issues such as lag or flickering during the switching process. Furthermore, running the dynamic view component in a non-main thread can reduce the burden on the main thread, improving response speed and smoothness while also enhancing the user experience.
[0086] For example, FIG5 is a schematic flow chart of another frame animation processing method provided by an embodiment of the present application, which can be executed by an electronic device. As shown in FIG5 , the method includes:
[0087] S501: Set the display content of the static view component to a static image.
[0088] Specifically, the static view component is used to display a fixed image content, and its display content can be set to a static image that needs to be displayed. The static view component can use a common view component, such as ImageView.
[0089] In the embodiment of the present application, the frame animation is played after the static image is displayed. Therefore, it is necessary to set the static image as the display content of the static view component before playing the frame animation to meet the needs of displaying static images in the application scenario. Specifically, the static view component can be created and the display content set when the user interface is first displayed. This user interface is used to display static images and frame animations.
[0090] S502: Set the display content of the dynamic view component to the first frame image of the frame animation.
[0091] Specifically, dynamic view components are used to play frame animations. They can be used to display a series of sequential frame images to create animation effects. By rendering frame by frame, dynamic view components can achieve rich visual effects. Dynamic view components can use view components running in non-main threads, such as TextureView.
[0092] In an embodiment of the present application, it is necessary to set the first frame image of the frame animation as the display content of the dynamic view component before the dynamic view component plays the frame animation. This allows the dynamic view component to pre-load the first frame image of the frame animation and avoid displaying a blank image when the frame animation needs to be played. Specifically, because the system can only receive the trigger event for playing the frame animation after the static image is displayed in the user interface, the display content of the static view component can be set to the first frame image of the frame animation at the same time as the display content of the static view component is set to the static image. This avoids the situation where the display content of the dynamic view component has not yet been set when the trigger event for playing the frame animation is received.
[0093] For example, after the application is started, it enters the user interface, creates a static view component in the user interface, and sets the specified static image as the display content of the static view component; at the same time, it creates a dynamic view component in the user interface, and sets the first frame image of the frame animation as the display content of the dynamic view component.
[0094] It should be noted that although the description distinguishes these two view components as "static" and "dynamic," this is a self-defined definition based on the functionality and usage of the embodiments of this application. In actual operations, many view components can have the ability to display static content and / or dynamic content, and the choice of which component to use may depend on specific needs. In the embodiments of this application, the naming of view components is only for the convenience of description and distinction, and does not constitute a specific limitation.
[0095] In some embodiments, setting the display content of the dynamic view component to the first frame image of the frame animation includes: obtaining the first frame image of the frame animation; after the rendering unit in the dynamic view component is initialized, setting the display content of the dynamic view component to the first frame image of the frame animation, and setting the display state of the dynamic view component to the hidden state.
[0096] Specifically, after a dynamic view component is created, its display content is blank. When the dynamic view component isn't playing a frame animation, an initial display image is set. This prevents flickering when switching from a static view component to the dynamic view component. This initial display image is set to the first frame of the frame animation. When the frame animation plays, this initial display image is replaced with the remaining frame images of the frame animation, preventing a sense of discontinuity or jumpiness.
[0097] If you want to pre-set the first frame image of the frame animation for display on the dynamic view component, you need to create and initialize the rendering unit in the dynamic view component. Because only after the rendering unit is initialized can the image be rendered to display the image on the dynamic view component.
[0098] In some embodiments, before setting the display content of the dynamic view component to the first frame image of the frame animation, it includes: creating a dynamic view component; setting the display state of the dynamic view component to a visible state to create and initialize a rendering unit in the dynamic view component.
[0099] Specifically, after a dynamic view component is created, the rendering unit in the dynamic view component is not necessarily created and initialized immediately. The creation and initialization process of the rendering unit is triggered only after the display state of the dynamic view component is set to visible.
[0100] For example, in Android, the visibility property of a View can be set using the setVisibility(int visibility) method, which can be represented by one of the following three constants:
[0101] View.VISIBLE: The view is visible.
[0102] View.INVISIBLE: The view is not visible (hidden), but still occupies space in the layout.
[0103] View.GONE: The view is not visible (hidden) and does not occupy space in the layout.
[0104] Taking TextureView as an example, the content of TextureView is rendered onto a SurfaceTexture (rendering unit). SurfaceTexture is created and initialized only when TextureView is visible (that is, the view's visibility property is View.VISIBLE). Therefore, even if the content of the dynamic view component does not need to be displayed, the dynamic view component should be set to a visible state.
[0105] It should be noted that when both the static view component and the dynamic view component are set to visible, since the dynamic view component (e.g., TextureView) initially displays no content (no image is rendered onto its SurfaceTexture), it may be completely transparent. Therefore, even in the "visible" state, it will not block or interfere with the display of the static view component. In addition, in some embodiments, the problem of interference between the display contents of the static view component and the dynamic view component can be avoided by controlling the hierarchical structure or transparency properties of the static view component and the dynamic view component through hierarchical management or transparency management.
[0106] Before receiving the trigger event for playing frame animation, the system needs to display a static image without playing the frame animation. When setting the display content of the dynamic view component to the first frame image of the frame animation, the display state of the dynamic view component needs to be set to a hidden state to avoid interfering with the static view component in displaying the static image.
[0107] For example, as shown in Figure 6, in the interface display, the static view component 610 is created and placed in the static image 611, and then set to a visible state. The dynamic view component 620 (TextureView) is created at the same time as the static view component 610, but the content of TextureView needs to be rendered to the SurfaceTexture (rendering unit). The initialization of SurfaceTexture is a time-consuming process. Only when TextureView is visible will SurfaceTexture be created and initialized. After the SurfaceTexture is initialized, the Android system will notify the developer that SurfaceTexture is ready through the onSurfaceTextureAvailable callback. Therefore, although the dynamic view component 620 may not need to be displayed at the beginning, in order to ensure the smooth playback of the frame animation, it is still necessary to set TextureView to visible, wait for the system to feedback the onSurfaceTextureAvailable notification, and then set the first frame image 621 of the frame animation to TextureView, and then hide TextureView after setting the first frame image 621 of the frame animation.
[0108] S503: When a trigger event for playing a frame animation is received, the display state of the static view component is switched from the visible state to the hidden state, and the display state of the dynamic view component is switched from the hidden state to the visible state.
[0109] Specifically, as shown in FIG7 , when the system receives a trigger event for playing a frame animation, it indicates that the interface needs to switch from displaying a static image 711 to displaying a frame animation 721. Therefore, the display state of the static view component 710 can be switched from visible to hidden, and the display state of the dynamic view component 720 can be switched from hidden to visible, thereby switching from displaying the static view component 710 to displaying the dynamic view component 720. Since the dynamic view component 720 has been pre-loaded with the first frame image of the frame animation 721 after creation, its displayed content is not blank, and the user will not observe flickering during the view component switching process.
[0110] S504: Switch the display content of the dynamic view component from the first frame image of the frame animation to the remaining sequence frame images of the frame animation.
[0111] Specifically, upon receiving a trigger event to play a frame animation, the dynamic view component switches from a hidden state to a visible state, and the dynamic view component begins traversing and parsing the remaining sequence of frame images in the frame animation; the dynamic view component switches its display content from the first frame image of the frame animation to the remaining sequence of frame images in the frame animation. The remaining sequence of frame images in the frame animation refers to all sequence frame images except the first frame image of the frame animation, and can be rendered and displayed frame by frame on the dynamic view component.
[0112] When the system receives a trigger event to play a frame animation and the dynamic view component's display state switches to visible, indicating that the frame animation needs to be played, the dynamic view component first traverses and parses the sequence of frame images of the frame animation. In other words, it reads each frame of the frame animation and performs the necessary analysis. The analysis process may involve format conversion, scaling, or other preprocessing steps to ensure that each frame is displayed correctly.
[0113] Because the dynamic view component has already set the first frame of the frame animation as the initial display content, it can only parse the remaining frame images except the first frame, and then render the remaining frame images of the frame animation frame by frame, and display the remaining frames in sequence at a specific rate (for example, 30 frames per second). The rendering process may involve processing steps to convert each frame image from its original format to a format that can be directly displayed on the screen. The rendering can be performed one frame at a time, and the display can be replaced in sequence until the frame animation is completed.
[0114] In an embodiment of the present application, the display content of the static view component is set to a static image; the display content of the dynamic view component is set to the first frame image of the frame animation; the dynamic view component runs in a non-main thread; when a trigger event for playing the frame animation is received, the display state of the static view component is switched from a visible state to a hidden state, and the display state of the dynamic view component is switched from a hidden state to a visible state; and the display content of the dynamic view component is switched from the first frame image of the frame animation to the remaining sequence frame images of the frame animation. In this method, since the dynamic view component pre-loads the first frame image of the frame animation before switching, no blank content will appear during the switch from the static view to the dynamic view component display, and a smooth transition can be made from displaying the first frame image of the frame animation to displaying the remaining sequence frame images. This switching is continuous and seamless, avoiding the problem of freezes or flickers during the switching process. Moreover, the dynamic view component running in a non-main thread can reduce the burden on the main thread, improve the response speed and smoothness, and improve the user experience.
[0115] FIG8 is a schematic structural diagram of a frame animation processing device provided in an embodiment of the present application.
[0116] Exemplarily, as shown in FIG8 , the frame animation processing device 800 includes:
[0117] The first preset module 810 is used to set the display content of the dynamic view component to a static image; the dynamic view component runs in a non-main thread;
[0118] The first switching module 820 is configured to switch the display content of the dynamic view component from a static image to a sequence of frame images of the frame animation upon receiving a trigger event for playing the frame animation.
[0119] In a possible implementation, the first switching module 820 is specifically configured to:
[0120] Traverse and parse the sequence frame images of frame animation through dynamic view components;
[0121] The display content of the dynamic view component is switched from a static image to a sequence of frame images of a frame animation; the sequence of frame images of the frame animation is rendered and displayed frame by frame on the dynamic view component.
[0122] In an embodiment of the present application, the display content of a dynamic view component is set to a static image; the dynamic view component runs in a non-main thread; and upon receiving a trigger event to play a frame animation, a switch is performed from the static image to the frame animation, switching the display content of the dynamic view component from the static image to the sequential frame images of the frame animation. This method uses the same dynamic view component to display both the static image and the frame animation, enabling a smooth switch from the static image to the frame animation, avoiding issues such as lag or flickering during the switching process. Furthermore, running the dynamic view component in a non-main thread can reduce the burden on the main thread, improve response speed and smoothness, and enhance the user experience.
[0123] FIG9 is a schematic structural diagram of another frame animation processing device provided in an embodiment of the present application.
[0124] Exemplarily, as shown in FIG9 , the frame animation processing device 900 includes:
[0125] A second preset module 910 is configured to set the display content of the static view component to a static image;
[0126] The third preset module 920 is used to set the display content of the dynamic view component to the first frame image of the frame animation; the dynamic view component runs in a non-main thread;
[0127] The second switching module 930 is configured to switch the display state of the static view component from the visible state to the hidden state and the display state of the dynamic view component from the hidden state to the visible state upon receiving a trigger event for playing a frame animation;
[0128] The third switching module 940 is configured to switch the display content of the dynamic view component from the first frame image of the frame animation to the remaining sequence frame images of the frame animation.
[0129] In a possible implementation, the third preset module 920 is specifically configured to:
[0130] Get the first frame image of the frame animation;
[0131] After the rendering unit in the dynamic view component is initialized, the display content of the dynamic view component is set to the first frame image of the frame animation;
[0132] Sets the display state of a dynamic view component to the hidden state.
[0133] In a possible implementation, the frame animation processing device 900 further includes an initialization module configured to:
[0134] Create dynamic view components;
[0135] Set the display state of the dynamic view component to visible to create and initialize the rendering unit in the dynamic view component.
[0136] In a possible implementation, the third switching module 940 is specifically configured to:
[0137] Traverse and parse the remaining sequence frame images of the frame animation through the dynamic view component;
[0138] The display content of the dynamic view component is switched from the first frame image of the frame animation to the remaining sequence frame images of the frame animation; the remaining sequence frame images of the frame animation are rendered and displayed frame by frame on the dynamic view component.
[0139] In an embodiment of the present application, the display content of the static view component is set to a static image; the display content of the dynamic view component is set to the first frame image of the frame animation; the dynamic view component runs in a non-main thread; when a trigger event for playing the frame animation is received, the display state of the static view component is switched from a visible state to a hidden state, and the display state of the dynamic view component is switched from a hidden state to a visible state; and the display content of the dynamic view component is switched from the first frame image of the frame animation to the remaining sequence frame images of the frame animation. In this method, since the dynamic view component pre-loads the first frame image of the frame animation before switching, no blank content will appear during the switch from the static view to the dynamic view component display, and a smooth transition can be made from displaying the first frame image of the frame animation to displaying the remaining sequence frame images. This switching is continuous and seamless, avoiding the problem of freezes or flickers during the switching process. Moreover, the dynamic view component running in a non-main thread can reduce the burden on the main thread, improve the response speed and smoothness, and enhance the user experience.
[0140] FIG10 is a schematic structural diagram of an electronic device provided in an embodiment of the present application.
[0141] Exemplarily, as shown in FIG10 , the electronic device 1000 includes: a memory 1010 and a processor 1020 , wherein the memory 1010 stores an executable program code 1011 , and the processor 1020 is configured to call and execute the executable program code 1011 to perform a frame animation processing method.
[0142] In the embodiments of the present application, the functional modules of the electronic device can be divided according to the above-mentioned method examples. For example, each functional module can be corresponded to, or two or more functions can be integrated into a processing module. The above-mentioned integrated module can be implemented in the form of hardware. It should be noted that the division of modules in the embodiments of the present application is schematic and is only a logical functional division. In actual implementation, other division methods may be used.
[0143] In the case of dividing each functional module into corresponding functional modules, the electronic device may include: a preset module and a first switching module, etc. It should be noted that all relevant contents of each step involved in the above method embodiment can be referred to the functional description of the corresponding functional module and will not be repeated here.
[0144] The electronic device provided in an embodiment of the present application is used to execute the above-mentioned frame animation processing method, and thus can achieve the same effect as the above-mentioned implementation method.
[0145] In the case of an integrated unit, the electronic device may include a processing module and a storage module. The processing module may be used to control and manage the operation of the electronic device, and the storage module may be used to support the electronic device in executing relevant program codes and data.
[0146] The processing module may be a processor or controller that implements or executes the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. The processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a digital signal processing (DSP) and a microprocessor, and the storage module may be a memory.
[0147] An embodiment of the present application also provides a computer-readable storage medium, which stores computer program code. When the computer program code runs on a computer, the computer executes the above-mentioned related method steps to implement a frame animation processing method in the above-mentioned embodiment.
[0148] An embodiment of the present application further provides a computer program product. When the computer program product is run on a computer, the computer is caused to execute the above-mentioned related steps to implement a frame animation processing method in the above-mentioned embodiment.
[0149] In addition, the electronic device provided in the embodiments of the present application can specifically be a chip, component or module, and the electronic device may include a connected processor and memory; wherein the memory is used to store instructions, and when the electronic device is running, the processor can call and execute instructions to enable the chip to perform a frame animation processing method in the above embodiment.
[0150] Among them, the electronic device, computer-readable storage medium, computer program product or chip provided in the embodiments of the present application are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods provided above, and will not be repeated here.
[0151] Through the description of the above implementation methods, technical personnel in the relevant field can understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0152] In the embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of modules or units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0153] The above content is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.
Claims
1. A frame animation processing method, wherein: The method comprises: Setting the display content of the dynamic view component to a static image; the dynamic view component runs in a non-main thread; When a trigger event for playing a frame animation is received, the display content of the dynamic view component is switched from the static image to the sequence frame images of the frame animation.
2. The method according to claim 1, wherein: The step of switching the display content of the dynamic view component from the static image to the sequence frame images of the frame animation includes: Traversing and parsing the sequence frame images of the frame animation through the dynamic view component; The display content of the dynamic view component is switched from the static image to the sequence frame image of the frame animation; the sequence frame image of the frame animation is rendered and displayed frame by frame on the dynamic view component.
3. A frame animation processing method, wherein: The method comprises: Set the display content of the static view component to a static image; Setting the display content of the dynamic view component to the first frame image of the frame animation; the dynamic view component runs in a non-main thread; When a trigger event for playing a frame animation is received, the display state of the static view component is switched from a visible state to a hidden state, and the display state of the dynamic view component is switched from a hidden state to a visible state; The display content of the dynamic view component is switched from the first frame image of the frame animation to the remaining sequence frame images of the frame animation.
4. The method according to claim 3, wherein: The step of setting the display content of the dynamic view component to the first frame image of the frame animation includes: Obtaining the first frame image of the frame animation; After the rendering unit in the dynamic view component is initialized, the display content of the dynamic view component is set to the first frame image of the frame animation, and the display state of the dynamic view component is set to the hidden state.
5. The method according to claim 3 or 4, wherein: Before setting the display content of the dynamic view component to the first frame image of the frame animation, the method includes: Create dynamic view components; The display state of the dynamic view component is set to a visible state to create and initialize a rendering unit in the dynamic view component.
6. The method according to claim 3 or 4, wherein: The step of switching the display content of the dynamic view component from the first frame image of the frame animation to the remaining sequence frame images of the frame animation includes: Traversing and parsing the remaining sequence frame images of the frame animation through the dynamic view component; The display content of the dynamic view component is switched from the first frame image of the frame animation to the remaining sequence frame images of the frame animation; the remaining sequence frame images of the frame animation are rendered and displayed frame by frame on the dynamic view component.
7. A frame animation processing device, wherein: The device comprises: A first preset module is used to set the display content of the dynamic view component to a static image; the dynamic view component runs in a non-main thread; The first switching module is used to switch the display content of the dynamic view component from the static image to the sequence frame image of the frame animation when receiving a trigger event for playing the frame animation.
8. A frame animation processing device, wherein: The device comprises: A second preset module, used to set the display content of the static view component to a static image; A third preset module is used to set the display content of the dynamic view component to the first frame image of the frame animation; the dynamic view component runs in a non-main thread; A second switching module is used to switch the display state of the static view component from a visible state to a hidden state, and switch the display state of the dynamic view component from a hidden state to a visible state when receiving a trigger event of playing a frame animation; The third switching module is used to switch the display content of the dynamic view component from the first frame image of the frame animation to the remaining sequence frame images of the frame animation.
9. An electronic device, wherein: The electronic device comprises: A memory for storing executable program codes; A processor, configured to call and run the executable program code from the memory, so that the electronic device executes the method according to any one of claims 1 to 6.
10. A computer-readable storage medium, wherein: The computer-readable storage medium stores a computer program, and when the computer program is executed, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Method for solving black screens before starting to play android advertisement video
CN109348295A
Animation playing method, terminal and computer readable storage medium
CN109828791A
Previewing a video in response to computing device interaction
CN110679154A
Video picture processing method, related device and storage medium
CN111432265A
Frame animation rendering method and device, computer equipment and storage medium
CN112348929A