A document watermark automatic generation method and terminal

CN117573048BActive Publication Date: 2026-10-13FUJIAN CENTM INFORMATION
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311507369.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-13
Publication Date
2026-10-13
Estimated Expiration
2043-11-13

AI Technical Summary

Technical Problem

通过这些水印内容可以很容易地追溯打印文档的来源,但是添加好水印之后再打印会影响文档在电子屏幕上的显示,而在打印阶段添加水印会增加设备端的负担

Benefits of technology

[0017]本发明的有益效果在于:根据打印机固定的打印长度和打印宽度建立对应大小的内存位图,将需要打印的目标页数据以及水印数据渲染到内存位图中,因内存位图的大小是根据打印长度和打印宽度建立的,而对于打印机而言,打印长度和打印宽度通常是确定的,故最终渲染位图的大小也是确定的,不会因为水印数据的增加而造成图片过大,减少了打印过程中的数据处理量,从而提高了打印的效率,加快添加水印的处理速度。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117573048B_ABST
    Figure CN117573048B_ABST
Patent Text Reader

Abstract

The application discloses a watermark automatic generation method and a terminal, which acquires target page data and watermark data, wherein the target page data comprises page content, page length and page width; printing length and printing width are acquired, and a memory bitmap is created according to the printing length and the printing width; the page content is rendered into the memory bitmap according to the page length and the page width, and the watermark data is rendered into the memory bitmap, so as to obtain a rendered bitmap; the rendered bitmap is converted into a printing format and printed; the target page data and the watermark data which need to be printed are rendered into the memory bitmap; the size of the memory bitmap is established according to the printing length and the printing width; the printing length and the printing width are usually determined for a printer; therefore, the size of the final rendered bitmap is also determined, the picture is not too large due to the increase of the watermark data, the data processing amount in the printing process is reduced, the printing efficiency is improved, and the processing speed of adding the watermark is accelerated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of watermark generation, and more particularly to an automatic watermark generation method and terminal. Background Technology

[0002] With the rapid development of digital technology, many industries and individuals now widely use electronic documents to process and store information, and often print or photocopy the content of these electronic documents onto paper for reading and dissemination. However, for enterprises and organizations dealing with confidential information (such as contracts, financial documents, and other important documents), much important or confidential information may be leaked through these paper documents and given to malicious third parties, causing losses to the enterprise.

[0003] To avoid this risky practice, employees add watermarks to printed documents. These watermarks typically display the employee's ID, printing date, and other information. While this makes it easy to trace the document's origin, adding watermarks before printing can negatively impact the document's display on electronic screens, and it also increases the workload on the printing equipment. Summary of the Invention

[0004] The technical problem to be solved by the present invention is to provide a method and terminal for automatic watermark generation, so as to improve the processing speed of adding watermarks during printing.

[0005] To solve the above-mentioned technical problems, the present invention adopts the following technical solution:

[0006] A method for automatically generating watermarks, comprising the following steps:

[0007] Obtain target page data and watermark data, wherein the target page data includes page content, page length, and page width;

[0008] Obtain the print length and print width, and create a memory bitmap based on the print length and print width;

[0009] The page content is rendered into the memory bitmap based on the page length and page width, and the watermark data is also rendered into the memory bitmap to obtain the rendered bitmap;

[0010] Convert the rendered bitmap to a printable format and print it.

[0011] To solve the above-mentioned technical problems, another technical solution adopted by the present invention is as follows:

[0012] A watermark automatic generation terminal includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it performs the following steps:

[0013] Obtain target page data and watermark data, wherein the target page data includes page content, page length, and page width;

[0014] Obtain the print length and print width, and create a memory bitmap based on the print length and print width;

[0015] The page content is rendered into the memory bitmap based on the page length and page width, and the watermark data is also rendered into the memory bitmap to obtain the rendered bitmap;

[0016] Convert the rendered bitmap to a printable format and print it.

