The content of the invention
In order to solve the above-mentioned problems in the prior art, the present invention propose a kind of frame animation loading accelerated method and
Device.
According to an aspect of the invention, it is proposed that a kind of frame animation loads accelerated method.The method includes:
All frame pictures in original frame animation are synthesized by least one composite diagram by edit tool, and derives all frame figures
Pictorial information file of the piece in composite diagram;
The thread of respective amount is created in the number of composite diagram in Natvie end groups, and by each composite diagram in corresponding line
It is loaded into internal memory in journey;
Read pictorial information file, based on the information for being read, according in the original frame animation all frame pictures it is suitable
Sequence, the every frame picture in each composite diagram being loaded into internal memory is associated one by one with the position in internal memory;
In the newly-built frame animation example in Java ends, the position in internal memory according to associated by every frame picture is by the number of every frame picture
According to being added in the frame animation example;
The frame animation example is carried out into the broadcasting of animation.
Preferably, the information of the pictorial information file includes positions and dimensions of every frame picture in composite diagram, is used for
Every frame picture is indexed in the composite diagram.
Preferably, it is described during all frame picture synthesis at least composite diagrams, to be grouped each frame figure in original frame animation
Piece is synthesized respectively, makes the difference in size between each composite diagram be less than predetermined value.
Preferably, described when each composite diagram is loaded into internal memory in corresponding thread, the composite diagram is with byte number
The form of group is stored.
According to another aspect of the invention, it is proposed that a kind of frame animation loads accelerator.The device includes:
Pretreatment unit, at least one composite diagram is synthesized by edit tool by all frame pictures in frame animation, and is derived
Pictorial information file of all frame pictures in composite diagram;
Loading unit, in Natvie end groups the thread of respective amount is created in the number of composite diagram, and by each composite diagram
It is loaded into internal memory in corresponding thread;
Associative cell, reads pictorial information file, based on the information for being read, according to all frames in the original frame animation
The order of picture, the every frame picture in each composite diagram being loaded into internal memory is associated one by one with the position in internal memory;
Example creating unit, in the newly-built frame animation example in Java ends, the position in internal memory according to associated by every frame picture
The data of every frame picture are added in the frame animation example;
Broadcast unit, by the frame animation example broadcasting of animation is carried out.
Preferably, the information of the pictorial information file includes positions and dimensions of every frame picture in composite diagram, is used for
Every frame picture is indexed in the composite diagram.
Preferably, it is described during all frame picture synthesis at least composite diagrams, to be grouped each frame figure in original frame animation
Piece is synthesized respectively, makes the difference in size between each composite diagram be less than predetermined value.
Preferably, described when each composite diagram is loaded into internal memory in corresponding thread, the composite diagram is with byte number
The form of group is stored.
Pretreatment mode by being synthesized to all pictures in original frame animation of the invention, and loaded using multithreading
The accelerated loading to frame animation picture is realized, so as to the time of frame animation is greatly shortened;Simultaneously because at Native ends
Picture loading procedure is realized, reduces the risk that internal memory overflows in picture loading procedure.
The method of the present invention has other characteristics and advantage, these characteristics and advantage from the accompanying drawing being incorporated herein and with
Will be apparent in specific embodiment afterwards, or will enter in the accompanying drawing being incorporated herein and subsequent specific embodiment
Row statement in detail, these the drawings and specific embodiments are provided commonly for explaining the certain principles of the present invention.
Specific embodiment
The present invention is more fully described below with reference to accompanying drawings.Although showing the preferred embodiments of the present invention in accompanying drawing,
However, it is to be appreciated that may be realized in various forms the present invention and should not be limited by embodiments set forth here.
Fig. 1 shows that frame animation according to an embodiment of the invention loads the flow chart of accelerated method.
In this embodiment, frame animation loading accelerated method is comprised the following steps:
(1) all frame pictures in frame animation are synthesized by least one composite diagram by edit tool, and derives all frame figures
Pictorial information file of the piece in composite diagram.
For the frame animation with many picture frames, in order to reduce the number of times for reading picture, all frame pictures are carried out first
Pretreatment.The quantity for reducing picture why is needed, is to reduce the secondary of the context switching of picture loading during software is realized
Number.
In the present embodiment, all frame pictures in frame animation are pre-processed, formed composite diagram and corresponding picture letter
Breath file after, upload onto the server end, then in subsequent step by terminal establishment thread after loaded.
The pretreatment carries out in the frame picture of certain amount by edit tool to be spliced to form a composite diagram, so as to
All frame pictures in frame animation are synthesized at least one composite diagram.
Thread is concurrent, and (i.e. multiple tasks, i.e. thread are more to process simultaneously for multi-threading) may, and processing simultaneously for task is got over
Many, the picture that can be read simultaneously in the present embodiment is more.But thread is more, also simultaneously concurrent capability can be caused to decline,
Obtain less than enough run times so as to there is each thread, thus block, lose more than gain.Thus, by composite diagram
Number be limited to reasonable number.This reasonable number realizes the consideration in thread quantity and performance balance and quilt for software
It is limited to not more than 3.
In the exemplary embodiment, it is described during all frame picture synthesis at least composite diagrams, to divide in original frame animation
Group is respectively synthesized each frame picture, makes the difference in size between each composite diagram be less than predetermined value.
For the consideration of the concurrent efficiency of thread, the equal of be spliced to form dimension of picture should be as far as possible ensured when picture splices
Weighing apparatus, that is, ensure to be smaller in size than predetermined value between each composite diagram.The predetermined value can determine according to actual needs.Such as mesh
Mark quantity is 3, then should try one's best and ensure that the size of this three pictures is Jie Jin consistent, it is to avoid the size between picture occurs
The king-sized situation of gap.In the splicing of picture, information of each picture frame in composite diagram should be recorded.
In the exemplary embodiment, edit tool is TexturePacker.
In the exemplary embodiment, the information of pictorial information file includes position and chi of each picture frame in composite diagram
It is very little, for every frame picture to be indexed in the composite diagram.Size of each picture frame in composite diagram be with pixel
Unit, position coordinates is also in units of pixel.
In the exemplary embodiment, pictorial information file is xml document.
It is below the example of pictorial information file of the two frame pictures in composite diagram:
Above parameter shows there are two frame pictures in the composite diagram for synthesizing, respectively pic1.png and pic2.png, wherein
The size of pic1.png is 1280*800, the position in composite diagram be top-left coordinates for (1,1), lower right coordinate for (1280,
800) rectangular area;The size of pic2.png is 1280*800, the position in composite diagram be top-left coordinates for (1,803),
Lower right coordinate is the rectangular area of (1280,800).
(2) thread of respective amount is created in the number of composite diagram in Natvie end groups, and by each composite diagram in correspondence
Thread in be loaded into internal memory.
It is the realization of software after pretreatment is completed, carries out at Java ends and Native ends respectively, can be with C/C++ realities
It is existing.
At least one composite diagram is synthesized in pretreatment stage, then identical number has been created at Native ends in software implementation phase
The thread of amount, and while being read corresponding composite diagram to be loaded into internal memory in each thread in.
Pictorial information is obtained, data flow is created, data is read internal memory, closed data flow, this whole reading with bytewise
Taking flow process has process to consume, if the picture to be loaded is excessive, many time all consumes the standard read in data flow
Standby and ending phase, the time being actually written and read is not long.And pass through to synthesize a limited number of composite diagram, reduce picture number
Amount, so as to have compressed the time for reading the preparatory stage.
Picture loading procedure is realized at Native ends, because Native codes are performed in primary space, and Java is not take up
, without the restriction that internal memory is used, will not easily there is the risk of internal memory benefit in end virutal machine memory.
In the exemplary embodiment, it is described when each composite diagram is loaded into internal memory in corresponding thread, the synthesis
Figure is stored in the form of byte arrays.Preferably, each pixel of composite diagram uses 4 byte representations.
For example, in above-mentioned example pictorial information file, data of the pic1.png in byte arrays be exactly upper left (1,1)
With the array region of bottom right (1280*4,800*4).
(3) pictorial information file is read, based on the information for being read, according to all frame pictures in the original frame animation
Order one by one associates the every frame picture in each composite diagram being loaded into internal memory with the position in internal memory.
Position of the composite diagram loaded in each thread in internal memory is random, if directly reading each composite diagram
In frame picture, then it with the order of all frame pictures in raw animation is being not necessarily sequentially consistent, it is therefore desirable to will
Every frame picture in already loaded into each composite diagram in internal memory is associated one by one with the position in internal memory.In associated
The sequence of positions deposited is consistent with putting in order for all frame pictures in raw animation, that is, realize in composite diagram per frame figure
The reduction of position of the piece in internal memory, puts in order by this and realizes the follow-up display per two field picture.
(4) in the newly-built frame animation example in Java ends, the position in internal memory according to associated by every frame picture will be per frame picture
Data be added in the frame animation example.
In the newly-built frame animation example in Java ends, newly-built frame animation example is, for example, AnimationDrawable,
AnimationDrawable is the basic class for realizing frame animation, for managing frame animation in each frame.Reducing composite diagram
In per behind position of the frame picture in internal memory, the position in internal memory according to associated by every frame picture adds the data of every frame picture
Enter in the frame animation example.
(5) the frame animation example is passed in terminal device, is currently displayed at the view class of screen to carry out animation
Broadcasting.
The view class for being displayed in screen is View, calls the broadcasting of the i.e. achievable animation of start () method of frame animation example.
According to another embodiment of the present invention, there is provided a kind of frame animation loads accelerator.
The device can include:
Pretreatment unit, at least one composite diagram is synthesized by edit tool by all frame pictures in frame animation, and is derived
Pictorial information file of all frame pictures in composite diagram;
Loading unit, in Natvie end groups the thread of respective amount is created in the number of composite diagram, and by each composite diagram
It is loaded into internal memory in corresponding thread;
Associative cell, reads pictorial information file, based on the information for being read, according to all frames in the original frame animation
The order of picture, the every frame picture in each composite diagram being loaded into internal memory is associated one by one with the position in internal memory;
Example creating unit, in the newly-built frame animation example in Java ends, the position in internal memory according to associated by every frame picture
The data of every frame picture are added in the frame animation example;
Broadcast unit, by the frame animation example broadcasting of animation is carried out.
In one example, the information of the pictorial information file includes position and chi of every frame picture in composite diagram
It is very little, for every frame picture to be indexed in the composite diagram.
In one example, it is described by during all frame picture synthesis at least composite diagrams, packet will in original frame animation
Each frame picture is synthesized respectively, makes the difference in size between each composite diagram be less than predetermined value.
In one example, it is described when each composite diagram is loaded into internal memory in corresponding thread, the composite diagram with
The form of byte arrays is stored.
Using example
For ease of understanding the scheme and its effect of the embodiment of the present invention, a concrete application example given below.This area
It should be understood to the one skilled in the art that the example is only for the purposes of understanding the present invention, its any detail is not intended to limit by any way
The system present invention.
Fig. 2 a- Fig. 2 l show 12 frame pictures, are followed successively by pic1, pic2, pic3, pic4, pic5, pic6, pic7,
pic8,pic9,pic10,pic11,pic12。
The frame animation being made up of this 12 frame pictures is carried out by following steps load acceleration process.
Step 1:Picture is pre-processed, 12 frame picture pic1-pic12 that will be as shown in Fig. 2 a- Fig. 2 l synthesize
Three composite diagrams, every composite diagram includes 4 frame pictures.As shown in Fig. 3 a- Fig. 3 c, synthesis Fig. 1 includes pic1-pic4, synthesis
Fig. 2 includes that pic5-pic8, synthesis Fig. 3 include pic9-pic12.And derive the picture file information of this three composite diagrams;In advance
Upload onto the server to hold after being disposed and be downloaded for terminal.
The pictorial information of synthesis Fig. 1,2,3 is as follows:
Synthesis Fig. 1:
Synthesis Fig. 2:
Synthesis Fig. 3:
Step 2:Synthesis Fig. 1,2,3 are downloaded in mobile phone terminal, and 3 threads are created at Native ends, respectively in corresponding line
Synthesis Fig. 1,2,3 are loaded into internal memory in journey;
Step 3:Pictorial information file is read, based on the information for being read, according to all frame pictures in original frame animation
Order one by one associates the every frame picture in each composite diagram being loaded into internal memory with the position in internal memory, including coordinate and chi
Correspondence on very little;
Step 4:Newly-built frame animation example AnimationDrawable, the position in internal memory according to associated by every frame picture
Put and the data of every frame picture are added in the frame animation example;
Step 5:The example is passed to view class View for being currently displayed at screen, by calling frame animation example
Start () carrys out playing animation, frame animation is shown on mobile phone screen.
It will be understood by those skilled in the art that above to the purpose of the description of embodiments of the invention only for exemplarily saying
The beneficial effect of bright embodiments of the invention, is not intended to limit embodiments of the invention to given any example.
The present invention can be device, method and/or computer program.Computer program can include computer
Readable storage medium storing program for executing, containing the computer-readable program instructions for being used to make processor realize various aspects of the invention.
Computer-readable recording medium can be the tangible of the instruction that holding and storage are used by instruction execution equipment
Equipment.Computer-readable recording medium for example can be-- but be not limited to-- storage device electric, magnetic storage apparatus, optical storage
Equipment, electromagnetism storage device, semiconductor memory apparatus or above-mentioned any appropriate combination.Computer-readable recording medium
More specifically example (non exhaustive list) includes:Portable computer diskette, hard disk, random access memory (RAM), read-only deposit
It is reservoir (ROM), erasable programmable read only memory (EPROM or flash memory), static RAM (SRAM), portable
Compact disk read-only storage (CD-ROM), digital versatile disc (DVD), memory stick, floppy disk, mechanical coding equipment, for example thereon
Be stored with instruction punch card or groove internal projection structure and above-mentioned any appropriate combination.Calculating used herein above
Machine readable storage medium storing program for executing is not construed as instantaneous signal itself, the electromagnetic wave of such as radio wave or other Free propagations, logical
Cross electromagnetic wave (for example, by the light pulse of fiber optic cables) that waveguide or other transmission mediums propagate or by wire transfer
Electric signal.
Computer-readable program instructions as described herein can from computer-readable recording medium download to each calculate/
Processing equipment, or outer computer or outer is downloaded to by network, such as internet, LAN, wide area network and/or wireless network
Portion's storage device.Network can include copper transmission cable, Optical Fiber Transmission, be wirelessly transferred, router, fire wall, switch, gateway
Computer and/or Edge Server.Adapter or network interface in each calculating/processing equipment is received from network and counted
Calculation machine readable program instructions, and forward the computer-readable program instructions, for being stored in each calculating/processing equipment in meter
In calculation machine readable storage medium storing program for executing.
For perform the present invention operation computer program instructions can be assembly instruction, instruction set architecture (ISA) instruction,
Machine instruction, machine-dependent instructions, microcode, firmware instructions, condition setup data or with one or more programming language
The source code write of any combination or object code, the programming language includes OO programming language-such as
Smalltalk, C++ etc., and the procedural programming languages of routine-such as " C " language or similar programming language.Computer
Readable program instructions can perform fully on the user computer, partly perform on the user computer, as one solely
Vertical software kit is performed, on the user computer part performs on the remote computer or completely in remote computer for part
Or perform on server.In the situation of remote computer is related to, remote computer can be by the network-bag of any kind
LAN (LAN) or wide area network (WAN)-be connected to subscriber computer are included, or, it may be connected to outer computer (such as profit
With ISP come by Internet connection).In certain embodiments, by using computer-readable program instructions
Status information carry out personalized customization electronic circuit, such as PLD, field programmable gate array (FPGA) or can
Programmed logic array (PLA) (PLA), the electronic circuit can perform computer-readable program instructions, so as to realize each side of the present invention
Face.
Referring herein to method according to embodiments of the present invention, device (system) and computer program flow chart and/
Or block diagram describes various aspects of the invention.It should be appreciated that each square frame and flow chart of flow chart and/or block diagram and/
Or in block diagram each square frame combination, can be realized by computer-readable program instructions.
These computer-readable program instructions can be supplied to all-purpose computer, special-purpose computer or other programmable datas
The processor of processing meanss, so as to produce a kind of machine so that these instructions are by computer or other programmable datas
During the computing device of processing meanss, flowchart is generated and/or work(specified in one or more square frames in block diagram
The device of energy/action.These computer-readable program instructions can also be stored in a computer-readable storage medium, these refer to
Order causes computer, programmable data processing unit and/or other equipment to work in a specific way, so as to be stored with instruction
Computer-readable medium then includes a manufacture, and it is included in flowchart and/or one or more square frames in block diagram
The instruction of the various aspects of the function/action of regulation.
Can also computer-readable program instructions be loaded into computer, other programmable data processing units or other
On equipment so that perform series of operation steps on computer, other programmable data processing units or miscellaneous equipment, to produce
The computer implemented process of life, so that perform on computer, other programmable data processing units or miscellaneous equipment
Function/action specified in one or more square frames in instruction flowchart and/or block diagram.
Flow chart and block diagram in accompanying drawing shows system, method and the computer journey of multiple embodiments of the invention
The architectural framework in the cards of sequence product, function and operation.At this point, each square frame in flow chart or block diagram can generation
A part for table one module, program segment or instruction a, part for the module, program segment or instruction is used comprising one or more
In the executable instruction of the logic function for realizing regulation.In some realizations as replacement, the function of being marked in square frame
Can be with different from the order marked in accompanying drawing generation.For example, two continuous square frames can essentially be held substantially in parallel
OK, they can also be performed in the opposite order sometimes, and this is depending on involved function.It is also noted that block diagram and/or
The combination of each square frame and block diagram and/or the square frame in flow chart in flow chart, can be with the function of performing regulation or dynamic
The special hardware based system made is realizing, or can be realized with the combination of computer instruction with specialized hardware.
It is described above various embodiments of the present invention, described above is exemplary, and non-exclusive, and
It is not limited to disclosed each embodiment.In the case of the scope and spirit without departing from illustrated each embodiment, for this skill
Many modifications and changes will be apparent from for the those of ordinary skill in art field.