Abstract:
The disclosure discloses an image copying method, which includes the steps of: copying, an image to be copied, to a destination address line by line, in the case of the image to be copied having a width of one pixel; copying, the image to be copied, to the destination address by a number of bytes according to a size of the image to be copied, in the case of the image to be copied not having a width of one pixel. The image copying method can save the image copying time and deduce the Central Processing Unit (CPU) occupation rate.

Description:
TECHNICAL FIELD 
       [0001]    The disclosure relates to the image processing field, and in particular to an image copying method and an image copying device. 
       BACKGROUND 
       [0002]    The operation of copying image pixels from a source address to a destination address can be used during image processing, wherein the operation includes image copying, image splicing, image splitting and the like; if specific algorithms, such as rotating the image, scaling the image, greying the image, making the image transparent and the like, are added in implementation steps, the implementation steps can be applied to most image processing operations after being modified and optimized slightly. 
         [0003]      FIG. 1  shows a typical image copying application scene, fox example, a user accesses the Internet by using a mobile terminal to enter into an application of searching weather conditions in case that the user desires to acquire the weather conditions, a cache of the application (which can be abstracted as a source image data storage part) can save image data (namely, the source image) which illustrate the weather conditions; and a source image can be stored into a Liquid Crystal Display (LCD) to refresh a data cache (in a destination image data storage part) starting from a first pixel datum on the top left corner of the source image; meanwhile, some necessary indicating bars and icons, namely, the image (in an image copying data storage part) which is to be copied needs to be saved in a proper position of the destination image data storage part; as shown in  FIG. 1 , an image a starts its storage from the position shown by “initial line  1 ”; the initial line of an image b is the position shown by “initial line  2 ”, and the initial line of the source image is marked with “source image initial line”, as shown in the figure. The image to be copied and the source image (in an image display part) is the recombined and re-spliced (in an image processing part) into a destination image which is displayed on a mobile terminal screen and finally seen by a customer. 
         [0004]    In the above-mentioned application scene, the source image and the image to be copied is combined into a destination image, namely, the image to be copied is overlapped (copied) to the source image to obtain the destination image. However, the destination image needs to be changed (for example stretching or widening and the like) by a certain ratio. In this application scene, the process of image copying is shown in  FIG. 2 , which includes the steps of: 
         [0005]    step  201 , the image copying starts; 
         [0006]    step  202 , judging whether the widths of the source image, the destination image and the image to be copied are all integer multiples of 4 bytes, and judging whether the image to be copied has the same width with a source image and with a destination image, if not, executing step  203 , if so, executing step  206 ; 
         [0007]    step  203 , calling C library function memcpy( )to copy a line of pixel data of the image to be copied to the destination address, and executing step  204  after completely copying the line of the pixel data; 
         [0008]    step  204 , starting to copy the next line of the pixel data (namely, moving the source address downward to a line relative to that in the step  203 ) of the image to be copied to a corresponding destination address (moving the destination address downward to a line relative to that in the step  203 ); 
         [0009]    step  205 , judging whether all the lines of the pixel data of the image to be copied are completely copied, if not, returning to the Step  203 , if so, completing the image copying; 
         [0010]    step  206 , judging whether the width of the image to be copied is  32  bytes in the case of the source address, destination address and width of the image to be copied all being integer multiples of 4 bytes; if so, executing step  209 , and then judging whether the height of the image to be copied is 16 lines, if so, executing step  210  to call the C library function memcpy( )for 16 times, in which one line of the pixel data (namely, 32 bytes) is copied each time, until the copying process is completed; if the height is not 16 lines, returning to the step  203 ; 
         [0011]    wherein if the width of the image to be copied is not 32 bytes, executing step  207 , judging whether the source image has the same width with the destination image, if so, taking multiple lines of the image to be copied as one line and executing the step  203 , if not, directly returning to the step  203 . 
         [0012]    The above-mentioned image copying method calls the C library function memcpy( ) to copy the images to be copied line by line, but such image processing process is time-consuming, and seriously occupies resources in a Central Processing Unit (CPU). 
       SUMMARY 
       [0013]    In view of this, the main purpose of the disclosure is to provide an image copying method and an image copying device, which can save the time for the image processing and reduce the occupied CPU resource. 
         [0014]    In order to achieve the purpose, the technical scheme of the disclosure is realized below. 
         [0015]    The disclosure provides an image copying method, which includes the steps of: 
         [0016]    copying, an image to be copied, to a destination address line by line, in the case of the image to be copied having a width of one pixel; 
         [0017]    copying, the image to be copied, to the destination address by a number of bytes according to a size of the image to be copied, in the case of the image to be copied not having a width of one pixel. 
         [0018]    Further, the step of copying the image to be copied to the destination address by a number of bytes according to the size of the image to be copied, in the case of the image to be copied not having a width of one pixel comprises: 
         [0019]    when the image to be copied has the same width with a source image and with a destination image and when the size of the image to be copied is greater than or equal to 512 bytes, copying the image to be copied to the destination address by 512 bytes each time. 
         [0020]    Further, the image to be copied does not have the same width with the source image and with the destination image, or when the image to be copied has the same width with the source image and with the destination image but the size of the image to be copied is smaller than 512 bytes, the method further comprises: 
         [0021]    copying least-significant 2 bytes of the source image to the destination address in the case of the destination address not being integer multiples of 4 bytes; 
         [0022]    loading the least-significant 2 bytes of the source image into a register, and copying the image to be copied to the destination address by the number of bytes based on the size of the image to be copied, in the case of a source address not being integer multiples of 4 bytes. 
         [0023]    Further, the step of loading the least-significant 2 bytes of the source image into a register, and copying the image to be copied to the destination address by the number of bytes according to the size of the image to be copied comprises: 
         [0024]    when the size of the image to be copied is greater than or equal to 18 bytes, copying the image to be copied to the destination address by 16 bytes each time until the size of the image remaining to be copied is smaller than 16 bytes, and determining whether the size of the image remaining to be copied is smaller than 8 bytes; when the size of the image to be copied is smaller than 18 bytes, determining whether the size of the image to be copied is smaller than 8 bytes; 
         [0025]    when the size of the image to be copied is smaller than 16 bytes but greater than 8 bytes, copying 8 bytes of the image to be copied to the destination address, and determining whether the size of the image remaining to be copied is smaller than 4 bytes; when the size of the image to be copied is smaller than 8 bytes, determining whether the size of the image to be copied is smaller than 4 bytes; 
         [0026]    when the size of the image to be copied is smaller than 8 bytes but greater than 4 bytes, copying 4 bytes of the image to be copied to the destination address, and determining whether the size of the image remaining to be copied is equal to 2 bytes; 
         [0027]    when the size of the image to be copied is smaller than 4 bytes, determining whether the size of the image to be copied is equal to 2 bytes; 
         [0028]    when the image to be copied is equal to 2 bytes, copying 2 bytes of the image to be copied to the destination address to complete the image copying; otherwise, indicating the size of the image remaining to be copied is equal to 0 byte and completing the image copying. 
         [0029]    Further, the step of copying the image to be copied to the destination address by the number of bytes according to the size of the image to be copied in the case of both the destination address and the source address being integer multiples of 4 bytes comprises: 
         [0030]    when the size of the image to be copied is greater than or equal to 32 bytes, copying the image to be copied to the destination address by 32 bytes each time until the size of the image remaining to be copied is smaller than 16 bytes, and determining whether the size of the image remaining to be copied is smaller than 16 bytes when the size of the image to be copied is smaller than 32 bytes; 
         [0031]    when the size of the image to be copied is smaller than  32  bytes but greater than 16 bytes, copying 16 bytes of the image to be copied to the destination address, and determining whether the size of the image remaining to be copied is smaller than 8 bytes; when the size of the image to be copied is smaller than 16 bytes, determining whether the size of the image to be copied is smaller than 8 bytes; 
         [0032]    when the size of the image to be copied is smaller than 16 bytes but greater than 8 bytes, copying 8 bytes of the image to be copied to the destination address, and determining whether the size of the image remaining to be copied is smaller than 4 bytes; when the size of the image to be copied is smaller than 8 bytes, determining whether the size of the image to be copied is smaller than 4 bytes; 
         [0033]    when the image to be copied is smaller than 8 bytes but greater than 4 bytes, copying 4 bytes of the image to be copied to the destination address and determining whether the size of the image remaining to be copied is smaller than 2 bytes; when the size of the image to be copied is smaller than 4 bytes, determining whether the size of the image to be copied is equal to 2 bytes; 
         [0034]    when the image to be copied is equal to 2 bytes, copying 2 bytes of the image to be copied to the destination address to complete the image copying; otherwise, indicating the size of the image remaining to be copied is equal to 0 byte and completing the image copying. 
         [0035]    The disclosure also provides an image copying device, which includes an analysis module and a copying module, wherein 
         [0036]    the analysis module is configured to analyze an image to be copied, to obtain an analysis result and to notify the copying module of the analysis result; 
         [0037]    the copying module is configured to, according to the analysis result of the image to be copied which is analyzed by the analysis module, to copy the image to be copied to the destination address line by line in the case of the image to be copied having a width of one pixel; 
         [0038]    to copy the image to be copied to the destination by a number of bytes according to a size of the image to be copied in the case of the width of the image to be copied not having a width of one pixel. 
         [0039]    The image copying method according to the disclosure combines the characteristics of the specific image resource data so as to classifying the image for the processing, which can greatly accelerate the speed for image copying, widely be applied to the image processing process, effectively alleviate the problem that the image updating is slow, and greatly improve the user experience. 
     
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         [0040]      FIG. 1  shows a typical image copying application scene in the related art; 
           [0041]      FIG. 2  shows an image copying process according to the related art; 
           [0042]      FIG. 3  shows an image copying process according to the disclosure; 
           [0043]      FIG. 4  shows an image copying process according to an embodiment of the disclosure; and 
           [0044]      FIG. 5  shows a structural diagram of an image copying device according to the disclosure. 
       
    
    
     DETAILED DESCRIPTION 
       [0045]    The technical scheme of the disclosure is further described below with reference to the drawings and embodiments in details. 
         [0046]    The main idea of the image copying according to the disclosure is to analyze the image to be copied, and then to adopt different copying methods for the images with different attributes; as shown in  FIG. 3 , the method includes: 
         [0047]    step  301 , copying, an image to be copied, to a destination address line by line, in the case of the image to be copied having a width of one pixel; and 
         [0048]    step  302 , copying, the image to be copied, to the destination address by a number of bytes according to a size of the image to be copied, in the case of the image to be copied not having a width of one pixel. 
         [0049]    The image copying method according to the disclosure is described below through specific embodiments; as shown in  FIG. 4 , the method includes: 
         [0050]    step  401 , the image copying starts; 
         [0051]    step  402 , judging whether the image to be copied has a width of one pixel (32 bytes), namely, whether the image to be copied is a single-column chart, if so, executing step  403 , if not, executing step  405 ; 
         [0052]    steps  403  to  404 , copying a line of the image (namely, one pixel of 32 bytes) to be copied to the destination each time in the case of the image to be copied having a width of one pixel, until all pixels of the image to be copied are completely copied line by line, and then the image copying is completed; 
         [0053]    step  405 , judging whether the image to be copied has the same width with the source image, the destination image in the case of the image to be copied having a width of one pixel, if so, executing step  406 , if not, executing step  409 ; 
         [0054]    step  406 , judging whether the size of the image to be copied is smaller than 512 bytes in the case of the image to be copied having the same width with the source image and the destination image, if so, executing step  409 ; if the size of the image to be copied is greater than or equal to 512 bytes, executing step  407 ; 
         [0055]    steps  407  to  408 , copying the image to be copied to the destination address by 512 bytes each time (namely, taking multiple lines of the image to be copied as one line to copy, wherein the line represented the multiple lines has a size of 512 bytes), until the image to be copied is smaller than 512 bytes; at this time, if the image remaining to be copied is smaller than 512 bytes and is 0, the image copying is completed; if the image remaining to be copied are smaller than 512 bytes and are not 0, executing step  409 ; 
         [0056]    steps  409  to  410 , judging whether the destination address is the integer multiples of 4 bytes; if not, copying the headmost 2 bytes of the source image to the destination address, thus the destination address is the integer multiple of 4 bytes and then executing step  411 ; and if the destination address is the integer multiple of 4 bytes, directly executing step  411 ; 
         [0057]    step  411 , judging whether the source address is the integer multiples of 4 bytes, wherein the source address can be the integer multiples of 4 bytes, or not; in addition, as the headmost 2 bytes of the source image are copied to the destination address in the step  410 , it may cause that the source address is not the integer multiples of 4 bytes; thereby, it needs to judge whether the source address is the integer multiples of 4 bytes; if so, executing step  423 ; and if not, executing step  412 ; 
         [0058]    steps  412  to  422 , loading the headmost 2 bytes of the source image into a register in the case of the destination address being the integer multiples of 4 bytes, and the source address being not; and thus, the source address is the integer multiples of 4 bytes; 
         [0059]    and then continuing the image copying, wherein the image can be copied by 16 bytes each time; judging whether the image to be copied is smaller than 18 bytes; if not, copying the image to be copied to the destination address by 16 bytes each time, until the size of the image remaining to be copied are smaller than 16 bytes; at this time, judging whether the size of the image remaining to be copied is smaller than 8 bytes; and if so, judging whether the size of the image remaining to be copied is smaller than 8 bytes; 
         [0060]    if the image to be copied is smaller than 16 bytes and greater than 8 bytes, copying 8 bytes of the image to be copied to the destination address, and then judging whether the image to be copied is smaller than 4 bytes; and if the image to be copied is smaller than 8 bytes, judging whether the image to be copied is smaller than 4 bytes; 
         [0061]    if the image to be copied is smaller than 8 bytes and greater than 4 bytes, copying 4 bytes of the image to be copied to the destination address, and then judging whether the image to be copied is equal to 2 bytes; if the image to be copied is smaller than 4 bytes, judging whether the image remaining to be copied is equal to 2 bytes; and it should be noted that when the image to be copied is smaller than 4 bytes, the size of the image remaining to be copied is 2 bytes or 0 byte; 
         [0062]    if the image remaining to be copied is equal to 2 bytes, copying the 2 bytes to the destination image address, and then the image copying is completed; otherwise, the image remaining to be copied is equal to 0 byte, which means the copying process is completed; 
         [0063]    steps  423  to  433 , judging whether the image to be copied is smaller than 32 bytes in the case of both the source address and the destination address being the integer multiples of 4 bytes; if so, judging whether the image to be copied is smaller than 16 bytes; and if not, copying the image to be copied to the destination address by 32 bytes each time, until the image to be copied is smaller than 16 bytes; 
         [0064]    when the image to be copied is smaller than 32 bytes and greater than 16 bytes, copying 16 bytes of the image to be copied to the destination address, and then judging whether the size of the image remaining to be copied is smaller than 8 bytes; when the image to be copied is smaller than 16 bytes, judging whether the size of the image remaining to be copied is smaller than 8 bytes; 
         [0065]    if the image to be copied is smaller than 16 bytes and greater than 8 bytes, copying 8 bytes of the image to be copied to the destination address, and then judging whether the image to be copied is smaller than 4 bytes; and if the image to be copied is smaller than 8 bytes, judging whether the image to be copied is smaller than 4 bytes; 
         [0066]    if the image to be copied is smaller than 8 bytes and greater than 4 bytes, copying 4 bytes of the image to be copied to the destination address, and then judging whether the size of the image remaining to be copied is equal to 2 bytes; if the image to be copied is smaller than 4 bytes, judging whether the size of the image remaining to be copied is equal to 2 bytes; and it should be noted that when the image to be copied is smaller than 4 bytes, the size of the image remaining to be copied is 2 bytes or 0 byte. 
         [0067]    If the size of the image remaining to be copied is equal to 2 bytes, copying the 2 bytes to the destination address, and then the image copying is completed; otherwise, the size of the image remaining to be copied is equal to 0 byte, which means the copying process is completed. 
         [0068]    In order to realize the above-mentioned method, the disclosure also provides an image copying device. As shown in  FIG. 5 , the device includes an analysis module  10  and a copying module  20 , wherein the analysis module  10  is configured to analyze an image to be copied, to obtain an analysis result, and to the copying module  20  of the analysis result; 
         [0069]    the copying module  20  is configured, according to the analysis result of the image to be copied which is analyzed by the analysis module  10 , to copy the image to be copied to the destination address line by line in the case of the image to be copied having a width of one pixel; to copy the image to be copied to the destination by a number of bytes according to a size of the image to be copied in the case of the width of the image to be copied not having a width of one pixel. 
         [0070]    All those described above are only the preferred embodiments of the disclosure and not intended to limit the scope of the disclosure.