A method for generating a transparent image

By comparing the color values ​​of pixel points at the same position on two electronic grid canvases, a binary image indicating transparent areas is generated, which solves the problem of misjudgment in the generation of transparent images in the prior art, and the accurate indication of transparent areas and the display effect is improved.

CN114092603BActive Publication Date: 2025-05-27FOUNDER INT(WUHAN)TECH DEV CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111353258.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-16
Publication Date
2025-05-27
Estimated Expiration
2041-11-16

AI Technical Summary

Technical Problem

When generating transparent images, it is difficult to accurately distinguish between pixel points and transparent points with actual content when the prior art generates a transparent image, which can easily lead to misjudgment and lead to incorrect display effect of the image content.

Method used

By creating two electronic raster canvases, filling and drawing the same content with different colors, comparing the color values ​​of pixel points at the same position on the two canvases, if they are different, they are recorded as transparent points, and the same is the solid content points, and generating a binary image to indicate the transparent area.

Benefits of technology

It realizes accurate indication of transparent areas, accurate to a single pixel, solves the problem of collision errors, and the algorithm is simple and easy to implement, and has nothing to do with the content drawn by the original production software.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114092603B_ABST
    Figure CN114092603B_ABST
Patent Text Reader

Abstract

The present invention provides a method for generating a transparent image. Step 1: Create an electronic grid canvas 1, and select any color A to fill the entire area of the electronic grid canvas 1 as the background. Step 2: Create an electronic grid canvas 2 with the same size as the electronic grid canvas 1, and select another color B to fill the entire area of the electronic grid canvas 2 as the background. Step 3: Perform a point-by-point scan on the pixel dot matrices on the electronic grid canvas 1 and the electronic grid canvas 2, compare the color values of the two pixel points at the same position. When a third-party software performs transparent display, the physical content points are covered by the electronic grid canvas 1 or the electronic grid canvas 2, and no operation is performed at the transparent points, directly proceeding to the next position. The indication of the transparent area is very accurate, accurate to individual pixels, logically completely solving the problem of collision errors, and the algorithm is simple and easy to implement, independent of the content drawn by the original production software.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer image processing, and particularly relates to a method for generating a transparent image. Background Art

[0002] For interactive desktop applications involving the production and processing of pictures, texts, and graphics, rendering and display operations during the process and the final processing result are essential functions. For the software itself, its rendering and display usually read internal data objects and are carried out in a vector drawing manner. However, when the processing result of this software needs to be displayed by other software, the method of relying on the original software to parse and redraw won't work. Usually, this software will depict and generate a picture of the processing result when necessary, and other software will use the picture for display. Since the pictures generated by this kind of depiction are not landscape photos, in the case of not deliberately setting the background board, there are always some areas with actual content and some areas without content, and the overlap between the two has no clear and regular boundary. When being displayed by other software, for the sake of beauty, it is often required that the picture can be transparently displayed, that is, the areas with actual content display the actual content, and the areas without actual content can be transparently displayed, rather than being displayed as a large white background board or a large black background board.

[0003] In the existing software technology, in order to generate a transparent image, usually before drawing, the electronic canvas background board is pre-filled with a color (such as white or black), and then drawing is carried out in a covering manner on the canvas that has been filled with the background color. Due to the characteristics of electronic drawing, the drawn content can completely cover and replace the original background color. Finally, check all the pixel points of the entire canvas. Those with color values the same as the pre-filled background color of the background board are regarded as transparent points without actual drawn content. When other software displays this image in the future, these pixels marked as transparent points will be displayed transparently.

[0004] The defects of the existing technology are obvious. The color of the actual content drawn may be the same as the color pre-filled as the background color (for example, using white or black as the background board color, but there is also white or black in the actual content), resulting in misjudgment, misjudging the pixel points with actual content as transparent points, and thus causing some points with actual content to be wrongly displayed as transparent when finally displayed. This leads to an incorrect display effect of the image content.

[0005] Although some remedial measures can be used for this technical defect, such as using a color that will not be used in the actual drawn content for the pre-filled background board color to avoid misjudgment. However, this kind of remedial measure still cannot completely fill the loophole, because in actual production, the content processed and produced each time is not fixed, and the colors involved in the actual content materials are various, and any background board color cannot rule out the accidental collision with the actual content color. Summary of the Invention