[0017] The beneficial effects of this invention are as follows: a memory bitmap of corresponding size is established according to the fixed printing length and printing width of the printer, and the target page data to be printed and the watermark data are rendered into the memory bitmap. Since the size of the memory bitmap is established according to the printing length and printing width, and for the printer, the printing length and printing width are usually fixed, the size of the final rendered bitmap is also fixed. The image will not become too large due to the increase of watermark data, thereby reducing the amount of data processing in the printing process, thus improving printing efficiency and speeding up the watermark addition process. Attached Figure Description

[0018] Figure 1 This is a flowchart illustrating the steps of an automatic watermark generation method according to an embodiment of the present invention.

[0019] Figure 2 A flowchart illustrating the application of an automatic watermark generation method according to an embodiment of the present invention in a real-world scenario;

[0020] Figure 3 This is a schematic diagram of the structure of an automatic watermark generation terminal according to an embodiment of the present invention;

[0021] Label Explanation:

[0022] 1. A watermark automatic generation terminal; 2. Processor; 3. Memory. Detailed Implementation

[0023] To explain in detail the technical content, objectives, and effects of the present invention, the following description is provided in conjunction with the embodiments and accompanying drawings.

[0024] Please refer to Figure 1 A method for automatically generating watermarks, comprising the following steps:

[0025] Obtain target page data and watermark data, wherein the target page data includes page content, page length, and page width;

[0026] Obtain the print length and print width, and create a memory bitmap based on the print length and print width;

[0027] The page content is rendered into the memory bitmap based on the page length and page width, and the watermark data is also rendered into the memory bitmap to obtain the rendered bitmap;

[0028] Convert the rendered bitmap to a printable format and print it.

[0029] As can be seen from the above description, the beneficial effects of the present invention are as follows: a memory bitmap of corresponding size is established according to the fixed printing length and printing width of the printer, and the target page data to be printed and the watermark data are rendered into the memory bitmap. Since the size of the memory bitmap is established according to the printing length and printing width, and for the printer, the printing length and printing width are usually fixed, the size of the final rendered bitmap is also fixed. The image will not become too large due to the increase of watermark data, thereby reducing the amount of data processing in the printing process, thus improving the printing efficiency and speeding up the watermark addition process.

[0030] Furthermore, the watermark data includes rotation angle, position coordinates, and watermark content;

[0031] The step of rendering the watermark data into the memory bitmap includes:

[0032] Convert the watermark content into a watermark bitmap;

[0033] Rotate the watermark bitmap according to the rotation angle;

[0034] The step of rendering the watermark data into the memory bitmap includes:

[0035] The rotated watermark bitmap is rendered onto the memory bitmap based on the position coordinates.

[0036] As described above, before rendering the watermark data into the memory bitmap, the watermark content is first converted into a watermark bitmap to ensure that the clear image of the watermark content is not lost during subsequent zooming / scaling / stretching. Then, the watermark is rotated according to a preset rotation angle to form an angle between the watermark and the content on the page to be printed, preventing the watermark from covering the page content after rendering. Finally, the watermark bitmap is rendered into the memory bitmap according to the coordinate position to achieve integration with the target page.

[0037] Furthermore, rendering the watermark data into the memory bitmap includes:

[0038] If, when rendering the watermark pixels of the watermark data, the target rendering position of the watermark pixel has already rendered the page pixels of the page content, then the pixel value of the page pixel and the pixel value of the watermark pixel are fused together using a pixel fusion algorithm to obtain the target pixel value.

[0039] Update the pixel at the target rendering position based on the target pixel value.

[0040] As described above, when rendering watermark pixels of watermark data, if the page pixels of the page content have already been rendered at the target rendering position, directly overwriting the page pixels with watermark pixels may cause the loss of page content. If page pixels are used directly, the watermark will be blurred at the corresponding position. In this case, both watermark pixels and page pixels are considered simultaneously, and the two are fused together using a pixel fusion algorithm to obtain the target pixel value. The target pixel value is used as the pixel value of the pixel at the target rendering position. This can find a balance between the information expressed by the watermark pixels and the information expressed by the page pixels, thus improving the final printing effect.

