Image generation method, device, equipment and storage medium
By directly writing and stitching each sub-image of the target object in the external memory, the problem of excessive memory usage in traditional methods is solved, and the success rate of image generation is improved.
Patent Information
- Application Number
- CN202011192458.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-30
- Publication Date
- 2025-03-11
- Estimated Expiration
- 2041-03-11
AI Technical Summary
During the process of long image generation, traditional methods occupy a large amount of memory, resulting in the inability to successfully generate growth images when there are a large number of file pages.
By sequentially generating sub-images of the target object, and writing them into an image file in the external memory according to the order of the sub-images in the target object, the splicing of each sub-image of the target object is automatically completed in the external memory.
It greatly reduces the overhead of running memory and improves the success rate of image generation, especially when processing files with large numbers of pages.
Smart Images

Figure CN112365401B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of computer technology, and in particular to an image generation method, apparatus, device and storage medium. Background Art
[0002] Currently, many image conversion software on the market can convert content information to be displayed into a long image, so that users can view the content information through the long image and manage the content information.
[0003] In traditional technology, the process of converting a file of a specific format into a long picture can be as follows: creating corresponding images of the file of the specific format in memory by page, then using memory image stitching technology to stitch the images corresponding to each page of the file in the memory into a long picture, and then saving the stitched long picture in the memory.
[0004] However, when the number of pages in a file is large, the traditional method occupies a large amount of memory and often fails to successfully generate long images. Summary of the invention
[0005] The present invention provides an image generation method, device, equipment and storage medium to solve the technical problem of large memory occupation in the process of long image generation.
[0006] In a first aspect, an embodiment of the present invention provides an image generation method, comprising:
[0007] Generate sub-images of the target object in sequence;
[0008] According to the order of the sub-images in the target object, the sub-images are sequentially written into an image file in an external memory to obtain a target image corresponding to the target object.
[0009] In a second aspect, an embodiment of the present invention further provides an image generating device, including:
[0010] A first generating module, used to sequentially generate sub-images of the target object;
[0011] The first writing module is used to write the sub-images into the image file of the external memory in sequence according to the order of the sub-images in the target object, so as to obtain the target image corresponding to the target object.
[0012] In a third aspect, an embodiment of the present invention further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the image generation method provided in the first aspect of the embodiment of the present invention are implemented.
[0013] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the image generation method provided in the first aspect of the embodiment of the present invention are implemented.
[0014] The image generation method, device, equipment and storage medium provided by the embodiments of the present invention sequentially generate sub-images of the target object, and sequentially write the sub-images into the image file of the external memory according to the order of the sub-images in the target object, so as to obtain the target image corresponding to the target object. That is to say, after each sub-image is obtained, the electronic device will directly write the sub-image into the image file of the external memory according to the order of the sub-images in the target object, so as to automatically complete the splicing of the sub-images of the target object in the external memory. Compared with the traditional method of needing to complete the splicing of all sub-images in the running memory and then write them into the disk memory, the running memory overhead is greatly reduced, thereby improving the success rate of image generation. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.
[0016] Figure 1 A schematic diagram of a flow chart of an image generation method provided by an embodiment of the present invention;
[0017] Figure 2 Another schematic diagram of a flow chart of an image generation method provided by an embodiment of the present invention;
[0018] Figure 3 This is a schematic diagram of a principle of writing a sub-image into an image file provided by an embodiment of the present invention;
[0019] Figure 4 A schematic diagram of another flow chart of the image generation method provided by an embodiment of the present invention;
[0020] Figure 5 A schematic diagram of another flow chart of the image generation method provided by an embodiment of the present invention;
[0021] Figure 6 A schematic diagram of the structure of an image generating device provided by an embodiment of the present invention;
[0022] Figure 7 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0023] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0024] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0025] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0026] It should be noted that the concepts of "first", "second", etc. mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units. It should be noted that the modifications of "one" and "multiple" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, they should be understood as "one or more".
[0027] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0028] To make the purpose, technical solution and advantages of the present invention more clear, the embodiments of the present invention will be described in detail with reference to the accompanying drawings. It should be noted that the embodiments and features in the embodiments of the present invention can be combined with each other arbitrarily without conflict.
[0029] It should be noted that the execution subject of the following method embodiment may be an image generating device, which may be implemented as part or all of an electronic device through software, hardware, or a combination of software and hardware. Optionally, the electronic device may be any electronic device capable of processing images, such as a desktop computer, a smart phone, a personal digital assistant, and a tablet computer. Of course, the electronic device may also be an independent server or a server cluster composed of multiple servers. The following method embodiment is described by taking the execution subject as an electronic device as an example.
[0030] Figure 1 A flowchart of an image generation method provided by an embodiment of the present invention. This embodiment relates to a specific process of how an electronic device obtains a target image of a target object. Figure 1 As shown, the method may include:
[0031] S101 . Generate sub-images of the target object in sequence.
[0032] Specifically, in order to facilitate the user to view the target object on the electronic device, the electronic device can convert the target object into a target image, wherein the target object can be various types of documents, such as a word document and a portable document format (PDF) document, etc., and the target object can also be a plurality of web page contents that need to be viewed and a plurality of images that need to be viewed, etc. For example, the electronic device can convert a word document into a target image, convert a PDF document into a target image, and convert a plurality of web page contents that need to be viewed into a target image.
[0033] As an optional implementation, the process of an electronic device sequentially generating sub-images of a target object may be: controlling the view control of the target object to move to the target content of the target object that has not been displayed on the screen; obtaining the sub-image corresponding to the target content, and returning to the step of controlling the view control of the target object to move to the target content of the target object that has not been displayed on the screen, until all contents of the target object are displayed and all sub-images of the target object are obtained.
[0034] Among them, the electronic device can generate a sub-image sequence of the target object through a view control. In the Android system, the view control is View. The electronic device obtains the target content in the target object by controlling the movement of the view control, so that the view control moves to the target content of the target object that has not been displayed on the screen. For the target content currently displayed on the screen, the electronic device can use a corresponding image acquisition method to obtain the sub-image corresponding to the target content. Optionally, the electronic device can use a screenshot method to obtain the sub-image corresponding to the target content. Specifically, the electronic device calls the interface of the screenshot system to obtain the sub-image corresponding to the currently displayed target content through the screenshot system. After obtaining the sub-image corresponding to the currently displayed target content, the electronic device returns to the above-mentioned step of controlling the view control of the target object to move to the target content of the target object that has not been displayed on the screen, and repeats the above process until all the contents of the target object are displayed, thereby obtaining all the sub-images of the target object.
[0035] As another optional implementation, for a target object that can be rendered into an image, the electronic device can sequentially generate each sub-image of the target object by using an image rendering method. In this case, the process of sequentially generating each sub-image of the target object by the electronic device can be: reading target content that has not been rendered in the target object; rendering the target content into a corresponding sub-image, and returning to the step of reading target content that has not been rendered in the target object, until all the contents of the target object are rendered, and all the sub-images of the target object are obtained.
[0036] S102. Writing the sub-images into an image file in an external memory in sequence according to the order of the sub-images in the target object to obtain a target image corresponding to the target object.
[0037] The external memory is relative to the running memory of the electronic device, and the external memory may be a disk memory, such as a hard disk, a floppy disk, an optical disk, and a USB flash drive. The image file may include a file header and a file body, wherein the file header may include the size information of the image file, and the file body is used to store a sub-image sequence of the target object. The file format of the image file may be a Joint Photographic Experts Group (JPEG) format, a Graphics Interchange Format (GIF) format, and an image file storage format (Portable Network Graphic Format, PNG) format, etc.
[0038] After obtaining the sub-image of the target object, the electronic device directly writes the sub-image into the image file of the external memory based on the order of the sub-image in the target object, that is, automatically splicing the sub-image with the current last sub-image in the image file in the external memory. After the splicing is completed, the sub-image is the current last sub-image in the image file. After the electronic device obtains the sub-image of the target object again, the electronic device continues to write the sub-image obtained this time into the above image file according to the above process. In other words, the electronic device obtains each sub-image of the target object in sequence, and writes each sub-image into the above image file in sequence according to the order of each sub-image in the target object, thereby realizing automatic splicing of each sub-image.
[0039] Optionally, before the above S102, the method may further include: the electronic device obtains the order of each sub-image in the target object.
[0040] When the electronic device generates each sub-image of the target object through the view control, the electronic device controls the view control to move to the target content of the target object that has not been displayed on the screen, obtains the position of the target content in the target object, and determines the order of the sub-images corresponding to the target content based on the position. For the order of other sub-images, the order of the sub-images corresponding to the target content can be referred to.
[0041] When the electronic device sequentially generates each sub-image of the target object by image rendering, the electronic device reads the target content that has not been rendered in the target object, and at the same time, obtains the position of the target content in the target object, and determines the order of the sub-images corresponding to the target content based on the position. For the order of other sub-images, the order of the sub-images corresponding to the target content can be obtained by referring to the method of obtaining the order of the sub-images corresponding to the target content.
[0042] It can be seen from the above process that the electronic device directly realizes the splicing of each sub-image of the target object in the external memory, and after obtaining a sub-image of the target object, the sub-image is directly written into the external memory for splicing based on the order of the sub-image, without the need to use memory splicing technology, which greatly reduces the occupation of the running memory. When a large target object needs to be converted into an image, especially for electronic devices with limited memory, the success rate of image generation is greatly improved.
[0043] Since each sub-image is spliced in the image file in sequence, each sub-image can be stored in the image file in the form of a one-dimensional vector. Therefore, in order to display the target image normally later, the electronic device needs to store the size information of the target image in the file header of the image file. To this end, based on the above embodiment, optionally, the method may also include: determining the target length and target width of the target image; writing the target length and target width into the file header of the image file. Optionally, the process of S102 may be: according to the order of each sub-image in the target object, each sub-image is sequentially written into the image file of the external storage device by vertical splicing or horizontal splicing to obtain the target image of the target object.
[0044] Among them, the target length refers to the length of the target image in the vertical direction, and the target width refers to the length of the target image in the horizontal direction. When the electronic device uses a vertical splicing method to splice each sub-image, the electronic device can add the lengths of all sub-images to determine the target length, and determine the maximum width in each sub-image as the target width. When the electronic device uses a horizontal splicing method to splice each sub-image, the electronic device can determine the maximum length in each sub-image as the target length, and add the widths of all sub-images to determine the target width. After obtaining the target length and target width of the target image, the electronic device writes the target length and target width into the file header of the image file. In this way, when the target image is displayed subsequently, the electronic device can read the target length and target width in the file header of the image file, load the data in the file body based on the target length and target width, and display the target image.
[0045] The image generation method provided by the embodiment of the present invention sequentially generates each sub-image of the target object, and sequentially writes each sub-image into the image file of the external memory according to the order of each sub-image in the target object, so as to obtain the target image corresponding to the target object. That is to say, after each sub-image is obtained, the electronic device will directly write the sub-image into the image file of the external memory according to the order of the sub-image in the target object, so as to automatically complete the splicing of each sub-image of the target object in the external memory. Compared with the traditional method of needing to complete the splicing of all sub-images in the running memory and then write them into the disk memory, the overhead of the running memory is greatly reduced, thereby improving the success rate of image generation.
[0046] In practical applications, in order to increase the speed of generating the target image, the electronic device may execute the writing step of the current sub-image of the target object and the generating step of the next sub-image of the target object in parallel. Based on the above embodiment, optionally, the above S102 may include:
[0047] S1021. According to the first order of the current sub-image of the target object in the target object, write the current sub-image into an image file in an external memory, and generate a next sub-image of the target object.
[0048] Among them, after obtaining the current sub-image of the target object, the electronic device writes the current sub-image into the image file of the external memory based on the first order of the current sub-image in the target object. At the same time, the electronic device immediately generates the next sub-image of the target object without waiting for the current sub-image to be written into the image file before generating the next sub-image.
[0049] S1022. Obtain a second order of the next sub-image in the target object, and write the next sub-image into the image file according to the second order until the last sub-image of the target object is written into the image file, thereby obtaining a target image of the target object.
[0050] For example, it is assumed that the current sub-image of the target object obtained by the electronic device is matrix 1 The electronic device directly writes the current sub-image into the image file of the external memory in the order of the current sub-image in the target object. The specific storage form of the current sub-image in the image file can be [1,2,3,4,5,6,7,8,9]. While writing the current sub-image, the electronic device also continues to generate the next sub-image of the target object. Assume that the next sub-image of the target object is matrix 2 The electronic device writes matrix 2 into the above image file in the order of the next sub-image. At this time, the data in the file body of the image file is updated to [1,2,3,4,5,6,7,8,9,1,2,3,3,2,1,7,8,9]. Further, assuming that the electronic device uses vertical splicing to splice the sub-images, and assuming that the target object includes 2 sub-images, the target length determined by the electronic device is the sum of the lengths of the above sub-images, and the target width is the maximum width of each sub-image. In this way, the electronic device determines the target length of the target image (the target image is the image after the target object is converted) as 6 and the target width as 3. The electronic device writes the target length and target width of the target image into the file header of the image file. In this way, the electronic device can load the data in the image file based on the target length and target width to display the target image. The target image displayed at this time can be
[0051] In practical applications, in order to further reduce the overhead of the running memory in the image generation process, based on the above embodiment, optionally, after writing the current sub-image into the image file in the external memory, the electronic device can also release the memory space occupied by the current sub-image in the running memory.
[0052] In this way, when generating the next sub-image of the target object, the electronic device can re-apply to the running memory for the memory space required for the next sub-image. It can be understood that during the entire image generation process, the size of the memory space occupied by the electronic device in the running memory is the same as the size of a sub-image. Compared with the method of stitching all sub-images in the running memory and then writing them to the disk storage, the running memory overhead is greatly reduced, thereby further improving the success rate of image generation.
[0053] In this embodiment, by executing the writing step of the current sub-image of the target object and the generating step of the next sub-image of the target object in parallel, the image generating speed is greatly improved compared with generating the next sub-image of the target object after completing the writing of the current sub-image. At the same time, after writing the current sub-image into the image file in the external memory, the electronic device can also release the memory space occupied by the current sub-image in the running memory, which greatly reduces the overhead of the running memory, thereby further improving the success rate of image generation.
[0054] After obtaining the current sub-image of the target object, the electronic device may encode the current sub-image and then write it into the image file of the external memory. In order to further improve the image generation speed, based on the above embodiment, optionally, Figure 2 As shown, the above S102 may include:
[0055] S201. Divide a current sub-image of the target object into a plurality of image blocks, wherein the image blocks correspond to encoders one by one.
[0056] Specifically, the electronic device may encode the current sub-image using a multi-threaded encoding method. To this end, the electronic device may divide the current sub-image into a plurality of image blocks based on the number of encoders, the number of divided image blocks being the same as the number of encoders, and different image blocks corresponding to different encoders. In the process of dividing the current sub-image, the electronic device may evenly divide the current sub-image into a plurality of image blocks, or may divide the current sub-image into a plurality of image blocks of different sizes according to a preset division rule. This embodiment does not limit the division method of the current sub-image. In addition, the encoding method adopted by the above-mentioned encoder may be Huffman coding, predictive coding, or transform coding, etc., and the corresponding encoding method may be selected according to actual needs.
[0057] S202 . Encode each image block by using an encoder corresponding to each image block to obtain a plurality of encoded image blocks.
[0058] After dividing the current sub-image into a plurality of image blocks, the electronic device uses corresponding encoders to encode each image block simultaneously, thereby obtaining a plurality of encoded image blocks.
[0059] S203 . Write each encoded image block into an image file in an external memory according to the first order of the current sub-image in the target object.
[0060] Taking the uniform division of the image as an example, the specific process of writing the current sub-image into the image file is introduced. Figure 3 , the electronic device evenly divides the current sub-image into N parts to obtain N image blocks. Wherein, N is greater than or equal to 2. Then, the electronic device uses a corresponding encoder to simultaneously encode the 1st image block, the 2nd image block...the Nth image block to obtain N encoded image blocks (the 1st encoded image block, the 1st encoded image block...the Nth encoded image block). Then, the electronic device writes each encoded image block into the image file of the external memory based on the first order of the current sub-image in the target object. Of course, the electronic device also writes the N encoded image blocks into the image file according to the order of each encoded image block in the current sub-image.
[0061] In practical applications, while encoding the current sub-image in a multi-threaded encoding manner, in order to further improve the image generation speed, the electronic device may also adjust corresponding encoding parameters to encode the image blocks divided by the current sub-image. To this end, based on the above embodiment, optionally, the above S202 may include:
[0062] S2021. Obtain encoding parameters adjusted by the user for the encoder corresponding to each image block.
[0063] Among them, the encoding speed corresponding to the adjusted encoding parameter is higher than the encoding speed corresponding to the encoding parameter before adjustment. Optionally, the encoding parameter can be the compression level of the image. In the specific implementation, a variety of image compression levels can be provided, for example, compression level 1, compression level 2... compression level 10, etc. Moreover, the higher the compression level of the image is set, the lower the encoding speed of the image, and vice versa, the lower the compression level of the image, the higher the encoding speed of the image. Based on this, in order to further improve the encoding speed of the image, thereby further improving the image generation speed, before encoding, the compression level of the image can be set to a lower level in advance. In this way, the electronic device can obtain the compression level of the image reset by the user, and encode the image block based on the compression level of the reset image. Among them, the compression level of the reset image is lower than the compression level of the image before adjustment.
[0064] S2022. Encode each image block by using each encoder and the encoding parameters adjusted by each encoder to obtain a plurality of encoded image blocks.
[0065] Among them, after obtaining the adjusted encoding parameters for each encoder, the electronic device uses each encoder and uses the adjusted encoding parameters of each encoder to encode each image block at the same time, and obtains multiple encoded image blocks. Taking the encoding parameter as the compression level as an example, it is assumed that the compression level before adjustment is 5, the compression level after adjustment is 3, and the encoding speed of the image corresponding to the compression level before adjustment is higher than that of the image corresponding to the compression level before adjustment. After obtaining the adjusted compression levels of each encoder, the electronic device uses a relatively low compression level to encode each image block of the current sub-image at the same time, obtains multiple encoded image blocks, and writes each encoded image block into the image file based on the order of each encoded image block in the current sub-image, thereby completing the writing process of the current sub-image.
[0066] In this embodiment, the electronic device can encode the current sub-image using a multi-threaded encoding method, thereby increasing the encoding speed of the image, thereby increasing the image generation speed. In addition, the electronic device can also encode the image block of the current sub-image using a relatively low encoding parameter, thereby further increasing the image encoding speed, thereby further increasing the image generation speed.
[0067] In one embodiment, in order to improve the accuracy of the target image, an abnormality detection mechanism is also provided. Based on the above embodiment, optionally, Figure 4 As shown, before writing the current sub-image into the image file in the external memory, the method may further include:
[0068] S401: Perform anomaly detection on the current sub-image.
[0069] Among them, the electronic device can use image rendering to obtain a sub-image sequence of the image to be generated. In this way, due to some problems in the image rendering method itself, some abnormalities may occur in the obtained sub-image sequence. For example, the obtained sub-image may have a large area of white screen, black screen or blur. Therefore, after obtaining the current sub-image, the electronic device needs to perform an abnormality detection on the current sub-image to detect whether the current sub-image has abnormalities such as white screen, black screen or blur.
[0070] S402: When it is determined that the current sub-image is an abnormal image, regenerate the current sub-image according to a preset retry mechanism.
[0071] Among them, when it is determined that the current sub-image is an abnormal image, the electronic device can regenerate the current sub-image. For example, re-read the content corresponding to the abnormal image in the file, and re-render the content into the corresponding image to obtain a new current sub-image. In a specific implementation, the retry frequency of the sub-image can be set, such as the retry frequency can be controlled by monitoring the system frame callback, and the electronic device re-acquires the current sub-image based on the retry frequency. Of course, when it is determined that the current sub-image is a normal image, that is, there is no abnormal situation such as a white screen, a black screen, and blur in the current sub-image, the electronic device directly writes the current sub-image into the image file according to the order of the current sub-image in the target object.
[0072] In order to facilitate those skilled in the art to understand the abnormality detection process, Figure 5 The process shown is taken as an example to introduce Figure 5 Specifically, the anomaly detection process may include:
[0073] S501: Generate a current sub-image of a target object.
[0074] S502: Detect whether the current sub-image has abnormal conditions such as white screen, black screen, blur, etc.
[0075] If it exists, execute S503; if it does not exist, after encoding the current sub-image, write the current sub-image into the image file according to the first order of the current sub-image in the target object.
[0076] S503: Wait for the system frame callback to regenerate the current sub-image.
[0077] Optionally, in order to avoid endless retries, a retry end condition may be set. Based on the above embodiment, optionally, the process of writing the current sub-image into the image file in the external storage device according to the first order of the current sub-image in the target object may be: when the number of times the current sub-image is generated reaches a preset threshold, and the newly generated current sub-image is still an abnormal image, the new current sub-image is written into the image file in the external storage device according to the first order.
[0078] Among them, when the number of retries exceeds the preset threshold, that is, when the number of acquisitions of the current sub-image reaches the preset threshold, if the newly generated current sub-image still has abnormal conditions such as white screen, black screen or blur, the new current sub-image can be directly encoded and written into the image file of the external storage device according to the first order.
[0079] Of course, for other sub-images of the target object, such as the next sub-image, the electronic device's abnormality detection process for other sub-images can refer to the above-mentioned abnormality detection process for the current sub-image, and this embodiment will not be repeated here.
[0080] In this embodiment, the electronic device can perform anomaly detection on the acquired sub-image of the target object, and regenerate the corresponding sub-image when anomalies exist in the sub-image to ensure the accuracy of the sub-image sequence, thereby improving the accuracy of the final target image.
[0081] Figure 6 A schematic diagram of the structure of an image generating device provided by an embodiment of the present invention. Figure 6 As shown, the device may include: a first generating module 601 and a first writing module 602.
[0082] Specifically, the first generating module 601 is used to sequentially generate sub-images of the target object;
[0083] The first writing module 602 is used to write the sub-images into the image file of the external memory in sequence according to the order of the sub-images in the target object, so as to obtain the target image corresponding to the target object.
[0084] The image generation device provided by the embodiment of the present invention sequentially generates each sub-image of the target object, and sequentially writes each sub-image into the image file of the external memory according to the order of each sub-image in the target object, so as to obtain the target image corresponding to the target object. That is to say, after each sub-image is obtained, the electronic device will directly write the sub-image into the image file of the external memory according to the order of the sub-image in the target object, so as to automatically complete the splicing of each sub-image of the target object in the external memory. Compared with the traditional method of needing to complete the splicing of all sub-images in the running memory and then write them into the disk memory, the running memory overhead is greatly reduced, thereby improving the success rate of image generation.
[0085] On the basis of the above embodiment, optionally, the first writing module 602 is specifically used to write the current sub-image of the target object into the image file of the external storage device according to the first order of the current sub-image of the target object in the target object, and generate the next sub-image of the target object at the same time; obtain the second order of the next sub-image in the target object, and write the next sub-image into the image file according to the second order until the last sub-image of the target object is written into the image file, so as to obtain the target image of the target object.
[0086] Based on the above embodiment, optionally, the first writing module 602 is specifically configured to write the sub-images into the image file in the external memory in sequence by vertical stitching or horizontal stitching according to the order of the sub-images in the target object.
[0087] On the basis of the above embodiment, optionally, the process of writing the current sub-image of the target object into the image file of the external storage device according to the first order of the current sub-image of the target object in the target object can be: dividing the current sub-image of the target object into multiple image blocks; encoding each image block by an encoder corresponding to each image block to obtain multiple encoded image blocks; and writing each encoded image block into the image file of the external storage device according to the first order of the current sub-image in the target object, wherein the image blocks correspond to the encoders one-to-one.
[0088] On the basis of the above embodiments, optionally, the process of encoding each image block by an encoder corresponding to each image block to obtain multiple encoded image blocks can be: obtaining encoding parameters adjusted by a user for the encoder corresponding to each image block; encoding each image block by each encoder and using the encoding parameters adjusted by the encoder to obtain multiple encoded image blocks, wherein the encoding speed corresponding to the adjusted encoding parameters is higher than the encoding speed corresponding to the encoding parameters before adjustment.
[0089] On the basis of the above embodiment, optionally, the device may further include: an abnormality detection module and a second generation module;
[0090] Specifically, the abnormality detection module is used to perform abnormality detection on the current sub-image before the writing module 602 writes the current sub-image into the image file of the external memory;
[0091] The second generating module is used to regenerate the current sub-image according to a preset retry mechanism when it is determined that the current sub-image is an abnormal image.
[0092] On the basis of the above embodiment, optionally, the process of writing the current sub-image of the target object into the image file of the external storage device according to the first order of the current sub-image of the target object in the target object can be: when the number of times the current sub-image is generated reaches a preset threshold and the regenerated new current sub-image is still an abnormal image, writing the new current sub-image into the image file of the external storage device according to the first order.
[0093] On the basis of the above embodiment, optionally, the device further includes: a determination module and a second writing module.
[0094] Specifically, the determination module is used to determine the target length and target width of the target image;
[0095] The second writing module is used for writing the target length and the target width into the file header of the image file.
[0096] On the basis of the above embodiment, optionally, the device further includes: a release module.
[0097] Specifically, the release module is used to release the memory space occupied by the current sub-image in the running memory after the first writing module 602 writes the current sub-image into the image file in the external memory.
[0098] Based on the above embodiment, optionally, the first generation module 601 is specifically used to control the view control of the target object to move to the target content of the target object that has not been displayed on the screen; obtain the sub-image corresponding to the target content, and return to the step of controlling the view control of the target object to move to the target content of the target object that has not been displayed on the screen, until all the contents of the target object are displayed and all the sub-images of the target object are obtained.
[0099] On the basis of the above embodiment, optionally, the process of obtaining the sub-image corresponding to the target content may be: obtaining the sub-image corresponding to the target content by taking a screenshot.
[0100] Based on the above embodiment, optionally, the first generation module 601 is specifically used to read the target content that has not been rendered in the target object; render the target content into a corresponding sub-image, and return to the step of reading the target content that has not been rendered in the target object, until all the contents of the target object are rendered, and all the sub-images of the target object are obtained.
[0101] Reference below Figure 7 , which shows a schematic diagram of the structure of an electronic device 700 suitable for implementing the embodiment of the present disclosure. The electronic device in the embodiment of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 7 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0102] like Figure 7As shown, the electronic device 700 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage device 707 to a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the electronic device 700 are also stored. The processing device 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0103] Typically, the following devices may be connected to the I / O interface 705: an input device 707 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 707 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 707 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 709. The communication device 709 may allow the electronic device 700 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 7 The electronic device 700 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0104] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 709, or installed from a storage device 707, or installed from a ROM 702. When the computer program is executed by the processing device 701, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0105] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0106] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0107] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0108] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: obtains at least two Internet Protocol addresses; sends a node evaluation request including the at least two Internet Protocol addresses to a node evaluation device, wherein the node evaluation device selects an Internet Protocol address from the at least two Internet Protocol addresses and returns it; receives the Internet Protocol address returned by the node evaluation device; wherein the obtained Internet Protocol address indicates an edge node in a content distribution network.
[0109] Alternatively, the computer-readable medium carries one or more programs, and when the one or more programs are executed by the electronic device, the electronic device: receives a node evaluation request including at least two Internet Protocol addresses; selects an Internet Protocol address from the at least two Internet Protocol addresses; and returns the selected Internet Protocol address; wherein the received Internet Protocol address indicates an edge node in a content distribution network.
[0110] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0111] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0112] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware. The name of a unit does not limit the unit itself in some cases. For example, the first acquisition unit may also be described as a "unit for acquiring at least two Internet Protocol addresses".
[0113] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0114] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0115] In one embodiment, an electronic device is further provided, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0116] Generate sub-images of the target object in sequence;
[0117] According to the order of the sub-images in the target object, the sub-images are sequentially written into an image file in an external memory to obtain a target image corresponding to the target object.
[0118] In one embodiment, a computer-readable storage medium is further provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0119] Generate sub-images of the target object in sequence;
[0120] According to the order of the sub-images in the target object, the sub-images are sequentially written into an image file in an external memory to obtain a target image corresponding to the target object.
[0121] The image generation apparatus, device and storage medium provided in the above embodiments can execute the image generation method provided in any embodiment of the present application, and have the corresponding functional modules and beneficial effects of executing the method. For technical details not described in detail in the above embodiments, please refer to the image generation method provided in any embodiment of the present application.
[0122] According to one or more embodiments of the present disclosure, there is provided an image generating method, comprising:
[0123] Generate sub-images of the target object in sequence;
[0124] According to the order of the sub-images in the target object, the sub-images are sequentially written into an image file in an external memory to obtain a target image corresponding to the target object.
[0125] According to one or more embodiments of the present disclosure, there is provided an image generation method as above, further comprising: writing the current sub-image of the target object into an image file in an external storage device according to a first order of the current sub-image of the target object in the target object, and generating a next sub-image of the target object at the same time; obtaining a second order of the next sub-image in the target object, and writing the next sub-image into the image file according to the second order, until the last sub-image of the target object is written into the image file, thereby obtaining a target image of the target object.
[0126] According to one or more embodiments of the present disclosure, an image generation method as above is provided, further comprising: writing the sub-images into an image file in an external memory in sequence by vertical stitching or horizontal stitching according to the order of the sub-images in the target object.
[0127] According to one or more embodiments of the present disclosure, there is provided an image generation method as above, further comprising: dividing a current sub-image of the target object into a plurality of image blocks; encoding each image block by an encoder corresponding to each image block to obtain a plurality of encoded image blocks; and writing each encoded image block into an image file in an external memory according to a first order of the current sub-image in the target object, wherein the image blocks correspond one-to-one to the encoders.
[0128] According to one or more embodiments of the present disclosure, an image generation method as above is provided, further comprising: obtaining encoding parameters adjusted by a user for an encoder corresponding to each image block; encoding each image block through each encoder and using the encoding parameters adjusted by each encoder to obtain a plurality of encoded image blocks, wherein an encoding speed corresponding to the adjusted encoding parameters is higher than an encoding speed corresponding to the encoding parameters before adjustment.
[0129] According to one or more embodiments of the present disclosure, there is provided an image generation method as above, further comprising: performing abnormality detection on the current sub-image; and when it is determined that the current sub-image is an abnormal image, regenerating the current sub-image according to a preset retry mechanism.
[0130] According to one or more embodiments of the present disclosure, an image generation method as above is provided, further comprising: when the number of times the current sub-image is generated reaches a preset threshold and the regenerated new current sub-image is still an abnormal image, writing the new current sub-image into an image file in an external storage device according to the first order.
[0131] According to one or more embodiments of the present disclosure, there is provided an image generation method as above, further comprising: determining a target length and a target width of the target image; and writing the target length and the target width into a file header of the image file.
[0132] According to one or more embodiments of the present disclosure, there is provided an image generation method as above, further comprising: releasing the memory space occupied by the current sub-image in the running memory.
[0133] According to one or more embodiments of the present disclosure, an image generation method as above is provided, further comprising: controlling the view control of the target object to move to a target content of the target object that has not been displayed on the screen; obtaining a sub-image corresponding to the target content, and returning to the step of controlling the view control of the target object to move to a target content of the target object that has not been displayed on the screen, until all contents of the target object are displayed and all sub-images of the target object are obtained.
[0134] According to one or more embodiments of the present disclosure, there is provided an image generation method as above, further comprising: acquiring a sub-image corresponding to the target content by means of a screenshot.
[0135] According to one or more embodiments of the present disclosure, there is provided an image generation method as above, further comprising: reading target content that has not yet been rendered in the target object;
[0136] The target content is rendered into a corresponding sub-image, and the process returns to the step of reading the target content that has not been rendered in the target object, until all the content of the target object is rendered, thereby obtaining all the sub-images of the target object.
[0137] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
[0138] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0139] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.
Claims
1. An image generation method, characterized in that: include: Generate sub-images of the target object in sequence; Writing each sub-image into an image file in an external memory in sequence according to the order of each sub-image in the target object, to obtain a target image corresponding to the target object; The step of writing the sub-images into an image file in an external memory in sequence according to the order of the sub-images in the target object to obtain a target image corresponding to the target object comprises: According to the first order of the current sub-image of the target object in the target object, writing the current sub-image into the image file of the external memory, and taking the current sub-image as the current last sub-image in the image file; Generate a next sub-image of the target object, obtain a second order of the next sub-image in the target object, write the next sub-image into the image file according to the second order, so as to splice the next sub-image with the current last sub-image in the image file, until the last sub-image of the target object is written into the image file, so as to obtain a target image of the target object.
2. The method according to claim 1, characterized in that The step of writing the sub-images into an image file in an external memory in sequence according to the order of the sub-images in the target object to obtain a target image corresponding to the target object comprises: According to the first order of the current sub-image of the target object in the target object, writing the current sub-image into an image file of an external memory, and generating a next sub-image of the target object at the same time; The second order of the next sub-image in the target object is obtained, and the next sub-image is written into the image file according to the second order until the last sub-image of the target object is written into the image file, thereby obtaining the target image of the target object.
3. The method according to claim 1, characterized in that The step of sequentially writing the sub-images into an image file in an external memory according to the order of the sub-images in the target object comprises: According to the sequence of the sub-images in the target object, the sub-images are sequentially written into the image file of the external memory by vertical splicing or horizontal splicing.
4. The method according to claim 2, characterized in that: The step of writing the current sub-image of the target object into an image file in an external memory according to the first order of the current sub-image of the target object in the target object comprises: Dividing the current sub-image of the target object into a plurality of image blocks, wherein the image blocks correspond to encoders one by one; Encoding each image block by using an encoder corresponding to each image block to obtain a plurality of encoded image blocks; According to the first order of the current sub-image in the target object, each encoded image block is written into an image file in the external memory.
5. The method according to claim 4, characterized in that The image blocks are encoded by encoders corresponding to the image blocks to obtain a plurality of encoded image blocks, including: Obtaining encoding parameters adjusted by a user for an encoder corresponding to each image block, wherein an encoding speed corresponding to the adjusted encoding parameters is higher than an encoding speed corresponding to the encoding parameters before the adjustment; The image blocks are encoded by using the encoding parameters adjusted by the encoders to obtain a plurality of encoded image blocks.
6. The method according to claim 2, characterized in that Before writing the current sub-image into the image file of the external memory, the method further comprises: Performing anomaly detection on the current sub-image; When it is determined that the current sub-image is an abnormal image, the current sub-image is regenerated according to a preset retry mechanism.
7. The method according to claim 6, characterized in that The step of writing the current sub-image of the target object into an image file in an external memory according to the first order of the current sub-image of the target object in the target object comprises: When the number of times the current sub-image is generated reaches a preset threshold and the newly generated current sub-image is still an abnormal image, the new current sub-image is written into the image file of the external memory according to the first sequence.
8. The method according to any one of claims 1 to 7, characterized in that Also includes: Determining a target length and a target width of the target image; The target length and the target width are written into the file header of the image file.
9. The method according to any one of claims 2 to 7, characterized in that After writing the current sub-image into the image file of the external memory, the method further comprises: The memory space occupied by the current sub-image in the running memory is released.
10. The method according to any one of claims 1 to 7, characterized in that The sequentially generating sub-images of the target object includes: Controlling the view control of the target object to move to the target content of the target object that has not been displayed on the screen; Obtain the sub-image corresponding to the target content, and return to the step of controlling the view control of the target object to move to the target content of the target object that has not been displayed on the screen, until all the contents of the target object are displayed, and obtain all the sub-images of the target object.
11. The method according to claim 10, characterized in that The obtaining of the sub-image corresponding to the target content includes: The sub-image corresponding to the target content is obtained by screenshot.
12. The method according to any one of claims 1 to 7, characterized in that The sequentially generating sub-images of the target object includes: Read the target content that has not yet been rendered in the target object; The target content is rendered into a corresponding sub-image, and the process returns to the step of reading the target content that has not been rendered in the target object, until all the content of the target object is rendered, thereby obtaining all the sub-images of the target object.
13. An image generating device, characterized in that: include: A first generating module, used to sequentially generate sub-images of the target object; A first writing module, used for writing each sub-image into an image file in an external memory in sequence according to the order of each sub-image in the target object, to obtain a target image corresponding to the target object; The first writing module is specifically used to write the current sub-image of the target object into the image file of the external memory according to the first sequence of the current sub-image of the target object in the target object, and use the current sub-image as the current last sub-image in the image file; Generate a next sub-image of the target object, obtain a second order of the next sub-image in the target object, write the next sub-image into the image file according to the second order, so as to splice the next sub-image with the current last sub-image in the image file, until the last sub-image of the target object is written into the image file, so as to obtain a target image of the target object.
14. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 12 are implemented.
15. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 12 are implemented.
Citation Information
Patent Citations
Image processing apparatus
US20050168763A1
Methods and devices of picture processing and user interface display
US20200334785A1