[0006] In view of the technical problems existing in the prior art, the present invention provides a method for generating a transparent image, which can accurately indicate the transparent area down to a single pixel, logically and thoroughly solve the problem of collision errors, and has a simple algorithm, is easy to implement, and has nothing to do with the content drawn by the original production software.

[0007] The technical solution of the present invention to solve the above technical problems is as follows: A method for generating a transparent image, which includes the following steps:

[0008] Step 1: Create an electronic grid canvas 1, and select any color A to fill the electronic grid canvas 1 globally as the background. After the filling is completed, perform a complete drawing on the electronic grid canvas 1 through the software rendering drawing module function. After the drawing is completed, save the electronic grid canvas 1;

[0009] Step 2: Create an electronic grid canvas 2 with the same size as the electronic grid canvas 1, select another color B to fill the electronic grid canvas 2 globally as the background, and use the software rendering drawing module function to perform a complete drawing on the electronic grid canvas 2. The drawn entity content is the same as that drawn in Step 1. After the drawing is completed, save the electronic grid canvas 2;

[0010] Step 3: Scan the pixel dot matrices on the electronic grid canvas 1 and the electronic grid canvas 2 point by point, and compare the color values of two pixel points at the same position. If the color values of two pixel points at the same position on the electronic grid canvas 1 and the electronic grid canvas 2 are different, then this point is recorded as a transparent point. If the color values of two pixel points at the same position on the electronic grid canvas 1 and the electronic grid canvas 2 are the same, then it is an entity content point. Record the result of the scanning and comparison as a result matrix with the same size as the electronic grid canvas 1 or the electronic grid canvas 2;

[0011] Step 4: Generate a binary image with the same pixels as the electronic grid canvas 1 or the electronic grid canvas 2 from the result matrix, and at the same time display the content using the binary image and the content in the electronic grid canvas 1 or the electronic grid canvas 2. When a third-party software performs transparent display, the entity content points are covered with the entity content of the electronic grid canvas 1 or the electronic grid canvas 2, and no operation is performed at the transparent points, and directly proceed to the next position.

[0012] Based on the above technical solution, the present invention can also be improved as follows.

[0013] Optionally, the pixel points of the entity content drawn in the electronic grid canvas 1 in Step 1 and the electronic grid canvas 2 in Step 2 are replaced with the color represented by the entity content, and the pixel points in the un-drawn area retain the corresponding filling color.

[0014] Optionally, the result matrix generated when scanning and comparing the pixel points on the two electronic grid canvases in step three is a two-dimensional matrix of M*N. When scanning and comparing all pixel points, if the scanning and comparing result is a transparent point, the recorded value at this position is 0. If the scanning and comparing result is a solid content point, the recorded value at this position is 1, and the recorded value is filled into the result matrix.

[0015] Optionally, the content in electronic grid canvas one or electronic grid canvas two is defined as the original image, and the binary image is the mask image. The mask image indicates the position of the transparent area. When using third-party software for transparent display, scan the corresponding two-dimensional matrix of the mask image. Among them, a filled value of 1 indicates that this point is a solid content point. Take out the pixel value at the position of this solid content in the original image and fill it in the corresponding position of the newly drawn canvas of the third-party software in a covering manner. If the filled value is 0, directly proceed to scan the next position.

[0016] Optionally, after one scan is completed, all the solid content in the original image is covered on the newly drawn canvas of the third-party software, and the transparent positions remain the original content of the new canvas, realizing the transparent display of the third-party software. Description of the Drawings

[0017] Figure 1 It is a schematic flowchart of a method for generating a transparent image according to the present invention. Detailed Embodiments

[0018] The following will further describe in detail the specific embodiments of the present invention in conjunction with the drawings and embodiments. The following embodiments are used to illustrate the present invention, but are not used to limit the scope of the present invention.

[0019] In the description of the present invention, unless otherwise specified and limited, it should be noted that the terms "installation", "connection", and "connection" should be understood in a broad sense. For example, it can be a mechanical connection or an electrical connection, or it can be the communication inside two components. It can be directly connected or indirectly connected through an intermediate medium. For those of ordinary skill in the art, the specific meanings of the above terms can be understood according to specific situations.