[0041] Further, the step of fusing the pixel value of the page pixel and the pixel value of the watermark pixel using a pixel fusion algorithm to obtain the target pixel value includes:

[0042] If the page pixel is a blank pixel, then the watermark pixel is directly used as the target pixel value after fusion;

[0043] Otherwise, obtain the transparency stored in the watermark data, and weight the pixel value of the watermark pixel and the pixel value of the page pixel according to the transparency;

[0044] The target pixel value is obtained by fusing the weighted pixel values ​​of the watermark pixels and the pixel values ​​of the page pixels.

[0045] As described above, if a page pixel is blank, it means that the page pixel at the target rendering location does not contain any information. In this case, there is no need to consider the page pixel, and the watermark pixel can be used directly instead. If the page pixel is not blank, it means that the target rendering location needs to consider the information in both the page pixel and the watermark pixel. In this case, the page pixel and the watermark pixel are merged, and the information expression of both is considered in combination to improve the quality of the final display.

[0046] Further, the weighting of the pixel values ​​of the watermark pixel and the page pixel based on the transparency includes:

[0047] w1 = transparent;

[0048] w2 = 1 - transparent;

[0049] Where w1 represents the weight of the pixel value of the watermark pixel; w2 represents the weight of the pixel value of the page pixel; and transparent represents the transparency.

[0050] The target pixel value is obtained by combining the weighted watermark pixel value and the page pixel value.

[0051] p = p1 × w1 + p2 × w2;

[0052] Where p represents the target pixel value, p1 represents the pixel value of the watermark pixel at the target rendering position, and p2 represents the pixel value of the page pixel at the target rendering position.

[0053] As described above, if the watermark is too heavy during rendering, it will affect the reading experience of the document itself. Therefore, a transparency is usually set for the watermark. This requires merging the pixels of the watermark and the document itself during rendering. In this invention, the transparency of the watermark pixels and the transparency of the page pixels are combined to form a complete weight. The watermark pixels and page pixels are weighted according to the transparency to obtain the final pixel value. If the transparency is set high, the weight in the fusion process is low, thereby reducing the impact on the content of the document while displaying the watermark completely, and avoiding the watermark affecting the viewing of the document content.

[0054] Furthermore, after updating the pixel at the target rendering position based on the target pixel value, the process further includes:

[0055] Obtain the neighboring pixels of the pixel;

[0056] Calculate the difference between the target pixel value and the neighbor pixel values ​​of each neighbor pixel;

[0057] If the number of neighboring pixels whose difference exceeds a preset difference exceeds a preset number, then a smoothing calculation is performed on the pixels.

[0058] As described above, after updating the pixels at the target rendering position, its neighboring pixels are also obtained. If the difference is too large and the number of large differences exceeds the preset number, it indicates that an error has occurred during the rendering process, and there are granular noises on the image. Smoothing calculations on the pixels can avoid the appearance of noise on the image after rendering.

[0059] Furthermore, the smoothing calculation for the pixel points includes:

[0060] The pixels and their neighboring pixels are sorted in order of pixel value size to obtain a pixel value queue;

[0061] Obtain the median of the pixel value queue, and update the pixel at the target rendering position based on the median.

[0062] As described above, smoothing based on the median of the pixel value queue can identify pixel values ​​that have appeared among neighboring pixels, thus avoiding the situation where abrupt noise appears after recalculating a new pixel value.

[0063] Further, the step of performing smoothing calculations on the pixels if the number of neighboring pixels whose difference exceeds a preset difference exceeds a preset number includes:

[0064] Obtain the neighboring pixels of the pixel;

[0065] Subtract the pixel values ​​of each neighboring pixel from each other and take the absolute value to obtain multiple relative differences;

[0066] Obtain the maximum difference among the relative differences, and use a preset multiple of the maximum difference as the preset difference.

