WO2019214615A1 - Frame animation realization method and apparatus, electronic device and computer-readable storage medium - Google Patents

Frame animation realization method and apparatus, electronic device and computer-readable storage medium Download PDF

Info

Publication number
WO2019214615A1
WO2019214615A1 PCT/CN2019/085854 CN2019085854W WO2019214615A1 WO 2019214615 A1 WO2019214615 A1 WO 2019214615A1 CN 2019085854 W CN2019085854 W CN 2019085854W WO 2019214615 A1 WO2019214615 A1 WO 2019214615A1
Authority
WO
WIPO (PCT)
Prior art keywords
frame
frame animation
animation
file
pictures
Prior art date
Application number
PCT/CN2019/085854
Other languages
French (fr)
Chinese (zh)
Inventor
魏治平
Original Assignee
鸿合科技股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 鸿合科技股份有限公司 filed Critical 鸿合科技股份有限公司
Publication of WO2019214615A1 publication Critical patent/WO2019214615A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T13/00Animation
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • the present invention relates to the field of image processing technologies, and in particular, to a frame animation implementation method, apparatus, electronic device, and computer readable storage medium.
  • the Android system provides a set of frame animation implementation methods, but the existing method has obvious limitations. For example, the total number of frames of the frame picture is not too large, and the size of each frame cannot be too large, etc. Otherwise, it is very easy to cause problems such as memory overflow when the frame animation is played.
  • the present invention proposes a frame animation implementation method, which can implement frame animation simply and efficiently, and has a small playback limit.
  • the method may include:
  • the acquiring a plurality of frame pictures includes: setting attributes of the plurality of frame pictures such that width, height, and suffix names of the plurality of frame pictures are the same.
  • the acquiring the plurality of frame pictures comprises: renaming the plurality of frame pictures according to a play order, and associating the file names of the frame pictures with a play order thereof.
  • the attribute information of the frame picture includes: a total number of frames of the plurality of frame pictures, and a width, a height, and a suffix name of each of the plurality of frame pictures;
  • the index information of the frame picture includes: a play order of each frame picture in the plurality of frame pictures.
  • the packaging the plurality of frame pictures to generate a frame animation file comprises:
  • the method further includes: storing the frame animation file in a /res/raw/ directory of the Android system.
  • the above method may further include: calling a preset frame animation playback control to read the frame animation file and playing the frame animation.
  • the preset frame animation playback control is a FrameAnimationView.
  • the calling a preset frame animation playing control to read the frame animation file to implement frame animation playback includes:
  • the present invention also provides a frame animation implementation device, including:
  • An acquisition module configured to acquire multiple frame images
  • a parameter determining module configured to determine attribute information and index information of the plurality of frame pictures
  • a generating module configured to package the plurality of the frame images to generate a frame animation file according to the attribute information and the index information.
  • the frame animation implementation apparatus further includes: a playing module, configured to call a preset frame animation playing control to read the frame animation file and play the frame animation.
  • the present invention also provides an electronic device comprising a memory, a processor, and a computer program stored on the memory and operable on the processor, the processor executing the program to implement the frame animation of any of the above Implementation.
  • the present invention also provides a computer readable storage medium having stored thereon a computer program that, when executed by a processor, implements the frame animation implementation method of any of the above.
  • the frame animation implementation solution provided by the present invention generates a frame animation file for frame animation playback based on the acquired frame image, and has no limitation on the size of the frame image and the total number of frames, and can be played during playback.
  • the problem is that the playback restriction is small, the playback is smooth, the card is not stuck, and there is no memory overflow.
  • FIG. 1 is a flowchart of a method for implementing frame animation according to an embodiment of the present invention
  • FIG. 2 is a schematic structural diagram of a frame animation file according to an embodiment of the present invention.
  • FIG. 3 is a schematic diagram of a frame animation playing process according to an embodiment of the present invention.
  • FIG. 4 is a schematic structural diagram of a frame animation implementation apparatus according to an embodiment of the present invention.
  • FIG. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
  • the embodiment of the present invention provides a frame animation implementation method.
  • FIG. 1 is a flowchart of a method for implementing frame animation according to an embodiment of the present invention. As shown in FIG. 1 , a method for implementing a frame animation according to an embodiment of the present invention includes the following steps:
  • Step 101 Acquire multiple frame pictures.
  • a plurality of frame pictures for playing a frame animation may first be acquired.
  • the frame picture may be a frame picture directly obtained from a specified position, or may be a frame picture generated after processing according to the original picture.
  • the processing of the frame picture in the step of acquiring the plurality of frame pictures may specifically include: setting the attributes of the plurality of frame pictures, and making the width, height, and suffix name of the plurality of the frame pictures. All the same.
  • the attributes of the acquired multiple frame pictures may be set, and the width and height thereof are set to be the same, so that the size of each frame picture will be exactly the same.
  • the suffix names of multiple frame pictures can be set to be the same, which can ensure that multiple frame pictures are the same file format.
  • the processing of the frame picture in the step of acquiring the plurality of frame pictures may further include: renaming the plurality of frame pictures according to the playing order, so that the file names of the plurality of frame pictures are The playback order is associated.
  • the file names of the plurality of frame pictures may be directly renamed into consecutive numbers, or the play order list may be established between the file names of the plurality of frame pictures according to the play order, and multiple frames may be used by using the foregoing multiple manners.
  • the file name after the picture is renamed is associated with the play order for convenient storage and subsequent calls. Taking the example of renaming a continuous number as an example, the naming of the first frame picture in the playback order is arranged from 0, which can be expressed as: 0.png, 1.png, 2.png....
  • Step 102 Determine attribute information and index information of the plurality of frame pictures.
  • attribute information and index information of the plurality of frame pictures may be further acquired.
  • the attribute information of the frame picture includes: a total number of frames of the plurality of frame pictures, and a width, a height, and a suffix name of each of the plurality of frame pictures.
  • the index information of the frame picture includes: a play sequence of each of the plurality of frame pictures.
  • Step 103 Packet the plurality of frame pictures according to the attribute information and the index information of the frame picture to generate a frame animation file.
  • Embodiments of the present invention provide a frame animation packaging tool that is specifically used to package a plurality of frame pictures to generate a frame animation file.
  • the frame animation packaging tool may be implemented by means of a batch file, which may include: firstly establishing a batch file make.bat, and then modifying the second, third, fourth, fifth, and sixth parameter information of the batch file, The second parameter indicates how many frames are in total, the third parameter is the width of the frame picture, the fourth parameter is the height of the picture, the fifth parameter is the suffix of the frame picture, and the sixth parameter is the generated frame animation file storage path.
  • the step of the frame animation package tool that is, the step of packaging the plurality of frame images to generate the frame animation file according to the attribute information and the index information may specifically include:
  • the frame animation packaging tool may be written and generated using any programming language, and is written in the C language in this embodiment.
  • the structure of the generated frame animation file can be as shown in FIG. 2, wherein the first 4 bytes of the frame animation file is the total number of frames, that is, the total number of frame images, corresponding to the second batch file. Parameter; the second 4 bytes indicates the width of the frame picture, corresponding to the third parameter of the batch file; the third 4 bytes indicates the height of the frame picture, corresponding to the fourth parameter of the batch file; then the data index
  • the length of the total frame is *4 bytes, corresponding to the start position of the first frame picture in this file, the start position of the second frame picture in this file, and the nth frame picture in this file.
  • the starting position; the last is the data area, which can be written directly in the order in which the frame pictures are played.
  • the generated frame animation file may be further stored in the /res/raw/ directory of the Android system.
  • the /res/raw/ directory of Android is used to store common files, and the files in this folder will not be compiled into binary files and copied to the device as they are.
  • the generated frame animation file is stored in the /res/raw/ directory, which ensures the normal storage of the frame animation file and subsequent normal reading.
  • a frame animation file may be generated according to a plurality of frame images, and the frame animation file has no limitation on the total number of frames of the frame image and the width and height of the frame image, that is, the process of generating the frame animation file to the frame image There is no limit to the number and size.
  • the frame animation implementation method in the embodiment of the present invention may further perform the following steps to perform frame animation playback.
  • Step 104 Call a preset frame animation playback control to read the frame animation file and play the frame animation.
  • the preset frame animation playing control may be specifically a FrameAnimationView.
  • FrameAnimationView is inherited from SurfaceView for the user interface (UI).
  • UI user interface
  • the reason why the embodiment of the present invention selects the SurfaceView is because the ordinary View can only update the UI in the main thread, and the SurfaceView can update the UI in the child thread, so if we use the SurfaceView, one thread can be used to read from the frame animation file.
  • the current frame data, another thread is used to render the UI, in order to ensure smooth playback of the frame animation.
  • other animation playing plugins may also be employed as the preset frame animation playing plug-in.
  • the foregoing steps may specifically include: first, initializing frame animation information, reading the frame animation file, acquiring the attribute information and index information; and playing according to the attribute information
  • the frame image application buffer reading the currently played frame image to the buffer according to the index information; decoding the buffer to generate a current format of a preset format corresponding to the frame image And acquiring the current play picture, and rendering the current play picture to a user interface for playing.
  • the foregoing preset format may be a Bitmap format.
  • step 301 is required to start initializing the animation information; then, two child threads are started, and one child thread is frame animation data.
  • the decoding thread 302 (Image Decode Thread) is used to continuously parse the data of the current frame image from the animation file and put it into the corresponding buffer; another sub-thread is the frame animation UI rendering thread 303 (Animation Draw Thread), used to The data in the current frame image is continuously read in the buffer and rendered onto the UI.
  • the frame rate is how many milliseconds, if it is a single play, the duration of the last frame after playing all the frames, and whether you need to play the completion callback, etc. .
  • the frame animation data decoding thread 302 may specifically include: 3021: obtain current frame index information; 3022: apply for a buffer according to a current frame data size in the current frame index information; 3023: read from a current frame index position. Take data to the buffer; 3024: decode the buffer data to generate a Bitmap; 3025: use the synchronization method to put the Bitmap into the bitmap buffer; 3026: determine whether to loop play; if yes, further execute 3027 to determine whether it is the last frame; If not, the process ends 3028, and the frame counter is reset to zero and returns to 3021. If it is not the last frame, the process 3029 increments the frame counter by one and returns to 3021.
  • the frame animation UI rendering thread 303 specifically includes: 3031: obtain the current Bitmap; 3032: determine whether it is empty; if not empty, return 3021; if it is empty, execute 3033, use the synchronization method to render the Bitmap to the UI interface ; 3034: use the synchronization method to remove the current frame Bitmap from the frame buffer, and immediately release the resource; 3035: determine whether to loop, if not, then end; if yes, further perform 3036 to determine whether it is the last frame; If it is the last frame, execute 3037 to zero the frame counter and return to 3031; if it is not the last frame, execute 3038 to increment the frame counter by 1, and return to 3031.
  • the second parameter indicates the time to delay the callback after the play is finished
  • the third parameter is the playback completion callback
  • the frame animation implementation method in the Android system of the present invention only needs to first use the frame animation production tool provided by the present invention to package a plurality of frame images into one frame animation file, thereby generating a frame animation file, and
  • This frame animation file does not set a limit on the number and size of frame images, and frame animation can be implemented simply and efficiently, and the playback limit is small.
  • the user can use the custom frame animation playback control in the interface layout file, and call the frame animation playback and stop method provided by the custom control in the program code, and the number of unrestricted frames can be easily realized. , the size of the smooth play.
  • an embodiment of the present invention further provides a frame animation implementation apparatus, including:
  • An obtaining module 401 configured to acquire multiple frame images
  • the parameter determining module 402 is configured to determine attribute information and index information of the plurality of frame pictures.
  • the generating module 403 is configured to package the plurality of the frame pictures to generate a frame animation file according to the attribute information and the index information.
  • the frame animation implementation apparatus may further include: a playing module 404, configured to call a preset frame animation playing control to read the frame animation file and play a frame animation, in order to implement the playing of the animation file. .
  • the obtaining module 401 may specifically include:
  • an attribute setting unit configured to set an attribute of the plurality of frame pictures, so that the width, the height, and the suffix name of the plurality of the frame pictures are the same.
  • a renaming unit configured to rename a plurality of the frame pictures according to a play order, so that a file name of the frame picture is associated with a play order thereof.
  • the attribute information of the frame picture includes: a total number of frames of the plurality of frame pictures, and a width, a height, and a suffix name of each frame picture.
  • the index information of the frame picture includes: a play order of each frame picture.
  • the generating module 403 may specifically include:
  • An information reading unit configured to read the attribute information and the index information and save the information
  • a file creation unit for creating a frame animation file
  • An information writing unit configured to write a total number of frames of the plurality of frame images in the created frame animation file, and a width and a height of each of the frame images;
  • a buffer application unit configured to apply a buffer having a capacity of four times the total number of frames of the plurality of frame pictures and write the frame animation file
  • a frame picture writing unit configured to cyclically read the plurality of frame pictures and write the plurality of frame pictures to the frame animation file according to a play order, and to use the plurality of frame pictures in the empty frame animation file
  • the offset is recorded to the corresponding buffer; the write buffer is written back; and the frame animation file is closed.
  • the generating module 403 further includes: a storage unit, configured to store the frame animation file in an /res/raw/ directory of the Android system.
  • the preset frame animation playing control is a FrameAnimationView.
  • the foregoing playing module 404 may specifically include:
  • An information determining unit configured to read a frame animation file, and obtain attribute information and index information
  • a cache application unit configured to apply for a buffer for the currently played frame image according to the attribute information
  • a frame picture reading unit configured to read the currently played frame picture to the buffer according to the index information
  • a decoding unit configured to decode the buffer, and generate a current play picture in a preset format corresponding to the frame picture
  • a rendering unit configured to acquire the current play picture, and render the current play picture to a user interface for playing.
  • the foregoing preset format may be a Bitmap format.
  • the device of the foregoing embodiment is used to implement the corresponding frame animation implementation method in the foregoing embodiment, and has the beneficial effects of the corresponding method embodiments, and details are not described herein again.
  • an embodiment of the present invention further provides an electronic device, which is configured as shown in FIG. 5, and includes a memory 501 and a processor 502.
  • the memory 501 and the processor 502 are connected by a bus; and the memory is stored and processed.
  • the electronic device of the foregoing embodiment is used to implement the corresponding method in the foregoing embodiments, and has the beneficial effects of the corresponding method embodiments, and details are not described herein again.
  • the embodiment of the present invention further provides a computer readable storage medium, where computer instructions are stored, and when the processor executes the computer instruction, the frame animation implementation method according to any one of the foregoing embodiments is implemented.
  • DRAM dynamic RAM

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Processing Or Creating Images (AREA)