[0020] Figure 1 It is a schematic flowchart of a method for generating a transparent image provided by the present invention. As Figure 1 shown, a method for generating a transparent image disclosed in this embodiment includes the following steps:

[0021] Step one: Create electronic grid canvas one, and select any color A to fill the entire area of electronic grid canvas one as the background. After the filling is completed, perform a complete drawing on electronic grid canvas one through the software rendering drawing module function. After the drawing is completed, save electronic grid canvas one;

[0022] Step 2: Create an electronic grid canvas 2 with the same size as the electronic grid canvas 1. Select another color B to fill the entire area of the electronic grid canvas 2 as the background, and use the software rendering and drawing module function to perform a complete drawing on the electronic grid canvas 2. The drawn entity content is the same as that drawn in Step 1. After the drawing is completed, save the electronic grid canvas 2;

[0023] Step 3: Scan the pixel dot matrices on the electronic grid canvas 1 and the electronic grid canvas 2 point by point, and compare the color values of the two pixel dots at the same position. If the color values of the two pixel dots at the same position on the electronic grid canvas 1 and the electronic grid canvas 2 are different, then this point is marked as a transparent point. If the color values of the two pixel dots at the same position on the electronic grid canvas 1 and the electronic grid canvas 2 are the same, then it is an entity content point. Record the result of the scanning and comparison as a result matrix with the same size as the electronic grid canvas 1 or the electronic grid canvas 2;

[0024] Step 4: Generate a binary image with the same pixels as the electronic grid canvas 1 or the electronic grid canvas 2 from the result matrix, and at the same time display the content using the binary image and the content in the electronic grid canvas 1 or the electronic grid canvas 2. When the third-party software performs transparent display, the entity content points are covered with the entity content of the electronic grid canvas 1 or the electronic grid canvas 2, and no operation is performed at the transparent points, and directly proceed to the next position.

[0025] It can be understood that during the drawing process of the software, when preparing the electronic grid canvas, first fill the entire range of the canvas with color A (such as white) uniformly, and let the software rendering and drawing module function perform a complete drawing on this canvas, just like normal display drawing. After the drawing is completed, temporarily save this canvas first. Due to the existing characteristics of electronic drawing, during the drawing process, the pixel dots at the positions with actual content on the canvas are replaced with the colors represented by the actual content, and the pixel dots in the un-drawn areas still retain the initial filled color (color A).

[0026] After the first drawing is completed, replace the canvas and prepare a new electronic grid canvas of the same size. Fill the entire range of the canvas with color B (such as black) uniformly, and let the software rendering function perform a complete drawing on this new canvas again, just like normal display drawing. After the drawing is completed, also temporarily save this canvas. Due to the existing characteristics of electronic drawing, during the drawing process, the pixel dots at the positions with actual content on the canvas are replaced with the colors represented by the actual content, and the pixel dots in the un-drawn areas still retain the initial filled color (color B).

[0027] For the first canvas and the second canvas saved after the above steps, perform a point-by-point scan in the form of pixels. Since it is the same drawing method, the sizes of canvas one and canvas two are exactly the same. All the pixels on one canvas can be regarded as a two-dimensional matrix of M*N. Scan this matrix one by one, take out the color values of the pixels at the same position on the two canvases and compare them. If the color value of the pixel taken out on canvas one is color A, and the color value of the pixel at the same position taken out on canvas two is B (that is, the color values of the two pixels at the same position are different), then it is considered that the point at this position is a transparent point, and a new M*N matrix is established to record the comparison result. If it is judged that this point is a transparent point, then record a value of 0 at the same position in the result matrix. If the color value of the pixel taken out on canvas one is the same as the color value of the pixel at the same position taken out on canvas two, then it is considered that the point at this position is a point with actual content, a non-transparent point. Record 1 at the same position in the result matrix. Scan the pixel matrix of the entire canvas, complete the comparison of all pixels, and fill the comparison results into the result matrix.