[0067] As described above, the preset difference dynamically adjusts the corresponding neighboring pixels based on different pixels. Since the pixel values ​​at different locations on the image may vary greatly, a uniform preset difference cannot adapt to all situations in the image. However, determining the preset difference based on the actual situation of the neighboring pixels around the pixel is more suitable for adjusting local pixels in the image and can also distinguish noise from pixel values ​​in the normal image. For example, the edge of a character will not be recognized as noise, further improving the quality of the final image.

[0068] Further, the step of converting the rendered bitmap to a print format and printing it includes:

[0069] Convert the rendered bitmap into a vector graphics file and print it.

[0070] As described above, by converting to a vector graphics file format for printing, the printing effect will not be affected by the resolution change, and high-definition printing results can be maintained.

[0071] Please refer to Figure 3 A watermark automatic generation terminal includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the various steps of the above-described watermark automatic generation method.

[0072] In the current printing process, adding a watermark during printing typically involves reading the watermark content from the print document, converting each watermark as an object into a vector graphics file (e.g., GDI) via an image device interface, and storing the various attributes of each watermark object in the vector graphics file (e.g., EMF). Next, a print spool queue (a queue in the printing system used to store user print requests) is used. User-submitted print requests are stored in this queue, and the system print process (responsible for reading the print document content and rendering it to the printer) prints the files in the queue sequentially. The print driver interface is then called to parse the vector graphics file into a Raw file, which is then sent to the printer via a port service. During the conversion of the print document into a vector graphics file, each watermark is transformed into a graphic object within the vector graphics file. These graphic objects contain various attributes, including color, line style, fill mode, font and text content, position, size, and rotation angle. When there are many watermarks, storing the attribute information of each watermark graphic object in the file results in a very large data file. The large data volume slows down the conversion to Raw files in subsequent steps, and the Raw files themselves are also very large, taking a long time to send to the printer, resulting in an overall slow printing speed. The watermark automatic generation method and terminal described above are applicable to scenarios where watermarks need to be added to printed documents, and will be explained below through specific implementation methods.

[0073] Please refer to Figure 1 Embodiment 1 of the present invention is as follows:

[0074] A method for automatically generating watermarks, comprising the following steps:

[0075] S1. Obtain target page data and watermark data, wherein the target page data includes page content, page length, and page width;

[0076] In one optional implementation, the watermark data includes rotation angle, position coordinates, and watermark content; the rotation angle can be preset, and the backend administrator can pre-configure the watermark parameters, including watermark content, watermark font, transparency, and the rotation angle of the watermark text.

[0077] In one alternative implementation, FPDF_LoadPage() is called with a document object passed in to obtain the document's printed page data (pageData), and FPDF_GetPageWidth() and FPDF_GetPageHeight() are used to obtain the width (pageWidth) and height (pageHeight) of the document page, respectively.

[0078] S2. Obtain the print length and print width, and create a memory bitmap based on the print length and print width;

[0079] In one alternative implementation, GetDeviceCaps() is called to obtain the print width (deviceWidth) and print height (deviceHeight) of the printer device; a memory bitmap with the same width and height as the printer device is created, and the background color of the memory bitmap is set to transparent to prevent other colors from affecting the document rendering result;

[0080] S3. Render the page content into the memory bitmap according to the page length and page width, and render the watermark data into the memory bitmap to obtain the rendered bitmap;

[0081] In one alternative implementation, the print page data is rendered to a memory bitmap by calling FPDF_RenderPageBitmap(). This method requires a memory bitmap, print page data (pageData), print width (deviceWidth), and print height (deviceHeight) as input. After rendering by this method, the print page data, including all watermarks and page content, will be converted into bitmap data. At the same time, the print page content is scaled to the bitmap size according to the ratio of the print page width and height to the bitmap width and height. The size of the bitmap is fixed in pixels equal to the product of the print width (deviceWidth) and the print height (deviceHeight).

[0082] Rendering the watermark data into a memory bitmap includes:

[0083] S31. Convert the watermark content into a watermark bitmap;