Abstract

Disclosed is a frame animation realization method, comprising: acquiring multiple frame pictures; determining attribute information and index information of the multiple frame pictures; and according to the attribute information and the index information, packaging the multiple frame pictures to generate a frame animation file. Further disclosed are a frame animation realization apparatus, an electronic device and a computer-readable storage medium. According to the present invention, a frame animation file for frame animation playing is generated based on acquired frame pictures, there is no limitation to both the size and the number of the frame pictures, and smooth playing of a frame animation can be realized while the playing limitation is low.

Description

帧动画实现方法、装置、电子设备及计算机可读存储介质Frame animation implementation method, device, electronic device and computer readable storage medium 技术领域Technical field
本发明涉及图像处理技术领域,特别是指一种帧动画实现方法、装置、电子设备及计算机可读存储介质。The present invention relates to the field of image processing technologies, and in particular, to a frame animation implementation method, apparatus, electronic device, and computer readable storage medium.
背景技术Background technique
目前安卓(Android)系统原生提供了一套帧动画实现的方法,但此现有方法存在明显的局限性,例如,要求帧图片总帧数不能太多,每帧图片尺寸不能太大等等,否则极易造成帧动画播放的时候卡顿甚至于发生内存溢出等问题。At present, the Android system provides a set of frame animation implementation methods, but the existing method has obvious limitations. For example, the total number of frames of the frame picture is not too large, and the size of each frame cannot be too large, etc. Otherwise, it is very easy to cause problems such as memory overflow when the frame animation is played.
发明内容Summary of the invention
有鉴于此,本发明提出一种帧动画实现方法,可以简单高效地实现帧动画,并且播放限制小。In view of this, the present invention proposes a frame animation implementation method, which can implement frame animation simply and efficiently, and has a small playback limit.
在本发明的实施例中,该方法可以包括:In an embodiment of the invention, the method may include:
获取多个帧图片;Get multiple frame images;
获取所述多个帧图片的属性信息和索引信息;以及Obtaining attribute information and index information of the plurality of frame pictures; and
根据所述属性信息和索引信息,将所述多个帧图片打包生成帧动画文件。And encoding the plurality of frame pictures according to the attribute information and the index information to generate a frame animation file.
在本发明的一些实施例中,所述获取多个帧图片包括:设置所述多个帧图片的属性,使所述多个帧图片的宽度、高度和后缀名均相同。In some embodiments of the present invention, the acquiring a plurality of frame pictures includes: setting attributes of the plurality of frame pictures such that width, height, and suffix names of the plurality of frame pictures are the same.
在本发明的一些实施例中,所述获取多个帧图片包括:根据播放顺序将所述多个帧图片进行重命名,使所述帧图片的文件名与其播放顺序相关联。In some embodiments of the present invention, the acquiring the plurality of frame pictures comprises: renaming the plurality of frame pictures according to a play order, and associating the file names of the frame pictures with a play order thereof.
在本发明的一些实施例中,所述帧图片的属性信息包括:所述多个帧图片的总帧数,以及所述多个帧图片中每个帧图片的宽度、高度和后缀名;所述帧图片的索引信息包括:所述多个帧图片中每个帧图片的播放顺序。In some embodiments of the present invention, the attribute information of the frame picture includes: a total number of frames of the plurality of frame pictures, and a width, a height, and a suffix name of each of the plurality of frame pictures; The index information of the frame picture includes: a play order of each frame picture in the plurality of frame pictures.
在本发明的一些实施例中,所述将所述多个帧图片打包生成帧动画文 件包括:In some embodiments of the present invention, the packaging the plurality of frame pictures to generate a frame animation file comprises:
读取并保存所述属性信息和索引信息;Reading and saving the attribute information and index information;
创建一个帧动画文件;Create a frame animation file;
在所述帧动画文件中写入所述多个帧图片的总帧数,以及每个帧图片的宽度、高度;Writing a total number of frames of the plurality of frame pictures in the frame animation file, and a width and a height of each frame picture;
申请所述多个帧图片的总帧数四倍大小的缓冲区并写入所述帧动画文件;Applying a buffer of four times the total number of frames of the plurality of frame pictures and writing the frame animation file;
循环读取所述多个帧图片并根据播放顺序写入所述帧动画文件,将所述多个帧图片在所述空帧动画文件中的偏移记录到对应的缓冲区;And cyclically reading the plurality of frame pictures and writing the frame animation file according to a play order, and recording an offset of the plurality of frame pictures in the empty frame animation file to a corresponding buffer;
回写缓冲区;Write back to the buffer;
关闭所述帧动画文件。Close the frame animation file.
在本发明的一些实施例中,上述方法在将所述多个帧图片打包生成帧动画文件之后,还包括:将所述帧动画文件存储至安卓系统的/res/raw/目录下。In some embodiments of the present invention, after the method of packaging the plurality of frame pictures to generate a frame animation file, the method further includes: storing the frame animation file in a /res/raw/ directory of the Android system.
在本发明的一些实施例中,上述方法可以进一步包括:调用预设的帧动画播放控件读取所述帧动画文件并播放帧动画。In some embodiments of the present invention, the above method may further include: calling a preset frame animation playback control to read the frame animation file and playing the frame animation.
在一些实施方式中,所述预设的帧动画播放控件为FrameAnimationView。In some embodiments, the preset frame animation playback control is a FrameAnimationView.
在一些实施方式中,所述调用预设的帧动画播放控件读取所述帧动画文件以实现帧动画播放包括:In some embodiments, the calling a preset frame animation playing control to read the frame animation file to implement frame animation playback includes:
读取所述帧动画文件,获取所述属性信息和索引信息;Reading the frame animation file to obtain the attribute information and index information;
根据所述属性信息,为当前播放的所述帧图片申请缓冲区;And applying, according to the attribute information, a buffer for the currently played frame image;
根据所述索引信息,读取当前播放的所述帧图片到所述缓冲区;Reading the currently played frame picture to the buffer according to the index information;
解码所述缓冲区,生成与所述帧图片对应的预设格式的当前播放图片;Decoding the buffer to generate a current play picture in a preset format corresponding to the frame picture;
获取所述当前播放图片,将所述当前播放图片渲染至用户界面进行播放。Obtaining the current play picture, and rendering the current play picture to a user interface for playing.
对应上述帧动画实现方法,本发明还提供了一种帧动画实现装置,包括:Corresponding to the above-mentioned frame animation implementation method, the present invention also provides a frame animation implementation device, including:
获取模块,用于获取多个帧图片;An acquisition module, configured to acquire multiple frame images;
参数确定模块,用于确定上述多个帧图片的属性信息和索引信息;以及a parameter determining module, configured to determine attribute information and index information of the plurality of frame pictures; and
生成模块,用于根据所述属性信息和索引信息,将多个所述帧图片打包生成帧动画文件。And a generating module, configured to package the plurality of the frame images to generate a frame animation file according to the attribute information and the index information.
在本发明的一些实施例中,上述帧动画实现装置进一步包括:播放模块,用于调用预设的帧动画播放控件读取所述帧动画文件并播放帧动画。In some embodiments of the present invention, the frame animation implementation apparatus further includes: a playing module, configured to call a preset frame animation playing control to read the frame animation file and play the frame animation.
本发明还提供了一种电子设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述程序时实现如上任意一项所述的帧动画实现方法。The present invention also provides an electronic device comprising a memory, a processor, and a computer program stored on the memory and operable on the processor, the processor executing the program to implement the frame animation of any of the above Implementation.
本发明还提供一种计算机可读存储介质,其上存储有计算机程序,上述计算机程序被处理器执行时实现如上任意一项所述的帧动画实现方法。The present invention also provides a computer readable storage medium having stored thereon a computer program that, when executed by a processor, implements the frame animation implementation method of any of the above.
从上面所述可以看出,本发明提供的帧动画实现方案,基于获取的帧图片生成用于帧动画播放的帧动画文件,对于帧图片的大小和总帧数没有限制,并且可以在播放时实现播放限制小、播放流畅、不卡顿、且不会出现内存溢出的问题。As can be seen from the above, the frame animation implementation solution provided by the present invention generates a frame animation file for frame animation playback based on the acquired frame image, and has no limitation on the size of the frame image and the total number of frames, and can be played during playback. The problem is that the playback restriction is small, the playback is smooth, the card is not stuck, and there is no memory overflow.
附图说明DRAWINGS
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the embodiments or the description of the prior art will be briefly described below. Obviously, the drawings in the following description are only It is a certain embodiment of the present invention, and other drawings can be obtained from those skilled in the art without any creative work.
图1为本发明实施例的帧动画实现方法流程图;1 is a flowchart of a method for implementing frame animation according to an embodiment of the present invention;
图2为本发明实施例中帧动画文件的结构示意图;2 is a schematic structural diagram of a frame animation file according to an embodiment of the present invention;
图3为本发明实施例的帧动画播放流程示意图;3 is a schematic diagram of a frame animation playing process according to an embodiment of the present invention;
图4为本发明实施例的帧动画实现装置结构示意图;以及4 is a schematic structural diagram of a frame animation implementation apparatus according to an embodiment of the present invention;
图5为本发明实施例的电子设备结构示意图。FIG. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
具体实施方式detailed description
为使本发明的目的、技术方案和优点更加清楚明白,以下结合具体实施例,并参照附图,对本发明进一步详细说明。The present invention will be further described in detail below with reference to the specific embodiments of the invention.
如前所述,为了解决现有安卓系统在播放帧动画时限制太多或播放不流畅等问题,本发明实施例提供了一种帧动画实现方法。As described above, in order to solve the problem that the existing Android system restricts too much or the playback is not smooth when the frame animation is played, the embodiment of the present invention provides a frame animation implementation method.
图1为本发明实施例提出的帧动画实现方法流程图。如图1所示,本发明实施例所述的帧动画实现方法,包括以下步骤:FIG. 1 is a flowchart of a method for implementing frame animation according to an embodiment of the present invention. As shown in FIG. 1 , a method for implementing a frame animation according to an embodiment of the present invention includes the following steps:
步骤101、获取多个帧图片。Step 101: Acquire multiple frame pictures.
在本发明的实施例中,首先可以获取用于播放帧动画的多个帧图片。该帧图片可以为从指定位置直接获取的帧图片,也可以为根据原始的图片进行处理后生成的帧图片。In an embodiment of the invention, a plurality of frame pictures for playing a frame animation may first be acquired. The frame picture may be a frame picture directly obtained from a specified position, or may be a frame picture generated after processing according to the original picture.
由于播放帧动画时要求每一帧的帧图片需要具有相同的规格和文件格式,以便于后续的数据处理。因此,在本发明的实施例中,获取多个帧图片的步骤中的对帧图片的处理具体可以包括:设置多个帧图片的属性,使多个所述帧图片的宽度、高度和后缀名均相同。具体地,可以将获取到的多个帧图片的属性进行设置,将其宽度和高度设置为相同,这样每个帧图片的大小将完全相同。此外,还可以将多个帧图片的后缀名设置为相同,这样能够保证多个帧图片均为相同的文件格式。Since the frame picture of each frame is required to play the frame animation, it needs to have the same specifications and file format for subsequent data processing. Therefore, in the embodiment of the present invention, the processing of the frame picture in the step of acquiring the plurality of frame pictures may specifically include: setting the attributes of the plurality of frame pictures, and making the width, height, and suffix name of the plurality of the frame pictures. All the same. Specifically, the attributes of the acquired multiple frame pictures may be set, and the width and height thereof are set to be the same, so that the size of each frame picture will be exactly the same. In addition, the suffix names of multiple frame pictures can be set to be the same, which can ensure that multiple frame pictures are the same file format.
此外,由于上述多个帧图片将用于播放帧动画,则其间应具有一定的时序上的先后关系,即播放顺序。因此,在本发明的实施例中,获取多个帧图片的步骤中的对帧图片的处理具体可以进一步包括:根据播放顺序将多个帧图片进行重命名,使多个帧图片的文件名与其播放顺序相关联。具体地,可以将多个帧图片的文件名直接重命名为连续的数字,或者将多个帧图片的文件名之间根据播放顺序建立播放顺序列表,通过上述多种方式,可以将多个帧图片重命名后的文件名与播放顺序相关联,方便存储以及后续的调用。以重命名为连续的数字为例,播放顺序中第一个帧图片的命名从0开始排列,具体可以表示为:0.png、1.png、2.png...。In addition, since the plurality of frame pictures will be used for playing frame animation, there should be a certain timing relationship, that is, a play order. Therefore, in the embodiment of the present invention, the processing of the frame picture in the step of acquiring the plurality of frame pictures may further include: renaming the plurality of frame pictures according to the playing order, so that the file names of the plurality of frame pictures are The playback order is associated. Specifically, the file names of the plurality of frame pictures may be directly renamed into consecutive numbers, or the play order list may be established between the file names of the plurality of frame pictures according to the play order, and multiple frames may be used by using the foregoing multiple manners. The file name after the picture is renamed is associated with the play order for convenient storage and subsequent calls. Taking the example of renaming a continuous number as an example, the naming of the first frame picture in the playback order is arranged from 0, which can be expressed as: 0.png, 1.png, 2.png....
步骤102、确定上述多个帧图片的属性信息和索引信息。Step 102: Determine attribute information and index information of the plurality of frame pictures.
在本发明的实施例中,在获取多个帧图片后,可以进一步获取这多个帧图片的属性信息和索引信息。其中,上述帧图片的属性信息包括:多个帧图片的总帧数,以及这多个帧图片中每个帧图片的宽度、高度和后缀名。上述帧图片的索引信息包括:这多个帧图片中每个所述帧图片的播放顺 序。In an embodiment of the present invention, after acquiring a plurality of frame pictures, attribute information and index information of the plurality of frame pictures may be further acquired. The attribute information of the frame picture includes: a total number of frames of the plurality of frame pictures, and a width, a height, and a suffix name of each of the plurality of frame pictures. The index information of the frame picture includes: a play sequence of each of the plurality of frame pictures.
步骤103、根据上述帧图片的属性信息和索引信息,将上述多个帧图片打包生成帧动画文件。Step 103: Packet the plurality of frame pictures according to the attribute information and the index information of the frame picture to generate a frame animation file.
本发明的实施例提供一种专门用于将多个帧图片打包生成帧动画文件的帧动画打包工具。具体地,该帧动画打包工具可以通过批处理文件的方式实现,具体可以包括:首先建立一个批处理文件make.bat,然后修改该批处理文件第二、三、四、五、六参数信息,其中,第二参数表示总共有多少帧,第三参数是帧图片的宽度,第四参数是图片的高度,第五参数是帧图片的后缀,第六参数是生成后的帧动画文件存储路径。Embodiments of the present invention provide a frame animation packaging tool that is specifically used to package a plurality of frame pictures to generate a frame animation file. Specifically, the frame animation packaging tool may be implemented by means of a batch file, which may include: firstly establishing a batch file make.bat, and then modifying the second, third, fourth, fifth, and sixth parameter information of the batch file, The second parameter indicates how many frames are in total, the third parameter is the width of the frame picture, the fourth parameter is the height of the picture, the fifth parameter is the suffix of the frame picture, and the sixth parameter is the generated frame animation file storage path.
在本发明的实施例中,上述帧动画打包工具的工作过程,即根据所述属性信息和索引信息,将多个帧图片打包生成帧动画文件的步骤具体可以包括:In the embodiment of the present invention, the step of the frame animation package tool, that is, the step of packaging the plurality of frame images to generate the frame animation file according to the attribute information and the index information may specifically include:
读取并保存上述多个帧图片的属性信息和索引信息;Reading and saving attribute information and index information of the plurality of frame pictures;
创建一个帧动画文件;Create a frame animation file;
在帧动画文件中写入多个帧图片的总帧数,以及每个帧图片的宽度、高度;The total number of frames in which a plurality of frame images are written in a frame animation file, and the width and height of each frame image;
申请容量为多个帧图片的总帧数四倍大小的缓冲区并写入帧动画文件;Applying a buffer having a capacity of four times the total number of frames of a plurality of frame pictures and writing the frame animation file;
循环读取多个帧图片并根据播放顺序写入帧动画文件,将多个帧图片在空帧动画文件中的偏移记录到对应的缓冲区;Cycling a plurality of frame images and writing the frame animation file according to the playing order, and recording the offset of the plurality of frame images in the empty frame animation file to the corresponding buffer;
回写缓冲区;以及Write back to the buffer;
关闭帧动画文件。Close the frame animation file.
在本发明的实施例中,上述帧动画打包工具可以使用任意编程语言编写生成,本实施例中采用C语言编写。In the embodiment of the present invention, the frame animation packaging tool may be written and generated using any programming language, and is written in the C language in this embodiment.
经过上述打包过程,生成的帧动画文件的结构可如图2所示,其中,帧动画文件的第一个4字节是总帧数,也就是帧图片总数,对应批处理文件的第二个参数;第二个4字节表示帧图片的宽度,对应批处理文件的第三个参数;第三个4字节表示帧图片的高度,对应批处理文件的第四个参数;然后是数据索引区,长度为总帧数*4字节,分别对应第一个帧图片在此文件中的开始位置、第二个帧图片在此文件中的开始位置、以及第n个帧图片在此文件中的开始位置;最后为数据区,直接按帧图片的播放顺序 写入即可。After the above packaging process, the structure of the generated frame animation file can be as shown in FIG. 2, wherein the first 4 bytes of the frame animation file is the total number of frames, that is, the total number of frame images, corresponding to the second batch file. Parameter; the second 4 bytes indicates the width of the frame picture, corresponding to the third parameter of the batch file; the third 4 bytes indicates the height of the frame picture, corresponding to the fourth parameter of the batch file; then the data index The length of the total frame is *4 bytes, corresponding to the start position of the first frame picture in this file, the start position of the second frame picture in this file, and the nth frame picture in this file. The starting position; the last is the data area, which can be written directly in the order in which the frame pictures are played.
在本发明的一些实施例中,在执行完上述步骤103之后,还可以进一步执行:将生成的帧动画文件存储至安卓系统的/res/raw/目录下。In some embodiments of the present invention, after the step 103 is performed, the generated frame animation file may be further stored in the /res/raw/ directory of the Android system.
通常,安卓系统的/res/raw/目录用于存放通用的文件,该文件夹内的文件将不会被编译成二进制文件,按原样复制到设备上。将生成的帧动画文件存储至/res/raw/目录下,能够保证帧动画文件的正常存储,以及后续的正常读取。Usually, the /res/raw/ directory of Android is used to store common files, and the files in this folder will not be compiled into binary files and copied to the device as they are. The generated frame animation file is stored in the /res/raw/ directory, which ensures the normal storage of the frame animation file and subsequent normal reading.
通过上述步骤101~103可以根据多个帧图片生成帧动画文件,该帧动画文件对帧图片的总帧数以及帧图片的宽度和高度都没有限制,也即生成帧动画文件的过程对帧图片的数量以及大小都没有限制。Through the above steps 101-103, a frame animation file may be generated according to a plurality of frame images, and the frame animation file has no limitation on the total number of frames of the frame image and the width and height of the frame image, that is, the process of generating the frame animation file to the frame image There is no limit to the number and size.
在生成了上述帧动画文件后,本发明实施例所述的帧动画实现方法还可以进一步执行下面的步骤以进行帧动画的播放。After the frame animation file is generated, the frame animation implementation method in the embodiment of the present invention may further perform the following steps to perform frame animation playback.
步骤104、调用预设的帧动画播放控件读取所述帧动画文件并播放帧动画。Step 104: Call a preset frame animation playback control to read the frame animation file and play the frame animation.
在本发明的实施例中,上述预设的帧动画播放控件可以具体为FrameAnimationView。FrameAnimationView继承于SurfaceView,用于用户界面(UI)。本发明的实施例选择SurfaceView的原因是因为普通的View只能在主线程中更新UI,而SurfaceView可以在子线程中更新UI,所以我们如果使用SurfaceView可以一个线程用来从帧动画文件中读取当前帧数据,另外一个线程用来渲染UI,这样才能保证帧动画流畅的播放。在本发明的其他实施例中,也可以采用其他的动画播放插件作为上述预设的帧动画播放插件。In the embodiment of the present invention, the preset frame animation playing control may be specifically a FrameAnimationView. FrameAnimationView is inherited from SurfaceView for the user interface (UI). The reason why the embodiment of the present invention selects the SurfaceView is because the ordinary View can only update the UI in the main thread, and the SurfaceView can update the UI in the child thread, so if we use the SurfaceView, one thread can be used to read from the frame animation file. The current frame data, another thread is used to render the UI, in order to ensure smooth playback of the frame animation. In other embodiments of the present invention, other animation playing plugins may also be employed as the preset frame animation playing plug-in.
具体地,在本发明的实施例中,上述步骤可以具体包括:首先,初始化帧动画信息,读取所述帧动画文件,获取所述属性信息和索引信息;根据所述属性信息,为当前播放的所述帧图片申请缓冲区;根据所述索引信息,读取当前播放的所述帧图片到所述缓冲区;解码所述缓冲区,生成与所述帧图片对应的预设格式的当前播放图片;获取所述当前播放图片,将所述当前播放图片渲染至用户界面进行播放。在本发明的实施例中,上述预设格式可以为Bitmap格式。Specifically, in the embodiment of the present invention, the foregoing steps may specifically include: first, initializing frame animation information, reading the frame animation file, acquiring the attribute information and index information; and playing according to the attribute information The frame image application buffer; reading the currently played frame image to the buffer according to the index information; decoding the buffer to generate a current format of a preset format corresponding to the frame image And acquiring the current play picture, and rendering the current play picture to a user interface for playing. In an embodiment of the present invention, the foregoing preset format may be a Bitmap format.
具体的,在使用FrameAnimationView控件实际实施过程中,可以参考图3所示的过程,开始播放帧动画时,首先需要执行步骤301开始初始 化动画信息;然后启动两个子线程,一个子线程是帧动画数据解码线程302(Image Decode Thread),用来从动画文件中不断解析当前帧图片的数据并放到对应缓冲区中;另外一个子线程是帧动画UI渲染线程303(Animation Draw Thread),用来从缓冲区中不断读取当前帧图片的数据并渲染到UI上。Specifically, in the actual implementation process of using the FrameAnimationView control, reference may be made to the process shown in FIG. 3, when starting to play the frame animation, firstly, step 301 is required to start initializing the animation information; then, two child threads are started, and one child thread is frame animation data. The decoding thread 302 (Image Decode Thread) is used to continuously parse the data of the current frame image from the animation file and put it into the corresponding buffer; another sub-thread is the frame animation UI rendering thread 303 (Animation Draw Thread), used to The data in the current frame image is continuously read in the buffer and rendered onto the UI.
此外,开始播放帧动画时,还需要传递一些参数,比如是否需要循环播放,帧率是多少毫秒,如果是单次播放,播放完所有帧后最后一帧停留的时长以及是否需要播放完成回调等。In addition, when starting to play the frame animation, you need to pass some parameters, such as whether you need to play in a loop, the frame rate is how many milliseconds, if it is a single play, the duration of the last frame after playing all the frames, and whether you need to play the completion callback, etc. .
具体地,参考图3,上述帧动画数据解码线程302可以具体包括:3021:得到当前帧索引信息;3022:根据当前帧索引信息中当前帧数据大小申请缓冲区;3023:从当前帧索引位置读取数据到缓冲区;3024:解码缓冲区数据生成Bitmap;3025:使用同步方法将Bitmap放入位图缓冲区;3026:判断是否循环播放;如果是则进一步执行3027判断是否为最后一帧;如果否,则结束;如果是最后一帧,则执行3028将帧计数器归零,并返回3021;如果不是最后一帧,则执行3029将帧计数器加1,并返回3021。Specifically, referring to FIG. 3, the frame animation data decoding thread 302 may specifically include: 3021: obtain current frame index information; 3022: apply for a buffer according to a current frame data size in the current frame index information; 3023: read from a current frame index position. Take data to the buffer; 3024: decode the buffer data to generate a Bitmap; 3025: use the synchronization method to put the Bitmap into the bitmap buffer; 3026: determine whether to loop play; if yes, further execute 3027 to determine whether it is the last frame; If not, the process ends 3028, and the frame counter is reset to zero and returns to 3021. If it is not the last frame, the process 3029 increments the frame counter by one and returns to 3021.
上述帧动画UI渲染线程303具体包括:3031:得到当前的Bitmap;3032:判断是否为空;如果不为空,则返回3021;如果是为空,则执行3033,使用同步方法渲染Bitmap到UI界面;3034:使用同步方法将当前帧Bitmap从帧缓冲区中移除,并立即释放资源;3035:判断是否循环播放,如果否,则结束;如果是则进一步执行3036判断是否为最后一帧;如果是最后一帧,则执行3037将帧计数器归零,并返回3031;如果不是最后一帧,则执行3038将帧计数器加1,并返回3031。The frame animation UI rendering thread 303 specifically includes: 3031: obtain the current Bitmap; 3032: determine whether it is empty; if not empty, return 3021; if it is empty, execute 3033, use the synchronization method to render the Bitmap to the UI interface ; 3034: use the synchronization method to remove the current frame Bitmap from the frame buffer, and immediately release the resource; 3035: determine whether to loop, if not, then end; if yes, further perform 3036 to determine whether it is the last frame; If it is the last frame, execute 3037 to zero the frame counter and return to 3031; if it is not the last frame, execute 3038 to increment the frame counter by 1, and return to 3031.
对应于上述实施例的安卓系统下的帧动画实现方法,可通过在需要使用帧动画的程序文件中使用代码如下:The frame animation implementation method corresponding to the Android system of the above embodiment can be used by using the code in a program file that needs to use frame animation as follows:
Figure PCTCN2019085854-appb-000001
Figure PCTCN2019085854-appb-000001
Figure PCTCN2019085854-appb-000002
Figure PCTCN2019085854-appb-000002
只播放一次动画,第二个参数表示播放完毕后延迟调用回调的时间,第三个参数是播放完成回调。Only one animation is played, the second parameter indicates the time to delay the callback after the play is finished, and the third parameter is the playback completion callback.
由上述实施例可见,本发明的安卓系统下的帧动画实现方法,用户只需要先使用本发明提供的帧动画制作工具将若干帧图片打包为一个帧动画文件,即可生成帧动画文件,且此帧动画文件对帧图片的数量以及大小不设置限制,可以简单高效地实现帧动画,并且播放限制小。此后,用户即可以在界面布局文件中使用自定义的帧动画播放控件,并在程序代码中调用此自定义控件提供的帧动画播放、停止的方法,就能够很轻松的实现不限帧图片数量、大小的流畅播放。It can be seen from the above embodiment that the frame animation implementation method in the Android system of the present invention only needs to first use the frame animation production tool provided by the present invention to package a plurality of frame images into one frame animation file, thereby generating a frame animation file, and This frame animation file does not set a limit on the number and size of frame images, and frame animation can be implemented simply and efficiently, and the playback limit is small. After that, the user can use the custom frame animation playback control in the interface layout file, and call the frame animation playback and stop method provided by the custom control in the program code, and the number of unrestricted frames can be easily realized. , the size of the smooth play.
基于同一方面构思,参考图4,本发明实施例还提供了一种帧动画实现装置,包括:Based on the same aspect, referring to FIG. 4, an embodiment of the present invention further provides a frame animation implementation apparatus, including:
获取模块401,用于获取多个帧图片;An obtaining module 401, configured to acquire multiple frame images;
参数确定模块402,用于确定上述多个帧图片的属性信息和索引信息;The parameter determining module 402 is configured to determine attribute information and index information of the plurality of frame pictures.
生成模块403,用于根据所述属性信息和索引信息,将多个所述帧图片打包生成帧动画文件。The generating module 403 is configured to package the plurality of the frame pictures to generate a frame animation file according to the attribute information and the index information.
在本发明的实施例中,为了实现动画文件的播放,上述帧动画实现装置还可以进一步包括:播放模块404,用于调用预设的帧动画播放控件读取所述帧动画文件并播放帧动画。In an embodiment of the present invention, the frame animation implementation apparatus may further include: a playing module 404, configured to call a preset frame animation playing control to read the frame animation file and play a frame animation, in order to implement the playing of the animation file. .
在本发明的一个实施例中,上述获取模块401可具体包括:In an embodiment of the present invention, the obtaining module 401 may specifically include:
属性设置单元,用于设置上述多个帧图片的属性,使多个所述帧图片的宽度、高度和后缀名均相同。And an attribute setting unit, configured to set an attribute of the plurality of frame pictures, so that the width, the height, and the suffix name of the plurality of the frame pictures are the same.
重命名单元,用于根据播放顺序将多个所述帧图片进行重命名,使所述帧图片的文件名与其播放顺序相关联。a renaming unit, configured to rename a plurality of the frame pictures according to a play order, so that a file name of the frame picture is associated with a play order thereof.
在本发明的实施例中,上述帧图片的属性信息包括:多个帧图片的总帧数,以及每个帧图片的宽度、高度和后缀名。上述帧图片的索引信息包括:每个帧图片的播放顺序。在获取了多个帧图片之后,上述参数确定模 块402还将获取这些帧图片的属性信息和索引信息。In an embodiment of the present invention, the attribute information of the frame picture includes: a total number of frames of the plurality of frame pictures, and a width, a height, and a suffix name of each frame picture. The index information of the frame picture includes: a play order of each frame picture. After acquiring a plurality of frame pictures, the parameter determination module 402 further acquires attribute information and index information of the frame pictures.
在本发明的一个实施例中,上述生成模块403具体可以包括:In an embodiment of the present invention, the generating module 403 may specifically include:
信息读取单元,用于读取所述属性信息和索引信息并保存;An information reading unit, configured to read the attribute information and the index information and save the information;
文件创建单元,用于创建一个帧动画文件;a file creation unit for creating a frame animation file;
信息写入单元,用于在创建的帧动画文件中写入多个所述帧图片的总帧数,以及每个所述帧图片的宽度、高度;An information writing unit, configured to write a total number of frames of the plurality of frame images in the created frame animation file, and a width and a height of each of the frame images;
缓存申请单元,用于申请容量为上述多个帧图片的总帧数四倍大小的缓冲区并写入所述帧动画文件;a buffer application unit, configured to apply a buffer having a capacity of four times the total number of frames of the plurality of frame pictures and write the frame animation file;
帧图片写入单元,用于循环读取上述多个帧图片并根据播放顺序将上述多个帧图片写入所述帧动画文件,将多个所述帧图片在所述空帧动画文件中的偏移记录到对应的缓冲区;回写缓冲区;以及关闭所述帧动画文件。a frame picture writing unit, configured to cyclically read the plurality of frame pictures and write the plurality of frame pictures to the frame animation file according to a play order, and to use the plurality of frame pictures in the empty frame animation file The offset is recorded to the corresponding buffer; the write buffer is written back; and the frame animation file is closed.
在本发明的一个实施例中,上述生成模块403还进一步包括:存储单元,用于将所述帧动画文件存储至安卓系统的/res/raw/目录下。In an embodiment of the present invention, the generating module 403 further includes: a storage unit, configured to store the frame animation file in an /res/raw/ directory of the Android system.
在本发明的一个可选的实施例中,上述预设的帧动画播放控件为FrameAnimationView。在这种情况下,上述播放模块404可以具体包括:In an optional embodiment of the present invention, the preset frame animation playing control is a FrameAnimationView. In this case, the foregoing playing module 404 may specifically include:
信息确定单元,用于读取帧动画文件,获取属性信息和索引信息;An information determining unit, configured to read a frame animation file, and obtain attribute information and index information;
缓存申请单元,用于根据属性信息,为当前播放的帧图片申请缓冲区;a cache application unit, configured to apply for a buffer for the currently played frame image according to the attribute information;
帧图片读取单元,用于根据索引信息,读取当前播放的帧图片到缓冲区;a frame picture reading unit, configured to read the currently played frame picture to the buffer according to the index information;
解码单元,用于解码所述缓冲区,生成与所述帧图片对应的预设格式的当前播放图片;以及a decoding unit, configured to decode the buffer, and generate a current play picture in a preset format corresponding to the frame picture;
渲染单元,用于获取所述当前播放图片,将所述当前播放图片渲染至用户界面进行播放。And a rendering unit, configured to acquire the current play picture, and render the current play picture to a user interface for playing.
在本发明的实施例中,上述预设格式可以为Bitmap格式。In an embodiment of the present invention, the foregoing preset format may be a Bitmap format.
上述实施例的装置用于实现前述实施例中相应的帧动画实现方法,并且具有相应的方法实施例的有益效果,在此不再赘述。The device of the foregoing embodiment is used to implement the corresponding frame animation implementation method in the foregoing embodiment, and has the beneficial effects of the corresponding method embodiments, and details are not described herein again.
基于同一方面构思,本发明实施例还提供了一种电子设备,其结构如图5所示,包括存储器501、处理器502;存储器501和处理器502通过总线连接;存储器上存储有可在处理器上运行的计算机程序503,所述处理器执行所述程序时实现如上述任意一实施例所述的帧动画实现方法。Based on the same aspect, an embodiment of the present invention further provides an electronic device, which is configured as shown in FIG. 5, and includes a memory 501 and a processor 502. The memory 501 and the processor 502 are connected by a bus; and the memory is stored and processed. The computer program 503 running on the device, when the processor executes the program, implements a frame animation implementation method as described in any of the above embodiments.
上述实施例的电子设备用于实现前述实施例中相应的方法,并且具有相应的方法实施例的有益效果,在此不再赘述。The electronic device of the foregoing embodiment is used to implement the corresponding method in the foregoing embodiments, and has the beneficial effects of the corresponding method embodiments, and details are not described herein again.
基于同一方面构思,本发明实施例还提供了一种计算机可读存储介质,其上存储有计算机指令,在处理器执行上述计算机指令时实现如上述任意一实施例所述的帧动画实现方法。Based on the same aspect, the embodiment of the present invention further provides a computer readable storage medium, where computer instructions are stored, and when the processor executes the computer instruction, the frame animation implementation method according to any one of the foregoing embodiments is implemented.
所属领域的普通技术人员应当理解:以上任何实施例的讨论仅为示例性的,并非旨在暗示本公开的范围(包括权利要求)被限于这些例子;在本发明的思路下,以上实施例或者不同实施例中的技术特征之间也可以进行组合,步骤可以以任意顺序实现,并存在如上所述的本发明的不同方面的许多其它变化,为了简明它们没有在细节中提供。It should be understood by those of ordinary skill in the art that the discussion of any of the above embodiments is merely exemplary, and is not intended to suggest that the scope of the disclosure (including the claims) is limited to these examples; Combinations of the technical features in the different embodiments can also be combined, the steps can be carried out in any order, and there are many other variations of the various aspects of the invention as described above, which are not provided in detail for the sake of brevity.
另外,为简化说明和讨论,并且为了不会使本发明难以理解,在所提供的附图中可以示出或可以不示出与集成电路(IC)芯片和其它部件的公知的电源/接地连接。此外,可以以框图的形式示出装置,以便避免使本发明难以理解,并且这也考虑了以下事实,即关于这些框图装置的实施方式的细节是高度取决于将要实施本发明的平台的(即,这些细节应当完全处于本领域技术人员的理解范围内)。在阐述了具体细节(例如,电路)以描述本发明的示例性实施例的情况下,对本领域技术人员来说显而易见的是,可以在没有这些具体细节的情况下或者这些具体细节有变化的情况下实施本发明。因此,这些描述应被认为是说明性的而不是限制性的。In addition, well-known power/ground connections to integrated circuit (IC) chips and other components may or may not be shown in the drawings provided for simplicity of illustration and discussion, and in order not to obscure the invention. . Furthermore, the apparatus may be shown in block diagram form in order to avoid obscuring the invention, and this also contemplates the fact that the details of the embodiments of the block diagram apparatus are highly dependent on the platform on which the invention is to be implemented (ie These details should be fully understood by those skilled in the art). In the case where the specific details (e.g., circuits) are described to describe the exemplary embodiments of the present invention, it will be apparent to those skilled in the art The invention is carried out as follows. Accordingly, the description is to be considered as illustrative rather than restrictive.
尽管已经结合了本发明的具体实施例对本发明进行了描述,但是根据前面的描述,这些实施例的很多替换、修改和变型对本领域普通技术人员来说将是显而易见的。例如,其它存储器架构(例如,动态RAM(DRAM))可以使用所讨论的实施例。Although the present invention has been described in connection with the specific embodiments of the present invention, many modifications, variations and variations of the embodiments are apparent to those skilled in the art. For example, other memory architectures (eg, dynamic RAM (DRAM)) may use the embodiments discussed.
本发明的实施例旨在涵盖落入所附权利要求的宽泛范围之内的所有这样的替换、修改和变型。因此,凡在本发明的精神和原则之内,所做的任何省略、修改、等同替换、改进等,均应包含在本发明的保护范围之内。All such alternatives, modifications, and variations are intended to be included within the scope of the appended claims. Therefore, any omissions, modifications, equivalents, improvements, etc., which are within the spirit and scope of the invention, are intended to be included within the scope of the invention.

