Image processing method, device and equipment
By pre-generating low-resolution image previews on the server, downloading the previews in the main process, loading and decoding the original images in the sub-process for size optimization, and finally rendering and displaying them in the main or sub-process, high resolution problems are solved. Problems such as incomplete display of high-resolution images and long opening times are avoided to avoid process crashes and lags.
Patent Information
- Application Number
- CN201910917769.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-09-26
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2040-01-04
AI Technical Summary
When viewing high-resolution pictures, the prior art causes incomplete display of pictures, long opening time, and a single thread execution time is too long, resulting in process crash or stuttering.
By pre-generating a low-resolution image preview on the server, downloading the preview image in the main process, loading and decoding the original image in the sub-process, optimizing its size, and finally rendering and displaying it in the main or sub-process. .
It realizes the rapid display of picture previews, solves the problem of too long picture display time, and displays the complete picture through size optimization, avoiding lags and crashes caused by too long execution time of a single process.
Smart Images

Figure CN112562024B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing, and in particular to an image processing method, device and equipment. Background Art
[0002] Currently, in the process of instant communication or web browsing, it is usually necessary to view pictures. The traditional picture viewing process includes: downloading the original picture to store it on the disk, loading and decoding the downloaded original picture from the disk, and rendering the picture to the display.
[0003] However, when viewing high-resolution images using the above-mentioned traditional image viewing method, the image will not be fully displayed because the size of the high-resolution image is much larger than the size of the display screen; and the high-resolution image occupies a large amount of memory, which will lead to a long image processing process, that is, a long image opening time. In this case, the user experience is greatly affected. Therefore, a new image processing method is urgently needed to solve the above problems. Summary of the invention
[0004] In view of this, an embodiment of the present invention discloses an image processing method, device and equipment, which solves the problems of long image display time and incomplete image display in the prior art, and avoids the problem of long execution time in a single thread, resulting in process crash and freeze.
[0005] The embodiment of the present invention discloses a method for processing an image, comprising:
[0006] In response to the picture download instruction, calling the main process to download the original picture and the preview picture generated in advance from the server, and displaying the preview picture on the display;
[0007] Create a child process;
[0008] Calling the subprocess to load the original image of the picture, decoding the original image of the picture, and optimizing the size of the decoded image;
[0009] The main process or the sub-process is called to render the size-optimized image, and the rendering result is displayed on the display.
[0010] Optionally, downloading a preview image of a pre-generated image in the main process includes:
[0011] Get the size parameters of the display;
[0012] A preview image matching the size parameters of the display screen is downloaded in the main process; wherein a plurality of preview images of different sizes are stored in the server.
[0013] Optionally, the creating a subprocess includes:
[0014] Creating a target thread in the main process;
[0015] A child process is created in the target thread.
[0016] Optionally, optimizing the size of the decoded picture in the sub-process includes:
[0017] Get the size parameters of the display;
[0018] Based on the size parameters of the display, the decoded image is scaled using a matrix transformation method.
[0019] Optionally, also include:
[0020] The subprocess is called to store the image data obtained after size optimization in a shared cache of the main process and the subprocess.
[0021] Optionally, also include:
[0022] A plurality of threads are started in the subprocess, and the original image of the image is decoded through the plurality of threads, and the size of the decoded image is optimized.
[0023] Optionally, also include:
[0024] The created subprocess includes one or more.
[0025] Optionally, in the case where the created sub-process includes a plurality of sub-processes, calling the sub-process to load the original image of the picture, decoding the original image of the picture, and optimizing the size of the decoded image includes:
[0026] Calling the first subprocess to load the original image of the image;
[0027] Decoding the original image of the image through the second sub-process;
[0028] The decoded picture is optimized in size through the third sub-process.
[0029] The embodiment of the present invention discloses a picture processing device, comprising:
[0030] A main process execution unit, configured to respond to a picture download instruction, call the main process to download a preview picture and an original picture of a pre-generated picture from a server, and display the preview picture on a display;
[0031] Create a unit, which is used to create a child process;
[0032] A sub-process execution unit, used for calling the sub-process to load the original image of the picture, decoding the original image of the picture, and optimizing the size of the decoded picture;
[0033] The display unit is used to call the main process or the sub-process to render the size-optimized image and display the rendering result on the display.
[0034] An embodiment of the present invention provides a terminal device, including:
[0035] Processor and memory;
[0036] Wherein, the processor is used to execute the program stored in the memory;
[0037] The memory is used to store a program, and the program is at least used to:
[0038] In response to the picture download instruction, calling the main process to download a preview picture and an original picture of the pre-generated picture from the server, and displaying the preview picture on the display;
[0039] Create a child process;
[0040] Calling the subprocess to load the original image of the picture, decoding the original image of the picture, and optimizing the size of the decoded image;
[0041] The main process or the sub-process is called to render the size-optimized image, and the rendering result is displayed on the display.
[0042] The embodiment of the present invention discloses a method, device and equipment for image processing, including: in response to an image download instruction, calling a main process to download a preview image and an original image of a pre-generated image from a server, and displaying the preview image on a display; creating a sub-process; calling the sub-process to load the original image of the image, and decoding the original image of the image, and optimizing the size of the decoded image; calling the main process or the sub-process to render the image after size optimization, and displaying the rendering result on the display. In this way, due to the memory space occupied by the preview image, by loading the preview image, the image can be quickly displayed on the display, solving the problem of too long image display time in the prior art, and obtaining an image matching the size of the display by size optimization, solving the problem of inability to display a complete image in the prior art.
[0043] In addition, in this embodiment, the processing operation of the original image is separated from the main process, and the processing operation of the original image is executed in a new process. This greatly reduces the time to execute image processing operations in a single process, and thus greatly reduces the probability of process freezes, crashes and other problems. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0045] Figure 1 A schematic diagram showing a method for image processing in the prior art is shown;
[0046] Figure 2 A schematic diagram of a process flow of a picture processing method provided by an embodiment of the present invention is shown;
[0047] Figure 3 A schematic diagram of an image processing scenario provided by an embodiment of the present invention is shown;
[0048] Figure 4 Another schematic diagram of a scene of image processing provided by an embodiment of the present invention is shown;
[0049] Figure 5 Another schematic diagram of a process of a picture processing method provided by an embodiment of the present invention is shown;
[0050] Figure 6 A schematic diagram of the structure of a picture processing device provided by an embodiment of the present invention is shown;
[0051] Figure 7 A schematic structural diagram of a terminal device provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0052] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0053] In order to solve the problem of long image opening time and incomplete image display, the applicant found that a preview of the original image can be pre-generated in the server, wherein the preview image is a low-resolution image that occupies less memory. The terminal loads the preview image of the image while loading the original image, and displays the preview image of the image on the display in advance. Since the low resolution occupies less memory, it can be displayed quickly on the display, so that the user can view the image through the preview image in a shorter time. In addition, the original image is scaled to adapt the image to the size of the display, and then the complete image is displayed on the display screen.
[0054] The improved image processing method shortens the image viewing time and allows the complete image to be viewed on the display, which improves the user experience to a certain extent. However, the inventors found that during the image viewing process, the entire program may still become unresponsive, freeze, crash, or the window may not be able to move.
[0055] The applicant has found through research that when viewing high-resolution images, the high-resolution original images occupy a large amount of memory, the image processing process is relatively complicated, resulting in a long image processing time, and the entire image processing process is executed in a single process (such as Figure 1 Generally speaking, when a program takes a long time to process in a single process, it is easy to cause the program to freeze or become unresponsive.
[0056] In addition, since the entire image processing operation is performed in a single process, if any operation in the image processing process is abnormal, the entire program will crash, making the image unviewable.
[0057] Based on the above problems, the applicant believes that different image processing operations can be separated from one process to solve the problems of program freeze and unresponsiveness caused by the long execution time of image processing in a single process. That is, different processes are used to perform different image processing operations to reduce the time of image processing operations in a single process.
[0058] In this embodiment, the operation process of image processing includes: image loading, image preview, image decoding, and image size optimization.
[0059] In order to avoid the problem of program unresponsiveness, crash or window inability to move as much as possible, each operation can be performed using one process. However, it takes a certain amount of time to start each process, which greatly reduces the efficiency of image processing.
[0060] Moreover, the applicant has found through research that during the image processing process, the display operation of the preview image needs to be executed as quickly as possible, and preferably in an independent process, so that the image preview will not be unable to be executed normally due to abnormalities in other operations, thereby causing the image to be unable to be displayed.
[0061] Therefore, in order to solve the problem of program unresponsiveness, crash or window inability to move without reducing the efficiency of image processing, the applicant has found through research that image loading and image preview operations can be performed in one process, and image decoding and image size optimization can be performed in another process. Since the operation of previewing the preview image is simple and occupies less memory, it can be displayed quickly on the monitor, and the process of image decoding and image size optimization is relatively complicated. Even if any operation in the process is abnormal, it will not cause the entire program to crash. In this way, the image preview operation can still run normally, and the user can view the image normally. In this way, not only can the execution time of the image processing operation in each process be reduced, but also the probability of jamming and unresponsiveness caused by too long operation time can be greatly reduced.
[0062] Next, we will introduce the image processing method in detail:
[0063] refer to Figure 2 , shows a schematic flow chart of a picture processing method provided by an embodiment of the present invention. In this embodiment, the method includes:
[0064] It should be noted that the image processing method of this embodiment is applied to a terminal.
[0065] S201: In response to a picture download instruction, calling a main process to download a preview picture and an original picture of a pre-generated picture, and performing a preview operation of the preview picture;
[0066] In this embodiment, S201 includes two operation steps:
[0067] 1. Call the main process to download the preview image and the original image;
[0068] In this embodiment, the picture download instruction may be sent by a user or may be automatically triggered.
[0069] After receiving the picture download instruction, the terminal calls the main process to download the preview picture and the original picture of the pre-generated picture from the server.
[0070] Among them, since the sizes of displays are various, in order to adapt to displays of different sizes, when the server receives the picture uploaded by the terminal, it generates a plurality of preview pictures of different sizes for the terminal to download.
[0071] It should be noted that the preview image of the picture is a low-resolution image. The generation of the low-resolution image can be based not only on the size of the display but also on the memory space occupied by different resolutions. While ensuring the clarity of the picture, the memory space is occupied as small as possible.
[0072] When the terminal downloads the preview image from the server, in order to adapt to the display of the terminal, the preview image may be downloaded according to the size of the display, specifically including:
[0073] Get the size parameters of the terminal display;
[0074] Downloading a preview image matching the size parameters of the display in the main process; wherein,
[0075] The server stores multiple preview images in different storages.
[0076] 2. Call the main process to perform the preview operation of the preview image.
[0077] In this embodiment, calling the preview operation of the preview image includes: rendering the preview image to display the preview image on a display.
[0078] In this embodiment, after the main process downloads the preview image and the original image, the preview image and the original image are stored, which can be stored in a target location based on a preset download path, for example, can be stored in a disk of the terminal.
[0079] S202: Create a child process;
[0080] In this embodiment, in order to avoid the problem of process crash and freeze caused by executing the image processing operation for too long in the main thread, a new process is created and the processing operation on the original image is performed in the new thread.
[0081] In this embodiment, in order to speed up the image processing rate, the subprocess can be started asynchronously, for example, including:
[0082] Creating a target thread in the main process;
[0083] A child process is created in the target thread.
[0084] Among them, downloading the preview image and the original image of the picture and executing the preview operation of the preview image can be performed in a thread of the main process, for example, represented as thread 1. The created target thread can be understood as a new thread, which is different from thread 1, and a child process is created in the new thread.
[0085] S203: calling the sub-process to load the original image of the picture, decoding the original image of the picture, and optimizing the size of the decoded image; in this embodiment, the sub-process performs a processing operation on the original image, and specific operation steps may include:
[0086] 1) Load the original image;
[0087] In this embodiment, the original image of the picture is stored in a target location of the terminal, such as a disk, so the child process can load the original image by accessing the location where the picture is stored, such as accessing the disk.
[0088] 2) Decode the original image;
[0089] Generally, the downloaded images are image data that has been encoded and compressed, not bitmaps. To render the images on a display, the encoded image data needs to be decoded and converted into bitmap data.
[0090] In this embodiment, the decoding operation of the picture can be performed in a variety of ways, which are not limited in this embodiment.
[0091] 3) Optimize the size of the decoded image;
[0092] In this embodiment, when the resolution of the image is less than or equal to the size of the display, the image can be fully displayed on the display, but when the size of the image is larger than the size of the display, the image cannot be fully displayed, especially for high-resolution images, the resolution of the image is much larger than the size of the display, then the high-resolution image cannot be fully displayed in the display.
[0093] Therefore, in order to ensure that a complete picture is displayed on the display, the size of the original picture may be optimized, and the size of the decoded picture needs to be optimized based on the size of the display.
[0094] The size of the image can be optimized by a variety of methods. In order to further improve the efficiency of image processing and reduce memory consumption, the image size can be optimized by resizing.
[0095] Specifically, they include:
[0096] Get the size parameters of the display;
[0097] Based on the size parameters of the display, the decoded image is scaled using a matrix transformation method.
[0098] S104: calling the main process or the sub-process to render the size-optimized image, and displaying the rendering result on a display.
[0099] In this embodiment, after the original image is processed, the processed data needs to be rendered, and the rendering result is displayed on a display.
[0100] In this embodiment, the image can be rendered in a variety of ways, which are not limited in this embodiment.
[0101] It should be noted that the main process and the sub-process share a cache, and the data processed by the sub-process needs to be stored in the shared cache. In this embodiment, before rendering the image, the sub-process also needs to write the size-optimized image data into the shared cache of the main process and the sub-process.
[0102] Among them, since the result of image processing of the original image is stored in the shared cache, both the main process and the child process can perform rendering operations.
[0103] If the rendering of the image data is performed by calling a child process, the child process needs to call HDC from the main process, wherein HDC is a Windows data structure containing drawing attribute information about a device (such as a display or a printer).
[0104] In this embodiment, in response to the image download instruction, the main process is called to download the preview image and the original image of the pre-generated image from the server, and the preview image is displayed on the display; a sub-process is created; the sub-process is called to load the original image of the image, and the original image of the image is decoded, and the size of the decoded image is optimized; the main process or the sub-process is called to render the size-optimized image, and the rendering result is displayed on the display. In this way, since the preview image occupies a small memory space, the image can be quickly displayed on the display by loading the preview image, which solves the problem of long image display time in the prior art, and the image matching the size of the display is obtained by size optimization, which solves the problem of inability to display the complete image in the prior art.
[0105] Moreover, in the present embodiment, the processing operation of the original image is separated out and executed in a new process, which greatly reduces the time of executing the image processing operation in a single process, and further greatly reduces the probability of problems such as process freeze and crash.
[0106] Furthermore, all operations performed by the child process may be performed in a single thread of the child process or in multiple threads, which is not limited in this embodiment.
[0107] The operations performed in the child process include: original image loading, image decoding, and size optimization. Each operation can be performed in a separate process. Specifically, the operations also include:
[0108] A plurality of threads are started in the subprocess, and the original image of the image is decoded through the plurality of threads, and the size of the decoded image is optimized.
[0109] Furthermore, in order to avoid problems such as process crash and unresponsiveness caused by executing image processing operations for too long in a single process to the greatest extent, multiple sub-processes can be used to perform different image processing operations respectively.
[0110] Furthermore, the created subprocess includes one or more subprocesses.
[0111] When multiple sub-processes are created, one operation can be performed through one sub-process, or multiple operations can be performed through one sub-process.
[0112] For example, when multiple subprocesses are created and one subprocess performs one operation, the specific steps include:
[0113] Calling the first subprocess to load the original image of the image;
[0114] Decoding the original image of the image through the second sub-process;
[0115] The decoded picture is optimized in size through the third sub-process.
[0116] refer to Figure 3 , shows a schematic diagram of an image processing scenario provided by an embodiment of the present invention, the scenario includes a first terminal 301, a server 302, and a second terminal 303;
[0117] Wherein, the first terminal uploads the picture to the server;
[0118] The server generates multiple preview images of different sizes of the image;
[0119] In order to match the sizes of different displays, the server may convert the received images into preview images of different sizes in advance.
[0120] The second terminal downloads the preview image and the original image of the image from the server;
[0121] The second terminal may download a preview image and an original image of the image based on the size of the display, and display the preview image and the original image of the image.
[0122] Among them, based on the above scenario, such as Figure 4 As shown, another schematic diagram of a scene of image processing provided by an embodiment of the present invention is shown:
[0123] S401: The first terminal uploads the original image to the server;
[0124] S402: The server saves the original image of the picture, and generates a plurality of preview images of different sizes based on the original image of the picture;
[0125] S403: The second terminal responds to the picture download instruction, calls the main process to download the preview image of the picture generated by the preview and the original image of the picture, and displays the preview image on the display;
[0126] S404: Create a child process;
[0127] S405: calling the subprocess to load the original image of the picture, decoding the original image of the picture, and optimizing the size of the decoded image;
[0128] S406: Call the main process or the child process to render the size-optimized image, and display the rendering result on the display.
[0129] In this embodiment, after receiving the original image of the picture uploaded by the first terminal, the server generates preview images of multiple pictures of different sizes, and the second terminal can download the original image and the preview image of the picture. Since the preview image of the picture occupies a small amount of memory, the picture can be quickly displayed on the display. In addition, the size of the picture is optimized, and the complete picture can be displayed on the display. In addition, the operation of processing the original image is separated from the main process, and the processing operation of the original image is performed in the sub-process. In this way, the time for performing image processing operations in a single process is greatly reduced, thereby greatly reducing the probability of problems such as process freezes and crashes.
[0130] refer to Figure 5 , shows another flow chart of a picture processing method provided by an embodiment of the present invention. In this embodiment, the method includes:
[0131] S501: In response to the picture download instruction, calling the main process to download the preview picture and the original picture of the pre-generated picture;
[0132] S502: Displaying the preview image on a display through the main process;
[0133] S503: creating a target thread in the main process, and creating a child process in the target thread;
[0134] S504: calling the subprocess to load the original image of the image;
[0135] S505: decoding the loaded original image through the sub-process;
[0136] S506: Optimizing the size of the decoded picture through the sub-process;
[0137] S507: Call the main process or the child process to render the size-optimized image, and display the rendering result on the display.
[0138] In this embodiment, since the preview image occupies a small amount of memory space, the image can be quickly displayed on the monitor by loading the preview image, which solves the problem of long image display time in the prior art, and an image matching the size of the monitor is obtained by size optimization, which solves the problem of inability to display the complete image in the prior art.
[0139] Moreover, in the present embodiment, the processing operation of the original image is separated from the main process, and the processing operation of the original image is executed in a new process. This greatly reduces the time of executing image processing operations in a single process, and further greatly reduces the probability of problems such as process freeze and crash.
[0140] refer to Figure 6 , shows a schematic diagram of the structure of a picture processing device provided by an embodiment of the present invention. In this embodiment, the device includes:
[0141] The main process execution unit 601 is used to call the main process to download the preview image and the original image of the pre-generated image from the server in response to the image download instruction, and display the preview image on the display;
[0142] A creation unit 602, used to create a child process;
[0143] The sub-process execution unit 603 is used to call the sub-process to load the original image of the picture, decode the original image of the picture, and optimize the size of the decoded picture;
[0144] The image rendering unit is used to call the main process or the sub-process to render the size-optimized image and display the rendering result on the display.
[0145] Optionally, the main process execution unit includes:
[0146] A first acquisition subunit, used to acquire size parameters of the display;
[0147] The download subunit is used to download a preview image matching the size parameters of the display screen in the main process; wherein a plurality of preview images of different sizes are stored in the server.
[0148] Optionally, the creation unit includes:
[0149] A first thread creation unit, used for creating a target thread in the main process;
[0150] The first subprocess creation unit is used to create a subprocess in the target thread.
[0151] Optionally, the subprocess execution subunit is used to:
[0152] A second acquisition subunit is used to acquire the size parameters of the display;
[0153] The scaling processing subunit is used to scale the decoded image using a matrix transformation method based on the size parameters of the display.
[0154] Optionally, also include:
[0155] The writing sub-unit is used to call the sub-process and write the size-optimized image data into the shared cache of the main process and the sub-process.
[0156] Optionally, also include:
[0157] The multi-thread control sub-unit is used to start multiple threads in the sub-process, decode the original image of the image through the multiple threads, and optimize the size of the decoded image.
[0158] Optionally, also include:
[0159] The second creation unit is used to create one or more sub-processes.
[0160] Optionally, the subprocess execution unit includes:
[0161] A loading sub-unit, used for calling the first sub-process to load the original image of the image;
[0162] A decoding subunit, configured to decode the original image of the image through the second sub-process;
[0163] The size optimization subunit is used to optimize the size of the decoded picture through the third sub-process.
[0164] Through the device of this embodiment, since the preview image occupies a small memory space, the image can be quickly displayed on the display by loading the preview image, which solves the problem of long image display time in the prior art, and an image matching the size of the display is obtained through size optimization, which solves the problem of inability to display the complete image in the prior art.
[0165] Moreover, in the present embodiment, the processing operation of the original image is separated from the main process, and the processing operation of the original image is executed in a new process. This greatly reduces the time of executing image processing operations in a single process, and further greatly reduces the probability of problems such as process freeze and crash.
[0166] refer to Figure 7 , shows a schematic diagram of the structure of a terminal device provided in an embodiment of the present invention. In this embodiment, the device includes:
[0167] Processor 701 and memory 702;
[0168] Wherein, the processor is used to execute the program stored in the memory;
[0169] The memory is used to store a program, and the program is at least used to:
[0170] In response to the picture download instruction, calling the main process to download a preview picture and an original picture of the pre-generated picture from the server, and displaying the preview picture on the display;
[0171] Create a child process;
[0172] Calling the subprocess to load the original image of the picture, decoding the original image of the picture, and optimizing the size of the decoded image;
[0173] The main process or the sub-process is called to render the size-optimized image, and the rendering result is displayed on the display.
[0174] Optionally, downloading a preview image of a pre-generated image in the main process includes:
[0175] Get the size parameters of the display;
[0176] A preview image matching the size parameters of the display screen is downloaded in the main process; wherein a plurality of preview images of different sizes are stored in the server.
[0177] Optionally, the creating a subprocess includes:
[0178] Creating a target thread in the main process;
[0179] A child process is created in the target thread.
[0180] Optionally, optimizing the size of the decoded picture in the sub-process includes:
[0181] Get the size parameters of the display;
[0182] Based on the size parameters of the display, the decoded image is optimized in size using a matrix transformation method.
[0183] Optionally, also include:
[0184] The sub-process is called to write the size-optimized picture data into the shared cache of the main process and the sub-process.
[0185] Optionally, also include:
[0186] A plurality of threads are started in the subprocess, and the original image of the image is decoded through the plurality of threads, and the size of the decoded image is optimized.
[0187] Optionally, also include:
[0188] The created subprocess includes one or more.
[0189] Optionally, in the case where the created sub-process includes a plurality of sub-processes, calling the sub-process to load the original image of the picture, decoding the original image of the picture, and optimizing the size of the decoded image includes:
[0190] Calling the first subprocess to load the original image of the image;
[0191] Decoding the original image of the image through the second sub-process;
[0192] The decoded picture is optimized in size through the third sub-process.
[0193] In some embodiments, the terminal or server may be a node in a distributed system, wherein the distributed system may be a blockchain system, and the blockchain system may be a distributed system formed by connecting the multiple nodes through network communication. The nodes may form a peer-to-peer (P2P) network, and any form of computing device, such as a server, terminal or other electronic device, may become a node in the blockchain system by joining the peer-to-peer network.
[0194] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0195] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for processing an image, characterized in that: include: In response to the picture download instruction, calling the first target thread in the main process to download the original picture and the preview picture generated in advance from the server, and displaying the preview picture on the display; Creating a second target thread in the main process, and creating a child process in the second target thread; The second target thread is different from the first target thread; Calling the subprocess to load the original image of the picture, decoding the original image of the picture, and optimizing the size of the decoded image; Calling the main process or the sub-process to render the size-optimized image, and displaying the rendering result on a display; Calling the first target thread in the main process to download a preview image of a pre-generated image from a server includes: Get the size parameters of the display; A preview image matching the size parameters of the display is downloaded in the main process; wherein a plurality of preview images of different sizes are stored in the server.
2. The method according to claim 1, characterized in that The step of optimizing the size of the decoded picture includes: Get the size parameters of the display; Based on the size parameters of the display, the decoded image is scaled using a matrix transformation method.
3. The method according to claim 1, characterized in that Also includes: The subprocess is called to store the image data obtained after size optimization in a shared cache of the main process and the subprocess.
4. The method according to claim 1, characterized in that: Also includes: A plurality of threads are started in the subprocess, and the original image of the image is decoded through the plurality of threads, and the size of the decoded image is optimized.
5. The method according to any one of claims 1 to 4, characterized in that: Also includes: The created subprocess includes one or more.
6. The method according to claim 5, characterized in that In the case that the created sub-process includes a plurality of sub-processes, calling the sub-process to load the original image of the picture, decoding the original image of the picture, and optimizing the size of the decoded image includes: Calling the first subprocess to load the original image of the image; Decoding the original image of the image through a second subprocess; The decoded image is optimized in size through the third sub-process.
7. A picture processing device, characterized in that: include: A main process execution unit, configured to respond to a picture download instruction, call a first target thread in the main process to download a preview image and an original image of a pre-generated picture from a server, and display the preview image on a display; Create a unit, which is used to create a child process; A sub-process execution unit, used for calling the sub-process to load the original image of the picture, decoding the original image of the picture, and optimizing the size of the decoded picture; A display unit, used to call the main process or the sub-process to render the size-optimized picture, and display the rendering result on a display; The main process execution unit includes: A first acquisition subunit, used to acquire size parameters of the display; A download subunit, used for downloading a preview image matching the size parameters of the display in the main process; wherein the server stores a plurality of preview images of different sizes; The creation unit comprises: A first thread creation unit, configured to create a second target thread in the main process; the second target thread is different from the first target thread; The first sub-process creation unit is used to create a sub-process in the second target thread.
8. The device according to claim 7, characterized in that The sub-process execution unit is used to: A second acquisition subunit is used to acquire the size parameters of the display; The scaling processing subunit is used to scale the decoded image using a matrix transformation method based on the size parameters of the display.
9. The device according to claim 7, characterized in that Also includes: The writing sub-unit is used to call the sub-process and write the size-optimized image data into the shared cache of the main process and the sub-process.
10. The device according to claim 7, characterized in that Also includes: The multi-thread control sub-unit is used to start multiple threads in the sub-process, decode the original image of the image through the multiple threads, and optimize the size of the decoded image.
11. The device according to any one of claims 7 to 10, characterized in that: Also includes: The second creation unit is used to create one or more sub-processes.
12. The device according to claim 11, characterized in that The sub-process execution unit includes: A loading sub-unit, used for calling the first sub-process to load the original image of the image; A decoding subunit, configured to decode the original image of the image through a second subprocess; The size optimization subunit is used to optimize the size of the decoded picture through the third sub-process.
13. A terminal device, characterized in that: include: Processor and memory; Wherein, the processor is used to execute the program stored in the memory; The memory is used to store a program, and the program is at least used to: In response to the picture download instruction, calling the first target thread in the main process to download a preview image of the pre-generated picture and the original image of the picture from the server, and displaying the preview image on the display; Creating a second target thread in the main process, and creating a child process in the second target thread; the second target thread is different from the first target thread; Calling the subprocess to load the original image of the picture, decoding the original image of the picture, and optimizing the size of the decoded image; Calling the main process or the sub-process to render the size-optimized image, and displaying the rendering result on a display; Calling the first target thread in the main process to download the preview image of the pre-generated image from the server, including: Get the size parameters of the display; A preview image matching the size parameters of the display is downloaded in the main process; wherein a plurality of preview images of different sizes are stored in the server.
Citation Information
Patent Citations
Picture showing method and device
CN106874485A
Picture display method and device, equipment and storage medium
CN107506119A