[0084] S32. Rotate the watermark bitmap according to the rotation angle: Perform pixel rotation transformation on the watermark bmp bitmap. The transformation only changes the pixel position, and the pixel value remains unchanged. For example, if the coordinates of a certain pixel point before rotation are (x1, y1) and the coordinates of the pixel point after rotation are (x2, y2), and the rotation angle is α, then: x2=x1×cosα-y1×sinα, y2=x1×cosα+y1×sinα; Here, the rotation formula is a distance, and other formulas that can achieve rotation transformation can be used, which are not restricted here;

[0085] S33. Rendering the rotated watermark bitmap onto the memory bitmap according to the position coordinates, including:

[0086] S331. If, when rendering the watermark pixel of the watermark data (which becomes the watermark pixel in the watermark bitmap after conversion), the target rendering position of the watermark pixel has already rendered the page pixel of the page content, then the pixel value of the page pixel and the pixel value of the watermark pixel are fused together using a pixel fusion algorithm to obtain the target pixel value.

[0087] In one optional implementation, if the watermark pixel is a blank point, the page pixel is used directly. Because the watermark bitmap is rotated in S32, some blank points will appear in the rotated watermark bitmap, that is, some points in the transformed image do not have corresponding pixels in the original image. Specifically, if the rotation angle is a multiple of 90 degrees, the pixels before and after the rotation are in one-to-one correspondence. However, if a rotation angle such as 30 degrees is selected, the pixels before and after the rotation will not be in one-to-one correspondence. According to the rotation formula, the coordinate point value after rotation is not an integer, but the coordinates must be rounded during the printing process. The calculated coordinates are rounded to the nearest integer, so some points after rotation do not have corresponding points before rotation.

[0088] In one optional implementation, fusing the pixel values ​​of the page pixels and the watermark pixels using a pixel fusion algorithm to obtain the target pixel value includes:

[0089] (1) If the page pixel is a blank pixel, the watermark pixel is directly used as the target pixel value after fusion; the blank pixel means that the page pixel is the background color (for example, the background color of the document is usually white), or the page pixel does not have a corresponding pixel value.

[0090] (2) Otherwise, obtain the transparency stored in the watermark data, and weight the pixel values ​​of the watermark pixels and the page pixels according to the transparency:

[0091] w1 = transparent;

[0092] w2 = 1 - transparent;

[0093] Where w1 represents the weight of the pixel value of the watermark pixel; w2 represents the weight of the pixel value of the page pixel; and transparent represents the transparency.

[0094] (3) Combine the weighted pixel values ​​of the watermark pixels with the pixel values ​​of the page pixels to obtain the target pixel value:

[0095] p = p1 × w1 + p2 × w2;

[0096] Where p represents the target pixel value, p1 represents the pixel value of the watermark pixel at the target rendering position, and p2 represents the pixel value of the page pixel at the target rendering position.

[0097] S332. Update the pixel at the target rendering position according to the target pixel value;

[0098] S333, Denoise the pixels at the target rendering location:

[0099] (1) Obtain the neighboring pixels of the pixel;

[0100] (2) Calculate the difference between the target pixel value and the neighbor pixel value of each neighbor pixel;

[0101] (3) If the number of neighboring pixels whose difference exceeds the preset difference exceeds the preset number, then execute (4);

[0102] In one optional implementation, the method for calculating the preset difference is as follows: obtain the neighboring pixels of the pixel; subtract the pixel values ​​of the neighboring pixels from each other and take the absolute value to obtain multiple relative differences; obtain the maximum difference among the relative differences, and use a preset multiple of the maximum difference as the preset difference;

[0103] For example, the function is set to execute only when the difference between the pixel and all neighboring pixels exceeds a preset difference (4);

[0104] In one optional implementation, four neighboring pixels (up, down, left, right) or eight neighboring pixels surrounding a pixel can be obtained. Taking four neighboring pixels (p1, p2, p3, p4) as an example, multiple relative differences a1 = |p1-p2|, a2 = |p1-p3|, a3 = |p1-p4|, a4 = |p2-p3|, a5 = |p2-p4|, a6 = |p3-p4| are calculated. If a2 is the largest and the preset multiple is 3, then a2 × 3 is taken as the preset difference value. The pixel is corrected using the surrounding points that have already been determined, which ensures the local image display effect and is closer to the real value.