Claims (17)

  1. 一种帧动画实现方法,其特征在于,包括:A frame animation implementation method, comprising:
    获取多个帧图片;Get multiple frame images;
    确定所述多个帧图片的属性信息和索引信息;以及Determining attribute information and index information of the plurality of frame pictures;
    根据所述属性信息和索引信息,将所述多个帧图片打包生成帧动画文件。And encoding the plurality of frame pictures according to the attribute information and the index information to generate a frame animation file.
  2. 根据权利要求1所述的帧动画实现方法,其特征在于,所述获取多个帧图片包括:从指定位置获取所述多个帧图片。The frame animation implementation method according to claim 1, wherein the acquiring the plurality of frame images comprises: acquiring the plurality of frame images from a specified location.
  3. 根据权利要求2所述的帧动画实现方法,其特征在于,所述获取多个帧图片进一步包括:设置所述多个帧图片的属性,使所述多个帧图片的宽度、高度和后缀名相同。The frame animation implementation method according to claim 2, wherein the acquiring the plurality of frame images further comprises: setting an attribute of the plurality of frame images, and making a width, a height, and a suffix name of the plurality of frame images the same.
  4. 根据权利要求2或3所述的帧动画实现方法,其特征在于,所述获取多个帧图片进一步包括:根据播放顺序将所述多个帧图片进行重命名,使所述多个帧图片的文件名与其播放顺序相关联。The frame animation implementation method according to claim 2 or 3, wherein the acquiring the plurality of frame images further comprises: renaming the plurality of frame images according to a play order, and causing the plurality of frame images The file name is associated with its play order.
  5. 根据权利要求1所述的帧动画实现方法,其特征在于,所述将多个帧图片打包生成帧动画文件包括:The frame animation implementation method according to claim 1, wherein the packaging the plurality of frame images to generate a frame animation file comprises:
    读取所述属性信息和索引信息并保存;其中,所述属性信息包括:所述多个帧图片的总帧数,以及所述多个帧图片中每个帧图片的宽度、高度和后缀名;所述索引信息包括:所述多个帧图片中每个帧图片的播放顺序;And reading the attribute information and the index information, where the attribute information includes: a total number of frames of the plurality of frame pictures, and a width, a height, and a suffix name of each of the plurality of frame pictures The index information includes: a play order of each frame picture in the plurality of frame pictures;
    创建一个帧动画文件;Create a frame animation file;
    在所述帧动画文件中写入多个所述帧图片的总帧数,以及所述多个帧图片中每个所述帧图片的宽度、高度;Writing a total number of frames of the plurality of frame pictures in the frame animation file, and a width and a height of each of the plurality of frame pictures;
    申请容量为所述多个帧图片的总帧数四倍大小的缓冲区并写入所述帧动画文件;Applying a buffer having a capacity four times the total number of frames of the plurality of frame pictures and writing the frame animation file;
    循环读取多个所述帧图片并根据播放顺序写入所述帧动画文件,将多个所述帧图片在所述空帧动画文件中的偏移记录到对应的缓冲区;And cyclically reading a plurality of the frame images and writing the frame animation files according to a play order, and recording offsets of the plurality of frame images in the empty frame animation file into corresponding buffers;
    回写缓冲区;以及Write back to the buffer;
    关闭所述帧动画文件。Close the frame animation file.
  6. 根据权利要求1所述的帧动画实现方法,其特征在于,所述将多个所述帧图片打包生成帧动画文件之后,所述方法进一步包括:将所述帧动 画文件存储至安卓系统的/res/raw/目录下。The frame animation implementation method according to claim 1, wherein after the plurality of the frame pictures are packaged to generate a frame animation file, the method further comprises: storing the frame animation file to an Android system/ Res/raw/ directory.
  7. 根据权利要求1所述的帧动画实现方法,其特征在于,所述方法进一步包括:调用预设的帧动画播放控件读取所述帧动画文件并播放帧动画。The frame animation implementation method according to claim 1, wherein the method further comprises: calling a preset frame animation playback control to read the frame animation file and playing the frame animation.
  8. 根据权利要求7所述的帧动画实现方法,其特征在于,所述预设的帧动画播放控件为FrameAnimationView。The frame animation implementation method according to claim 7, wherein the preset frame animation playback control is a FrameAnimationView.
  9. 根据权利要求8所述的帧动画实现方法,其特征在于,所述调用预设的帧动画播放控件读取所述帧动画文件并播放帧动画包括:The frame animation implementation method according to claim 8, wherein the calling the preset frame animation playing control to read the frame animation file and playing the frame animation comprises:
    读取所述帧动画文件,获取所述属性信息和索引信息;Reading the frame animation file to obtain the attribute information and index information;
    根据所述属性信息,为当前播放的所述帧图片申请缓冲区;And applying, according to the attribute information, a buffer for the currently played frame image;
    根据所述索引信息,读取当前播放的所述帧图片到所述缓冲区;Reading the currently played frame picture to the buffer according to the index information;
    解码所述缓冲区,生成与所述帧图片对应的预设格式的当前播放图片;Decoding the buffer to generate a current play picture in a preset format corresponding to the frame picture;
    获取所述当前播放图片,将所述当前播放图片渲染至用户界面进行播放。Obtaining the current play picture, and rendering the current play picture to a user interface for playing.
  10. 一种帧动画实现装置,其特征在于,包括:A frame animation implementation device, comprising:
    获取模块,用于获取多个帧图片;An acquisition module, configured to acquire multiple frame images;
    参数确定模块,用于确定上述多个帧图片的属性信息和索引信息;以及a parameter determining module, configured to determine attribute information and index information of the plurality of frame pictures; and
    生成模块,用于根据所述属性信息和索引信息,将多个所述帧图片打包生成帧动画文件。And a generating module, configured to package the plurality of the frame images to generate a frame animation file according to the attribute information and the index information.
  11. 根据权利要求10所述的帧动画实现装置,其特征在于,所述获取模块包括:The frame animation implementation apparatus according to claim 10, wherein the obtaining module comprises:
    属性设置单元,用于设置上述多个帧图片的属性,使多个所述帧图片的宽度、高度和后缀名均相同;An attribute setting unit, configured to set an attribute of the plurality of frame pictures, so that a width, a height, and a suffix name of the plurality of the frame pictures are the same;
    重命名单元,用于根据播放顺序将多个所述帧图片进行重命名,使所述帧图片的文件名与其播放顺序相关联。a renaming unit, configured to rename a plurality of the frame pictures according to a play order, so that a file name of the frame picture is associated with a play order thereof.
  12. 根据权利要求10所述的帧动画实现装置,其特征在于,所述生成模块包括:The frame animation implementation apparatus according to claim 10, wherein the generating module comprises:
    信息读取单元,用于读取所述属性信息和索引信息并保存;An information reading unit, configured to read the attribute information and the index information and save the information;
    文件创建单元,用于创建一个帧动画文件;a file creation unit for creating a frame animation file;
    信息写入单元,用于在创建的帧动画文件中写入多个所述帧图片的总帧数,以及每个所述帧图片的宽度、高度;An information writing unit, configured to write a total number of frames of the plurality of frame images in the created frame animation file, and a width and a height of each of the frame images;
    缓存申请单元,用于申请容量为上述多个帧图片的总帧数四倍大小的缓冲区并写入所述帧动画文件;a buffer application unit, configured to apply a buffer having a capacity of four times the total number of frames of the plurality of frame pictures and write the frame animation file;
    帧图片写入单元,用于循环读取上述多个帧图片并根据播放顺序将上述多个帧图片写入所述帧动画文件,将多个所述帧图片在所述空帧动画文件中的偏移记录到对应的缓冲区;回写缓冲区;以及关闭所述帧动画文件。a frame picture writing unit, configured to cyclically read the plurality of frame pictures and write the plurality of frame pictures to the frame animation file according to a play order, and to use the plurality of frame pictures in the empty frame animation file The offset is recorded to the corresponding buffer; the write buffer is written back; and the frame animation file is closed.
  13. 根据权利要求12所述的帧动画实现装置,其特征在于,所述生成模块进一步包括:存储单元,用于将所述帧动画文件存储至安卓系统的/res/raw/目录下。The frame animation implementation apparatus according to claim 12, wherein the generating module further comprises: a storage unit, configured to store the frame animation file in a /res/raw/ directory of the Android system.
  14. 根据权利要求10所述的帧动画实现装置,其特征在于,所述帧动画实现装置进一步包括:播放模块,用于调用预设的帧动画播放控件读取所述帧动画文件,播放帧动画。The frame animation implementing apparatus according to claim 10, wherein the frame animation implementing device further comprises: a playing module, configured to call the preset frame animation playing control to read the frame animation file, and play the frame animation.
  15. 根据权利要求14所述的帧动画实现装置,其特征在于,所述播放模块包括:The frame animation implementation apparatus according to claim 14, wherein the playing module comprises:
    信息确定单元,用于读取帧动画文件,获取属性信息和索引信息;An information determining unit, configured to read a frame animation file, and obtain attribute information and index information;
    缓存申请单元,用于根据属性信息,为当前播放的帧图片申请缓冲区;a cache application unit, configured to apply for a buffer for the currently played frame image according to the attribute information;
    帧图片读取单元,用于根据索引信息,读取当前播放的帧图片到缓冲区;a frame picture reading unit, configured to read the currently played frame picture to the buffer according to the index information;
    解码单元,用于解码所述缓冲区,生成与所述帧图片对应的预设格式的当前播放图片;以及a decoding unit, configured to decode the buffer, and generate a current play picture in a preset format corresponding to the frame picture;
    渲染单元,用于获取所述当前播放图片,将所述当前播放图片渲染至用户界面进行播放。And a rendering unit, configured to acquire the current play picture, and render the current play picture to a user interface for playing.
  16. 一种电子设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,其特征在于,所述处理器执行所述程序时实现如权利要求1至9任意一项所述的帧动画实现方法。An electronic device comprising a memory, a processor, and a computer program stored on the memory and operable on the processor, wherein the processor executes the program as claimed in any one of claims 1 to The frame animation implementation method described.
  17. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如权利要求1至9任意一项所述的帧动画实现方法。A computer readable storage medium, characterized in that the computer readable storage medium stores a computer program, and when the computer program is executed by a processor, the frame animation implementation according to any one of claims 1 to 9 is implemented method.