[0028] Generate a binary image with M*N pixels from the M*N result matrix. Each pixel of this image can only have two values, 1 or 0, and it is called a mask image. Use this image to indicate the position of the transparent area. You can take either canvas one or canvas two to generate an original content image with M*N pixels. The color value of each pixel in the original image is the color value of the pixel at the same position on the electronic canvas.

[0029] When a third-party software needs to perform transparent display, the generated original image and mask image can be used in combination. That is, the pixels of both images are M*N matrices. Scan the matrix of the mask image. If the value filled in the pixel is 1, then it means that this point is a solid content point, take out the pixel value at this position in the original image, and fill it in the corresponding position of the new canvas drawn by the third-party software in a covering manner. If the value filled in the pixel of the mask image matrix is 0, then it means that this point is a transparent point, and no operation is performed and go to the next position. After a scan is completed, the solid content in the original image has been drawn into the new canvas, and the transparent positions display the original content of the new canvas. Thus, the transparent display of the third party is completed.

[0030] It can be understood that this solution is mainly used for the pictures generated by self-drawing of application software involved in text, image, and graphic production and processing to accurately indicate the content entity area and background area in the picture, so that the third-party software can only display the solid content in a transparent manner, filter the background, and improve the aesthetics. The indication of the transparent area is very accurate, accurate to a single pixel, logically completely solves the problem of collision errors, and the algorithm is simple and easy to implement, and has nothing to do with the drawing content of the original production software.

[0031] In a possible embodiment, the pixel points of the entity content drawn on the electronic grid canvas 1 in the first step and the electronic grid canvas 2 in the second step are replaced with the colors represented by the entity content, and the pixel points in the un-drawn areas retain the corresponding filling colors.

[0032] It can be understood that the pixel points with entity content in the electronic grid canvas 1 and the electronic grid canvas 2 are covered by the entity content, while the un-drawn areas still retain the filling colors to distinguish the entity content from the transparent areas.

[0033] In a possible embodiment, the result matrix generated when scanning and comparing the pixel points on the two electronic grid canvases in the third step is a two-dimensional matrix of M*N. When scanning and comparing all pixel points, if the scanning and comparing result is a transparent point, the recorded value at this position is 0, and if the scanning and comparing result is an entity content point, the recorded value at this position is 1, and the recorded value is filled into the result matrix.

[0034] It can be understood that in this embodiment, a binary image is used to record and process all pixel points. Specifically, each pixel point is scanned once. During the scanning, if the pixel point is a transparent point, it is recorded as 0, otherwise it is recorded as 1. When subsequently determining whether the point is a transparent point or an entity content point, only the recorded value needs to be judged.

[0035] In a possible embodiment, the content in the electronic grid canvas 1 or the electronic grid canvas 2 is defined as the original image, and the binary image is the mask image. The mask image indicates the positions of the transparent areas. When using a third-party software for transparent display, the corresponding two-dimensional matrix of the mask image is scanned. Among them, a filled value of 1 indicates that this point is an entity content point, and the pixel value at this position in the original image is taken out and filled in the corresponding position of the new canvas in a covering manner. If the filled value is 0, it directly proceeds to scan the next position.

[0036] It can be understood that the pixel value at the position with a filled value of 1 recorded in the original image is taken out, and this point is the entity content point. During processing, the drawn content of the entity content point is taken out for use when performing transparent display through a third-party software.

[0037] In a possible embodiment, after one scan is completed, all the entity content in the original image is covered on the newly drawn canvas, and the original content of the new canvas is displayed at the transparent positions, realizing the transparent display of the third-party software.

[0038] It can be understood that the entity content points scanned in the original image are covered on the newly drawn canvas. Therefore, when displaying, only the entity content part with a scanning result of 1 is displayed, and the remaining positions are displayed as transparent points.

[0039] It should be noted that in the above embodiments, the descriptions of each embodiment have their own emphases. For parts not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0040] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, a system, or a computer program product. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0041] The present invention is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to the embodiments of the present invention. It should be understood that each flow and / or block in the flowchart and / or block diagram, as well as the combination of flows and / or blocks in the flowchart and / or block diagram, can be realized by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded computer, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for realizing the functions specified in Figure 1 one or more of the flows Figure 1 or blocks or the combination of blocks.