[0105] (4) Perform smoothing calculation on the pixel: Sort the pixel and its neighboring pixels in order of pixel value size to obtain a pixel value queue; obtain the median of the pixel value queue, and update the pixel at the target rendering position according to the median;

[0106] Repeat steps S31 to S33 until all watermark bitmaps have been rendered.

[0107] S4. Convert the rendered bitmap to print format and print it. After printing one target page in the document, return to S1 to obtain the data for the next target page, until there is no more data for the next target page, i.e., all pages in the document have been printed, including:

[0108] S41. Call StartPage() and pass in the printer device context. At this point, the printing system begins to prepare to print a new page.

[0109] S42. The rendered bitmap is rendered to the printer device context using StretchDIBits(). This method takes the rendered bitmap, the printer device context (printDC), and the pixel combination mode as input. The printing of the new page is then ended using EndPage(). At this point, the printing system converts the rendered bitmap data into a vector graphics file. Because the size of the bitmap in the converted vector graphics file is fixed as the product of the print width (deviceWidth) and print height (deviceHeight), the size of all vector graphics files is also fixed and will not increase with the amount of watermark. Vector graphics files are intermediate files used by the system for printing.

[0110] Please refer to Figure 2 Embodiment two of the present invention is as follows:

[0111] The steps preceding step S1 also include:

[0112] 1. Create a print device context by calling CreateDC(). The function returns the printer context (printerDC) upon successful creation. This function (CreateDC()) requires the printer name as input. A print device context is a data structure that defines a set of graphical objects and their properties, affecting the output. Windows provides a device context table for interaction between applications and physical devices, thus providing platform independence for application design.

[0113] 2. Call StartDoc() to create a print job for the printer. The function corresponding to this print job needs to be passed the printer device context (printerDC).

[0114] 3. Call SetPrinter() to set printer parameters such as print resolution, paper source, paper orientation, etc.

[0115] 4. Initialize the FPDFSDK library (for PDF document parsing), and pass the print document address to FPDF_LoadDocument() to create a document object. The document object will be used for subsequent reading of document information and obtaining document content.

[0116] 5. Call FPDF_GetPageCount() to get the total number of pages (pageNumber) of the printed document. This function requires the printed document object as input.

[0117] 6. Then, print each page of the document object in a loop, with each loop including the steps of Example 1;

[0118] 7. Once all pages have been printed, printing ends and resources are reclaimed. Call `EndDoc()` to terminate the print job, delete the print device context (printerDC), and close the document object. The entire printing process is now complete.

[0119] Please refer to Figure 3 Embodiment 3 of the present invention is as follows:

[0120] A watermark automatic generation terminal 1 includes a processor 2, a memory 3, and a computer program stored in the memory 3 and executable on the processor 2. When the processor 2 executes the computer program, it implements the steps in Embodiment 1.

[0121] In summary, this invention provides an automatic watermark generation method and terminal. By setting a fixed-size memory bitmap, the target page and watermark from the document to be printed are rendered into this memory bitmap to obtain a rendered bitmap. Printing is then performed using this rendered bitmap. For the printer, this means it only needs to receive the pre-set fixed-size rendered bitmap, eliminating the need to process multiple watermark bitmaps. This speeds up printing and avoids excessive thread usage in the printer, especially when the watermarks are densely packed, preventing slow printing due to large amounts of data being rendered to the printer. Furthermore, during the printing process, the watermark is adjusted by reading parameters such as transparency and rotation angle when generating the rendered bitmap, meeting more diverse user needs. Before entering the actual printing process, the watermark data and page data are fused to obtain the rendered bitmap, further reducing the amount of data processed by the printer. Simultaneously, a noise reduction mechanism is introduced during pixel fusion. By judging the pixel values ​​of the neighboring pixels of the currently rendered pixel, a range is defined for the currently rendered pixel, avoiding the impact of noise from various processing steps on the final print quality.