PCT/CN2019/085854 2018-05-09 2019-05-07 Frame animation realization method and apparatus, electronic device and computer-readable storage medium WO2019214615A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810438908.9A CN110473275B (en) 2018-05-09 2018-05-09 Frame animation realization method and device under android system and electronic equipment
CN201810438908.9 2018-05-09

Publications (1)

Publication Number Publication Date
WO2019214615A1 true WO2019214615A1 (en) 2019-11-14

Family

ID=68467815

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/085854 WO2019214615A1 (en) 2018-05-09 2019-05-07 Frame animation realization method and apparatus, electronic device and computer-readable storage medium

Country Status (2)

Country Link
CN (1) CN110473275B (en)
WO (1) WO2019214615A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110473275A (en) * 2018-05-09 2019-11-19 鸿合科技股份有限公司 Frame animation realization, device, electronic equipment under a kind of Android system
CN112905283A (en) * 2021-02-23 2021-06-04 深圳市迅雷网络技术有限公司 Special effect animation playing method, device and system, computer equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9349204B1 (en) * 2015-08-07 2016-05-24 House Of Moves, Inc. Systems and methods for generating videos using animation and motion capture scene information
CN105657574A (en) * 2014-11-12 2016-06-08 阿里巴巴集团控股有限公司 Video file making method and device
CN107204024A (en) * 2016-03-16 2017-09-26 腾讯科技(深圳)有限公司 Handle the method and device of sequence of pictures frame

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH07325934A (en) * 1992-07-10 1995-12-12 Walt Disney Co:The Method and equipment for provision of graphics enhanced to virtual world
JPH07129364A (en) * 1993-10-28 1995-05-19 Mitsubishi Electric Corp Device for retriving common picture information indication
JP2006325082A (en) * 2005-05-20 2006-11-30 Canopus Co Ltd Animation data edit apparatus and method
JP4566821B2 (en) * 2005-05-20 2010-10-20 トムソン・カノープス株式会社 Apparatus having moving picture data playing function, moving picture playing program, and moving picture data playing method
CN100514992C (en) * 2007-03-30 2009-07-15 中国联合网络通信集团有限公司 Method for processing mobile-terminal frame carboon
CN103544048A (en) * 2013-10-31 2014-01-29 Tcl集团股份有限公司 Boot animation display method of Android system and system comprising same
CN104123742A (en) * 2014-07-21 2014-10-29 徐才 Method and player for translating static cartoon picture into two dimensional animation
US20160275108A1 (en) * 2015-02-09 2016-09-22 Jonathan Mark Sidener Producing Multi-Author Animation and Multimedia Using Metadata
CN104811799B (en) * 2015-04-29 2018-08-07 北京奇艺世纪科技有限公司 A kind of video image quality comparative approach and device
CN115908644A (en) * 2016-12-22 2023-04-04 广州方硅信息技术有限公司 Animation processing method and device
CN110473275B (en) * 2018-05-09 2023-05-30 鸿合科技股份有限公司 Frame animation realization method and device under android system and electronic equipment

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105657574A (en) * 2014-11-12 2016-06-08 阿里巴巴集团控股有限公司 Video file making method and device
US9349204B1 (en) * 2015-08-07 2016-05-24 House Of Moves, Inc. Systems and methods for generating videos using animation and motion capture scene information
CN107204024A (en) * 2016-03-16 2017-09-26 腾讯科技(深圳)有限公司 Handle the method and device of sequence of pictures frame

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110473275A (en) * 2018-05-09 2019-11-19 鸿合科技股份有限公司 Frame animation realization, device, electronic equipment under a kind of Android system
CN112905283A (en) * 2021-02-23 2021-06-04 深圳市迅雷网络技术有限公司 Special effect animation playing method, device and system, computer equipment and storage medium

