Embodiment
For making the purpose, technical solutions and advantages of the present invention clearer, below in conjunction with embodiment and accompanying drawing, the present invention is described in further details.At this, exemplary embodiment of the present invention and explanation thereof be for explaining the present invention, but not as a limitation of the invention.
The embodiment of the present invention provides a kind of image converting method and device, and the present invention is described in detail below in conjunction with accompanying drawing.
Embodiment mono-
Fig. 1 is a kind of image converting method process flow diagram that the embodiment of the present invention provides, and as shown in Figure 1, described method comprises:
S101, obtain the format information of picture.
In embodiments of the present invention, when the application program in terminal need to load the picture of 9.png form, at first terminal will obtain the format information of the picture that will be loaded, so that the form of the picture that next step judgement will be loaded.
S102, judge according to described format information whether described picture is the 9.png form.
In embodiments of the present invention, whether terminal is the 9.png form according to the picture that the format information judgement that gets will be loaded, and format information can comprise suffix name, picture file length and the picture file the 38th, 39 of picture file, the information such as value of 40,41 bytes.
S103, if described picture is not the 9.png form, be converted to the 9.png form by described picture.
In embodiments of the present invention, if described picture is the 9.png form, application program can directly load the picture of 9.png form.If described picture is not the 9.png form, terminal need to first be converted to the 9.png form by picture, reloads afterwards the picture of 9.png form.
A kind of image converting method that the embodiment of the present invention provides, can automatic decision and the picture of non-9.PNG form is converted to the 9.PNG form, avoids program to occur loading not coming into force or situation that generating program is abnormal.
Fig. 2 is the process flow diagram of step S102 in Fig. 1 of providing of the embodiment of the present invention, and as shown in Figure 2, step S102 comprises:
S201, judge according to described format information whether described picture is the png form.
In embodiments of the present invention, at first terminal judges according to the format information of the picture that gets whether picture is the png form, preferably, format information can comprise suffix name, picture file length and the picture file the 38th, 39 of picture file, 40, at first the information such as value of 41 bytes, terminal can judge according to the suffix name of picture whether picture is the png form, if described picture is the png form, carry out step S203, continue to judge whether the png picture is the 9.png form; If described picture is not the png form, carry out step S202.
S202, if described picture is not the png form, judge that described picture is not the 9.png form.
S203, if described picture is the png form, whether the file size that continues to judge the png picture, greater than 40 bytes, is not the 9.png form if the file size of png picture less than or equal to 40 bytes, judges described picture; If the file size of png picture, greater than 40 bytes, carries out step S204.
S204, the 38th, 39,40 of judgement png picture, whether the value of 41 bytes is " npTc " four ASCII character values corresponding to letter, if the png picture the 38th, 39, the value of 40,41 bytes is " npTc " four ASCII character values corresponding to letter, judges that described picture is the 9.png form; If the 38th of png picture, the value of 39,40,41 bytes are not " npTc " four ASCII character values corresponding to letter, judge that described picture is not the 9.png form.
Fig. 3 is the process flow diagram of step S103 in Fig. 1 of providing of the embodiment of the present invention, and as shown in Figure 2, step S103 comprises:
S301, if described picture is not the png form, be converted to the png form by described picture, performs step afterwards S302 again, by described picture, from the png format conversion, is the 9.png form.
In embodiments of the present invention, judged result according to step S202, if described picture is not the png form, jpeg format or other picture formats in this way, can first picture be converted to the png form from jpeg format or other picture formats, perform step afterwards S302, every like this picture that can be converted to the png form just can be converted to the 9.png form again.
S302, if described picture is the png form, according to data block that comprises 9.png information of picture structure.
Fig. 4 is the process flow diagram of step S302 in Fig. 3 of providing of the embodiment of the present invention, and as shown in Figure 4, in embodiments of the present invention, step S302 can comprise following sub-step:
S3021, resolve and obtain original PNG picture width and the height, be designated as respectively width, height;
S3022, the empty array of 52 byte lengths of structure, be designated as chunk[];
S3023, be filled to respectively 1,2,2,1 equivalences by front four bytes of chunk array;
S3024, be filled into the width width of original PNG picture 37~40 bytes of chunk array according to " holding greatly order " pattern;
S3025, be filled into the height height of original PNG picture 45~48 bytes of chunk array according to " holding greatly order " pattern;
S3026, be filled into numerical value 0 or 1 49th~52 bytes of chunk array according to " holding greatly order " pattern, obtain comprising the data block of 9.png information.
S303, the data block that will comprise 9.png information is inserted in the data stream of picture of png form, obtains the picture of 9.png form.
Fig. 5 is the process flow diagram of step S303 in Fig. 3 of providing of the embodiment of the present invention, and as shown in Figure 5, in embodiments of the present invention, step S303 can comprise following sub-step:
S3031, read front 41 bytes of original PNG picture, is designated as srcHeader[];
S3032, construct an empty array that length is 105 byte lengths, is designated as destHeader[];
S3033, copy front 33 bytes of srcHeader in front 33 bytes of destHeader;
S3034, be filled into numerical value 52 in 34th~37 bytes of destHeader array according to " holding greatly order " pattern;
S3035, the ASCII character value that " npTc " is corresponding is filled into respectively in 38~41 bytes of destHeader data;
S3036, copy 42~93 byte places of chunk content to destHeader;
S3037, copy 98~105 byte places of 34~41 bytes of srcHeader to destHeader;
S3038, with srcHeader data in the original PNG picture of replacement of destHeader data, obtain the picture of 9.png form.
Embodiment bis-
Fig. 6 is a kind of image converting method process flow diagram that the embodiment of the present invention provides, and as shown in Figure 6, described method comprises:
S601, receive the picture load request.
In embodiments of the present invention, when the application program of moving in terminal need to Load Image, can send a picture load request to terminal, terminal receives the picture load request of application program.
S602, whether the picture that needs to load according to described load request judgement is the 9.png form.
In embodiments of the present invention, in the picture load request, can comprise the Format Type of the picture of the required loading of application program, terminal judges according to the picture load request whether application program will load the picture of 9.png form.
S603, if the picture that needs to load is the 9.png form, continue to obtain the format information of picture.
In embodiments of the present invention, if the picture that application program need to load is not the 9.png form, terminal directly Loads Image; If the picture that application program need to load is the 9.png form, terminal finds corresponding Target Photo according to the picture load request, and obtains the format information of Target Photo.
S604, judge according to described format information whether described picture is the 9.png form.
In embodiments of the present invention, whether terminal is the 9.png form according to Target Photo corresponding to format information judgement that gets.
S605, if described picture is not the 9.png form, be converted to the 9.png form by described picture.
In embodiments of the present invention, if Target Photo is the 9.png form, application program can directly load the picture of 9.png form.If Target Photo is not the 9.png form, terminal need to first be converted to the 9.png form by picture, reload afterwards the picture of 9.png form.
A kind of image converting method that the embodiment of the present invention provides, can automatic decision and the picture of non-9.PNG form is converted to the 9.PNG form, avoids program to occur loading not coming into force or situation that generating program is abnormal.And the conversion to picture format is real-time, and namely this conversion behavior occurs over just in the process that this resource is being loaded, and does not therefore need to do the pre-service of any off-line.
Embodiment tri-
Fig. 7 is a kind of picture conversion equipment block diagram that the embodiment of the present invention provides, and as shown in Figure 7, described picture conversion equipment comprises:
Format information acquiring unit 701, be used to obtaining the format information of picture.
In embodiments of the present invention, when the application program in terminal need to load the picture of 9.png form, at first format information acquiring unit 701 will obtain the format information of the picture that is loaded, so that the form of the picture that 702 next step judgements of picture format judging unit are loaded, format information can comprise suffix name, picture file length and the picture file the 38th of picture file, the information such as value of 39,40,41 bytes.
Whether picture format judging unit 702 is the 9.png form for according to described format information, judging described picture.
In embodiments of the present invention, whether the picture that is loaded of the format information judgement that gets according to format information acquiring unit 701 of picture format judging unit 702 is the 9.png form.
Picture format converting unit 703, for when described picture is not the 9.png form, be converted to the 9.png form by described picture.
In embodiments of the present invention, if the described picture of picture format judging unit 702 judgement is the 9.png form, application program can directly load the picture of 9.png form.If the described picture of picture format judging unit 702 judgement is not the 9.png form, picture format converting unit 703 need to first be converted to the 9.png form by picture, by application program, is loaded afterwards the picture of 9.png form again.
A kind of picture conversion equipment that the embodiment of the present invention provides, can automatic decision and the picture of non-9.PNG form is converted to the 9.PNG form, avoids program to occur loading not coming into force or situation that generating program is abnormal.
As shown in Figure 7, picture format judging unit 702 can comprise:
Whether the first judge module 7021 is the png form for according to described format information, judging described picture.
In embodiments of the present invention, the first judge module 7021 judges according to the format information of the picture that format information acquiring unit 701 gets whether picture is the png form, preferably, the first judge module 7021 can judge according to the suffix name of picture whether picture is the png form, if the described picture of the first judge module 7021 judgement is the png form, by the second judge module 7022, continued to judge whether described picture is the 9.png form; If the described picture of the first judge module 7021 judgement is not the png form, picture format judging unit 702 judges that directly described picture is not the 9.png form.
The second judge module 7022, for when described picture is the png form, judge whether described picture is the 9.png form.
In embodiments of the present invention, if the described picture of the first judge module 7021 judgement is the png form, the second judge module 7022 continues to judge that whether the file size of png picture is greater than 40 bytes, if it is not the 9.png form that the file size of png picture less than or equal to 40 bytes, judges described picture; If the file size of png picture is greater than 40 bytes, the second judge module 7022 continues the 38th of judgement png picture, 39, whether the value of 40,41 bytes is " npTc " four ASCII character values corresponding to letter, if the png picture the 38th, 39, the value of 40,41 bytes is " npTc " four ASCII character values corresponding to letter, judges that described picture is the 9.png form; If the 38th of png picture, the value of 39,40,41 bytes are not " npTc " four ASCII character values corresponding to letter, judge that described picture is not the 9.png form.
As shown in Figure 7, picture format converting unit 703 can comprise:
The first modular converter 7031, for when described picture is not the png form, be converted to the png form by described picture, by the second modular converter 7032, by described picture, from the png format conversion, is the 9.png form more afterwards.
In embodiments of the present invention, if described picture is not the png form, jpeg format or other picture formats in this way, the first modular converter 7031 can first be converted to the png form by form from JPEG or other picture formats, by the second modular converter 7032, by described picture, from the png format conversion, be the 9.png form more afterwards, every like this picture that can be converted to the png form just can be converted to the 9.png form.
The second modular converter 7032, for when described picture is not the png form, be converted to the png form by described picture.Preferably, if described picture is the png form, the second modular converter 7032 can be constructed a data block that comprises 9.png information according to picture; And the data block that will comprise 9.png information is inserted in the data stream of picture of png form, obtains the picture of 9.png form.
In embodiments of the present invention, width and the height of original PNG picture resolved and obtained to the second modular converter 7032 at first, is designated as respectively width, height; Construct afterwards the empty array of 52 byte lengths, be designated as chunk[]; Front four bytes of chunk array are filled to respectively to 1,2,2,1 equivalences; Again the width width of original PNG picture is filled into to 37~40 bytes of chunk array according to " holding greatly order " pattern; Simultaneously the height height of original PNG picture is filled into to 45~48 bytes of chunk array according to " holding greatly order " pattern; Finally numerical value 0 or 1 is filled into to 49th~52 bytes of chunk array according to " holding greatly order " pattern, obtains comprising the data block of 9.png information.
In embodiments of the present invention, after the second modular converter 7032 constructed according to picture the data block that comprises 9.png information, at first the second modular converter 7032 read front 41 bytes of original PNG picture, is designated as srcHeader[]; And construct the empty array that a length is 105 byte lengths, be designated as destHeader[]; Copy afterwards front 33 bytes of srcHeader in front 33 bytes of destHeader; Numerical value 52 is filled in 34th~37 bytes of destHeader array according to " holding greatly order " pattern; The ASCII character value that " npTc " is corresponding is filled into respectively in 38~41 bytes of destHeader data; Copy 42~93 byte places of chunk content to destHeader; Copy 98~105 byte places of 34~41 bytes of srcHeader to destHeader; Finally use srcHeader data in the original PNG picture of replacement of destHeader data, obtain the picture of 9.png form.
Embodiment tetra-
Fig. 8 is a kind of picture conversion equipment block diagram that the embodiment of the present invention provides, and as shown in Figure 8, described picture conversion equipment comprises:
Load request receiving element 801, be used to receiving the picture load request.
In embodiments of the present invention, when the application program of moving in terminal need to Load Image, can send a picture load request to terminal, load request receiving element 801 receives the picture load request of application program.
Whether load request judging unit 802 is the 9.png form for the picture that needs to load according to described load request judgement.
In embodiments of the present invention, in the picture load request, can comprise the Format Type of the picture of the required loading of application program, load request judging unit 802 judges according to the picture load request whether application program will load the picture of 9.png form.
Format information acquiring unit 803, while for the picture that loads at needs, being the 9.png form, continue to obtain the format information of picture.
In embodiments of the present invention, if the picture that application program need to load is not the 9.png form, application program directly Loads Image; If the picture that application program need to load is the 9.png form, format information acquiring unit 803 finds corresponding Target Photo according to the picture load request, and obtains the format information of Target Photo.
Whether picture format judging unit 804 is the 9.png form for according to described format information, judging described picture.
In embodiments of the present invention, whether picture format judging unit 804 is the 9.png form according to Target Photo corresponding to format information judgement that gets.
Picture format converting unit 805, for when described picture is not the 9.png form, be converted to the 9.png form by described picture.
In embodiments of the present invention, if Target Photo is the 9.png form, application program can directly load the picture of 9.png form.If Target Photo is not the 9.png form, picture format converting unit 805 need to first be converted to the 9.png form by picture, application program reloads the picture of 9.png form afterwards.
A kind of picture conversion equipment that the embodiment of the present invention provides, can automatic decision and the picture of non-9.PNG form is converted to the 9.PNG form, avoids program to occur loading not coming into force or situation that generating program is abnormal.And the conversion to picture format is real-time, and namely this conversion behavior occurs over just in the process that this resource is being loaded, and does not therefore need to do the pre-service of any off-line.
In addition, typically, terminal of the present invention can be various terminal devices, such as mobile phone, personal digital assistant (PDA) etc., so protection scope of the present invention should not be defined as the terminal of certain particular type.
In addition, the method according to this invention can also be implemented as the computer program of being carried out by CPU.When this computer program is carried out by CPU, carry out the above-mentioned functions that limits in method of the present invention.
In addition, said method step and system unit also can utilize controller and make controller realize that the computer readable storage devices of the computer program of above-mentioned steps or Elementary Function realizes for storage.
In addition, should be understood that, computer readable storage devices as herein described (for example, storer) can be volatile memory or nonvolatile memory, or can comprise volatile memory and nonvolatile memory.And nonrestrictive, nonvolatile memory can comprise ROM (read-only memory) (ROM), programming ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory as an example.Volatile memory can comprise random access memory (RAM), and this RAM can serve as the External Cache storer.As an example and nonrestrictive, RAM can obtain in a variety of forms, such as synchronous random access memory (DRAM), dynamic ram (DRAM), synchronous dram (SDRAM), double data rate SDRAM (DDR SDRAM), enhancing SDRAM (ESDRAM), synchronization link DRAM (SLDRAM) and direct RambusRAM (DRRAM).The memory device of disclosed aspect is intended to include but not limited to the storer of these and other suitable type.
Those skilled in the art will also understand is that, in conjunction with the described various illustrative logical blocks of disclosure herein, module, circuit and algorithm steps, may be implemented as electronic hardware, computer software or both combinations.For this interchangeability of hardware and software clearly is described, with regard to the function of various exemplary components, square, module, circuit and step, it has been carried out to general description.This function is implemented as software or is implemented as hardware and depends on concrete application and the design constraint that imposes on whole system.Those skilled in the art can realize described function in every way for every kind of concrete application, but this realization determines should not be interpreted as causing departing from the scope of the present invention.
In conjunction with the described various illustrative logical blocks of disclosure herein, module and circuit, can utilize the following parts that are designed to carry out function described here realize or carry out: general processor, digital signal processor (DSP), special IC (ASIC), field programmable gate array (FPGA) or other programmable logic device (PLD), discrete gate or transistor logic, discrete nextport hardware component NextPort or any combination of these parts.General processor can be microprocessor, but replacedly, processor can be any conventional processors, controller, microcontroller or state machine.Processor also may be implemented as the combination of computing equipment, and for example, the combination of DSP and microprocessor, multi-microprocessor, one or more microprocessor are in conjunction with DSP core or any other this configuration.
In the software module that can directly be included in hardware, be carried out by processor in conjunction with the step of the described method of disclosure herein or algorithm or in the two combination.Software module can reside in the storage medium of RAM storer, flash memory, ROM storer, eprom memory, eeprom memory, register, hard disk, removable dish, CD-ROM or any other form known in the art.Exemplary storage medium is coupled to processor, makes the processor can be from reading information this storage medium or to this storage medium writing information.In an alternative, described storage medium can be integral to the processor together.Processor and storage medium can reside in ASIC.ASIC can reside in user terminal.In an alternative, processor and storage medium can be used as discrete assembly and reside in user terminal.
In one or more exemplary design, described function can realize in hardware, software, firmware or its combination in any.If realize in software, described function can be transmitted on computer-readable medium or by computer-readable medium as one or more instructions or code storage.Computer-readable medium comprises computer-readable storage medium and communication media, and this communication media includes and helps computer program is sent to from a position any medium of another position.Storage medium can be can be by any usable medium of universal or special computer access.As an example and nonrestrictive, this computer-readable medium can comprise RAM, ROM, EEPROM, CD-ROM or other optical disc memory apparatus, disk storage device or other magnetic storage apparatus, or can be used to carry or file layout be instruction or data structure required program code and can be by any other medium of universal or special computing machine or universal or special processor access.In addition, any connection can suitably be called computer-readable medium.For example, if use coaxial cable, optical fiber cable, twisted-pair feeder, digital subscriber line (DSL) or such as the wireless technology of infrared ray, radio and microwave come from website, server or other remote source send software, above-mentioned coaxial cable, optical fiber cable, twisted-pair feeder, DSL or include the definition at medium such as the wireless technology of infrared first, radio and microwave.As used herein, disk and CD comprise compact disk (CD), laser disk, CD, digital versatile disc (DVD), floppy disk, Blu-ray disc, disk rendering data magnetically usually wherein, and cd-rom using laser optics ground rendering data.The combination of foregoing also should be included in the scope of computer-readable medium.
Although the disclosed content in front shows exemplary embodiment of the present invention, it should be noted that under the prerequisite of the scope of the present invention that does not deviate from the claim restriction, can carry out multiple change and modification.According to function, step and/or the action of the claim to a method of inventive embodiments described herein, need not carry out with any particular order.In addition, although element of the present invention can be with individual formal description or requirement, also it is contemplated that a plurality of, unless clearly be restricted to odd number.
Above-described embodiment; purpose of the present invention, technical scheme and beneficial effect are further described; institute is understood that; the foregoing is only the specific embodiment of the present invention; the protection domain that is not intended to limit the present invention; within the spirit and principles in the present invention all, any modification of making, be equal to replacement, improvement etc., within all should being included in protection scope of the present invention.