[0122] The above description is merely an embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent modifications made based on the content of the present invention specification and drawings, or direct or indirect applications in related technical fields, are similarly included within the patent protection scope of the present invention.

Claims

1. A method for automatically generating watermarks, characterized in that, Including the following steps: Obtain target page data and watermark data, wherein the target page data includes page content, page length, and page width; Obtain the print length and print width, and create a memory bitmap based on the print length and print width; The page content is rendered into the memory bitmap based on the page length and page width, and the watermark data is also rendered into the memory bitmap to obtain the rendered bitmap; Convert the rendered bitmap into a vector graphics file and print it; The step of rendering the watermark data into the memory bitmap includes: If, when rendering the watermark pixels of the watermark data, the target rendering position of the watermark pixel has already rendered the page pixels of the page content, then the pixel value of the page pixel and the pixel value of the watermark pixel are fused together using a pixel fusion algorithm to obtain the target pixel value. Update the pixel at the target rendering position based on the target pixel value; The watermark data includes rotation angle, position coordinates, and watermark content; The step of rendering the watermark data into the memory bitmap includes: Convert the watermark content into a watermark bitmap; Rotate the watermark bitmap according to the rotation angle; The step of rendering the watermark data into the memory bitmap includes: The rotated watermark bitmap is rendered onto the memory bitmap based on the position coordinates. The process of updating the pixel at the target rendering position based on the target pixel value further includes: Obtain the neighboring pixels of the pixel; Calculate the difference between the target pixel value and the neighbor pixel values ​​of each neighbor pixel; If the number of neighboring pixels whose difference exceeds a preset difference exceeds a preset number, then the pixels are subjected to a smoothing calculation. The smoothing calculation for the pixels includes: The pixels and their neighboring pixels are sorted in order of pixel value size to obtain a pixel value queue; Obtain the median of the pixel value queue, and update the pixel at the target rendering position based on the median; If the number of neighboring pixels whose difference exceeds a preset difference exceeds a preset number, then before performing smoothing calculations on the pixels, the following steps are included: Obtain the neighboring pixels of the pixel; Subtract the pixel values ​​of each neighboring pixel from each other and take the absolute value to obtain multiple relative differences; Obtain the maximum difference among the relative differences, and use a preset multiple of the maximum difference as the preset difference.

2. The watermark automatic generation method according to claim 1, characterized in that, The step of fusing the pixel values ​​of the page pixels and the watermark pixels using a pixel fusion algorithm to obtain the target pixel value includes: If the page pixel is a blank pixel, then the watermark pixel is directly used as the target pixel value after fusion; Otherwise, obtain the transparency stored in the watermark data, and weight the pixel value of the watermark pixel and the pixel value of the page pixel according to the transparency; The target pixel value is obtained by fusing the weighted pixel values ​​of the watermark pixels and the pixel values ​​of the page pixels.

3. The method for automatically generating a watermark according to claim 2, characterized in that, The weighting of the pixel values ​​of the watermark pixel and the page pixel based on the transparency includes: w1=transparent; w2 = 1 - transparent; Where w1 represents the weight of the pixel value of the watermark pixel; w2 represents the weight of the pixel value of the page pixel; and transparent represents the transparency. The target pixel value is obtained by combining the weighted watermark pixel value and the page pixel value. p = p1 × w1 + p2 × w2; Where p represents the target pixel value, p1 represents the pixel value of the watermark pixel at the target rendering position, and p2 represents the pixel value of the page pixel at the target rendering position.

4. A watermark automatic generation terminal, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps in the automatic watermark generation method according to any one of claims 1-3.

Citation Information

Patent Citations

  • Implementation method and device for automatically generating document watermark

    CN112733095A

  • Digital watermark embedding device, digital watermark detection device and recording medium recording computer readable program for realizing functions of two devices

    US6757405B1