[0042] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured article including an instruction device, and the instruction device realizes the functions specified in Figure 1 one or more of the flows Figure 1 or blocks or the combination of blocks.

[0043] These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for realizing the functions specified in Figure 1 one or more of the flows Figure 1 or blocks or the combination of blocks.

[0044] Although the preferred embodiments of the present invention have been described, additional changes and modifications can be made to these embodiments by those skilled in the art once they learn the basic inventive concept. Therefore, the appended claims are intended to be construed to include the preferred embodiments as well as all changes and modifications falling within the scope of the present invention.

[0045] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalent technologies, the present invention is also intended to include these modifications and variations.

Claims

1. A method for generating a transparent image, characterized in that, it includes the following steps: Step 1: Create an electronic grid canvas 1, and select any color A to fill the entire area of the electronic grid canvas 1 as the background. After the filling is completed, perform a complete drawing on the electronic grid canvas 1 through the software rendering drawing module function. After the drawing is completed, save the electronic grid canvas 1; Step 2: Create an electronic grid canvas 2 with the same size as the electronic grid canvas 1, select another color B to fill the entire area of the electronic grid canvas 2 as the background, and use the software rendering drawing module function to perform a complete drawing on the electronic grid canvas 2. The physical content drawn is the same as that drawn in Step 1. After the drawing is completed, save the electronic grid canvas 2; Step 3: Perform a point-by-point scan of the pixel dot matrices on the electronic grid canvas 1 and the electronic grid canvas 2, and compare the color values of two pixel points at the same position. If the color values of two pixel points at the same position on the electronic grid canvas 1 and the electronic grid canvas 2 are different, then this point is recorded as a transparent point. If the color values of two pixel points at the same position on the electronic grid canvas 1 and the electronic grid canvas 2 are the same, then it is a physical content point. Record the result of the scan comparison as a result matrix with the same size as the electronic grid canvas 1 or the electronic grid canvas 2; Step 4: Generate a binary image with the same pixels as the electronic grid canvas 1 or the electronic grid canvas 2. Each pixel in the binary image is 1 or 0. A pixel of 1 represents a physical content point, and a pixel of 0 represents a transparent point. At the same time, display the content of the binary image and the electronic grid canvas 1 or the electronic grid canvas 2. When a third-party software performs transparent display, the physical content points are covered with the physical content of the electronic grid canvas 1 or the electronic grid canvas 2, and no operation is performed at the transparent points, and directly proceed to the next position; Wherein, the pixel points of the physical content drawn in the electronic grid canvas 1 in Step 1 and the electronic grid canvas 2 in Step 2 are replaced with the color represented by the physical content, and the pixel points in the un-drawn areas retain the corresponding filling colors; Wherein, the display using the binary image and the content of the electronic grid canvas 1 or the electronic grid canvas 2 in Step 4 includes: Define the content of the electronic grid canvas 1 or the electronic grid canvas 2 as the original image, and the binary image as the mask image. The mask image indicates the position of the transparent area. When using a third-party software for transparent display, scan the corresponding two-dimensional matrix of the mask image. Among them, a filled value of 1 indicates that this point is a physical content point, take out the pixel value at the position of this physical content in the original image, and fill it in the corresponding position of the new drawing canvas of the third-party software in a covering manner. If the filled value is 0, directly proceed to the scan of the next position.

2. A method for generating a transparent image according to claim 1, characterized in that, The result matrix generated when the pixel points on the two electronic grid canvases are scanned and compared in the third step is a two-dimensional matrix of M*N. When all pixel points are scanned and compared, if the scanning and comparison result is a transparent point, the recorded value at that position is 0. If the scanning and comparison result is a solid content point, the recorded value at that position is 1, and the recorded value is filled into the result matrix.

3. A method for generating a transparent image according to claim 1, characterized in that, After one scan is completed, all the solid content in the original image is covered in the canvas newly drawn by the third-party software, and the original content in the new canvas is displayed at the transparent positions, realizing the transparent display of the third-party software.

Citation Information

Patent Citations

  • Raster image processing method and device

    CN104240273A

  • Method and system for ink data generation, ink data rendering, ink data manipulation and ink data communication

    CN106170748A