Also Published As

Publication number Publication date
CN110473275B (en) 2023-05-30
CN110473275A (en) 2019-11-19

Similar Documents

Publication Publication Date Title
CN109194960B (en) Image frame rendering method and device and electronic equipment
WO2017124811A1 (en) Data drawing method and apparatus, terminal and storage medium
KR102131322B1 (en) Computing device, method, computer program for processing video
WO2019214615A1 (en) Frame animation realization method and apparatus, electronic device and computer-readable storage medium
CN108549562A (en) A kind of method and device of image load
US9137428B2 (en) Storyboards for capturing images
US9396575B2 (en) Animation via pin that defines multiple key frames
WO2017157042A1 (en) Display method and apparatus for task execution progress, and client
KR20180019158A (en) METHOD AND DEVICE FOR PREVIEWING A DYNAMIC IMAGE, AND METHOD AND DEVICE FOR DISPLAYING A DISPLAY PACKAGE
CN112055254B (en) Video playing method, device, terminal and storage medium
CN109788212A (en) A kind of processing method of segmenting video, device, terminal and storage medium
US11941728B2 (en) Previewing method and apparatus for effect application, and device, and storage medium
Van Every Pro Android Media: Developing Graphics, Music, Video, and Rich Media Apps for Smartphones and Tablets
WO2017080241A1 (en) Time-lapse photographing method and device
CN110727825A (en) Animation playing control method, device, server and storage medium
CN111309424B (en) Page restoration method and related equipment
KR20190020039A (en) Method and apparatus for decoding a variable length coded file
WO2019062615A1 (en) User interface rendering method and apparatus
WO2018076710A1 (en) Method and device for smart photographing and storage medium
JP4878054B2 (en) Video analysis apparatus, video analysis method, and video analysis program
US20140193083A1 (en) Method and apparatus for determining the relationship of an image to a set of images
CN114331808A (en) Action posture storage method, device, medium and electronic equipment
CN111131707B (en) Shooting method and device based on raspberry pie
CN112311961A (en) Method and device for setting lens in short video
KR101698484B1 (en) Method and apparatus for performing JAVA application

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19800097

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19800097

Country of ref document: EP

Kind code of ref document: A1