Disclosure of Invention
The invention aims to: how to add a light-colored watermark for thermal printing that does not mask normal text.
In order to achieve the above purpose, the invention provides the following technical scheme:
a watermark printing method of a thermal printer comprises the following steps:
converting the initial binary printing data of the watermark into gray scale data according to the watermark command;
and after error diffusion processing is carried out on the gray scale data, new binary printing data is formed through an image binarization algorithm.
As an embodiment of the present invention, the converting binary print data of a watermark into grayscale data according to an acquired watermark command includes:
presetting watermark depth levels S1, S2, and the... once.once.Sn and the. once.once.once.n (M levels are total, 1 is less than M and less than 255), wherein the preset gray level value corresponding to Sn is Nn, and when the depth level in the obtained watermark command is Sn, converting binary printing data 0 of the watermark into a preset gray level value N0, and converting 1 into a gray level value Nn, wherein 255 is more than or equal to a preset gray level value N0 and more than Nn.
As an embodiment of the present invention, the converting binary print data of a watermark into grayscale data according to an acquired watermark command includes:
presetting watermark depth levels S1, S2, and the.. once.; when the depth level in the watermark acquisition command is Sn, the binary print data 0 of the watermark is converted into a preset gray-scale value N0, and 1 is converted into a gray-scale value (255/M) × (N-1), wherein 255 is more than or equal to the preset gray-scale value N0 > (255/M) > (N-1).
As an embodiment of the present invention, the converting binary print data of a watermark into grayscale data according to an acquired watermark command includes:
acquiring a watermark command, converting binary printing data 0 of the watermark into a preset gray level value N0, and converting 1 into a gray level value k 255 (rounding), wherein k is a set value, k is more than 0 and less than 1, the larger the k is, the shallower the depth of the watermark is, and the 255 is more than or equal to the preset gray level value N0 and more than k 255.
Further, the error diffusion processing carries out transition processing on the gray scale data to form continuously-transitional gray scale data;
the image binarization algorithm processing is carried out on the continuously transitional gray scale data, the gray scale data which do not accord with the preset condition are converted into binary printing data 0, so that the original continuous heating points can form staggered spaced points due to the algorithm processing, and watermarks with different concentrations are formed and displayed.
And further, performing logical OR operation superposition on the received text printing data and the new binary printing data of the watermark obtained by the processing of the watermark data to form final printing data, and controlling a thermal printing unit to print.
Further, the watermark printing method further includes: receiving a text printing command, acquiring word stock character data in a printer according to GBK codes of a printed text, generating binary printing data of the printed text by combining character position coordinates of the printed text, storing the binary printing data in a cache, and waiting for calling and carrying out logical or operational superposition on the new binary printing data of the watermark obtained by processing the watermark data processing process to form final printing data.
Further, the watermark printing method further includes: receiving a watermark printing command, acquiring word stock character data in a printer according to GBK (global bit keying) codes of watermarks, generating initial binary printing data of the watermarks by combining position coordinates of characters for printing the watermarks, executing a watermark data processing process, and storing new binary printing data of the watermarks obtained by the watermark data processing process in a cache;
receiving a text printing command, acquiring word stock character data in a printer according to GBK codes of a printing text, generating binary printing data of the printing text by combining character position coordinates of the printing text, and calling a binary printing data memory in a cache to perform logical or operational superposition with the binary printing data of the printing text to form final printing data.
The present embodiment also provides a storage medium storing at least one instruction, and/or at least one program, and/or a code set, and/or an instruction set, for implementing a watermark printing method of any one of the thermal printers.
The present embodiment also provides a thermal printing apparatus including:
the processing unit is used for converting the initial binary printing data of the watermark into gray scale data according to the obtained watermark command; and after error diffusion processing is carried out on the gray scale data, new binary printing data is formed through an image binarization algorithm.
Further, the thermal printing apparatus of the present embodiment includes:
the processing unit performs logical OR operation superposition on the received text printing data and the new binary printing data of the watermark obtained by processing to form final printing data and generates a printing instruction;
the thermal printing unit is used for receiving the printing instruction sent by the processing unit and executing the printing process;
preferably, the thermal printing device further comprises a storage unit, configured to obtain font library character data in the printer according to the GBK code of the print text by the cache processing unit, and generate binary print data of the print text by combining with the character position coordinates of the print text, or configured to cache new binary print data of the watermark obtained by the watermark data processing process.
Compared with the prior art, the invention has the following beneficial effects:
the initial binary printing data of the watermark printed by the heat sensitivity is composed of 0 and 1, wherein 0 represents no heating, 1 represents heating, and the initial binary printing data of the watermark is converted into gray scale data according to a watermark command; the error diffusion algorithm processing is carried out on the new watermark data, the new binary printing data is formed through the image binarization algorithm, and the original continuous heating points form staggered interval points due to the algorithm processing, so that characters with reduced concentration are displayed, the added watermark has certain transparency, the printed normal text cannot be shielded, the better watermark adding effect of thermal printing is realized, and the identifiability of the text characters is not influenced.
The invention presets M-level watermark depth levels, so that a user can select the corresponding watermark depth level for watermark addition according to the required watermark effect, and the conversion process of the watermark printing method for thermal printing is simpler by setting the numerical value of M, and the method is more suitable for a portable thermal printer.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be described clearly and completely with reference to the accompanying drawings. It should be apparent that the described embodiments are only some of the embodiments of the present invention, and not all of them.
Thus, the following detailed description of the embodiments of the invention is not intended to limit the scope of the invention as claimed, but is merely representative of some embodiments of the invention. All other embodiments, which can be obtained by a person skilled in the art without inventive step based on the embodiments of the present invention, are within the scope of protection of the present invention.
It should be noted that the embodiments of the present invention and the features and technical solutions thereof may be combined with each other without conflict.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
In the description of the present invention, it should be noted that the terms "upper", "lower", and the like refer to orientations or positional relationships based on those shown in the drawings, or orientations or positional relationships that are conventionally arranged when the products of the present invention are used, or orientations or positional relationships that are conventionally understood by those skilled in the art, and such terms are used for convenience of description and simplification of the description, and do not refer to or imply that the devices or elements referred to must have a specific orientation, be constructed and operated in a specific orientation, and thus, should not be construed as limiting the present invention. Furthermore, the terms "first," "second," and the like are used merely to distinguish one description from another, and are not to be construed as indicating or implying relative importance.
Referring to fig. 1, the watermark printing method of the thermal printer provided by this embodiment includes:
the processing unit converts the initial binary printing data of the watermark into gray scale data according to the watermark command;
and after error diffusion processing is carried out on the gray scale data, new binary printing data is formed through an image binarization algorithm.
The initial binary printing data of the watermark for thermal printing in the embodiment is composed of 0 and 1, wherein 0 represents no heating, 1 represents heating, and the processing unit converts the initial binary printing data of the watermark into gray scale data according to the watermark command; the error diffusion algorithm processing is carried out on the new watermark data, the new binary printing data is formed through the image binarization algorithm, and the original continuous heating points form staggered interval points due to the algorithm processing, so that characters with reduced concentration are displayed, the added watermark has certain transparency, the printed normal text cannot be shielded, the better watermark adding effect of thermal printing is realized, and the identifiability of the text characters is not influenced.
As an implementation manner of this embodiment, the processing unit of this embodiment converts the watermarked binary print data into grayscale data according to the acquired watermark command, including:
presetting watermark depth levels S1, S2, and the... once.once.Sn and the. once.once.once.n (M levels are total, 1 is less than M and less than 255), wherein the preset gray level value corresponding to Sn is Nn, and when the depth level in the obtained watermark command is Sn, converting binary printing data 0 of the watermark into a preset gray level value N0, and converting 1 into a gray level value Nn, wherein 255 is more than or equal to a preset gray level value N0 and more than Nn.
In the present embodiment, according to binary print data of thermal printing, 0 represents no heating, the print effect is white, corresponding to a gray level value of 255,1 represents heating, the print effect is black, and the corresponding gray level value is 0, therefore, in the present embodiment, the binary print data of the watermark, corresponding to a gray level value of 1 greater than 0 and less than 255, presents gray between white and black, and is converted into binary print data executable by thermal printing to perform printing.
According to the watermark printing method of the thermal printer, the M watermark levels with different depth levels are set, the gray level values corresponding to the M watermark levels can be average or non-average, and a user can select the watermark level Sn according to specific printing requirements, so that the watermark printing requirements of the user are greatly met.
As another implementation manner of this embodiment, the converting the two-value printing data of the watermark into the grayscale data according to the obtained watermark command includes:
presetting watermark depth levels S1, S2, and the.. once.; when the depth level in the watermark acquiring command is Sn, the binary printing data 0 of the watermark is converted into a preset gray level value N0, and 1 is converted into a gray level value (255/M) × (N-1), wherein 255 is more than or equal to the preset gray level value N0 > (255/M) × (N-1).
Presetting watermark depth levels S1, S2, a.. once.a., Sn, a.. once.a. (M levels are total, 1 is less than M and less than 255), wherein S1 corresponds to a gray level value 0, Sn corresponds to a gray level value (255/M) is (n-1), and 1 is less than n and less than M; when the processing unit obtains that the depth level in the watermark command is Sn, the binary printing data 0 of the watermark is converted into a gray-scale value 255, and 1 is converted into a gray-scale value (255/M) × (n-1).
In the present embodiment, according to binary print data of thermal printing, 0 represents no heating, the print effect is white, corresponding to a gray level value of 255,1 represents heating, the print effect is black, and the corresponding gray level value is 0, therefore, in the present embodiment, the binary print data of the watermark, corresponding to a gray level value of 1 greater than 0 and less than 255, presents gray between white and black, and is converted into binary print data executable by thermal printing to perform printing.
In this embodiment, M-level watermark depth levels are preset, so that a user can select a corresponding watermark depth level for watermark addition according to a required watermark effect, and by setting the value of M, the conversion process of the watermark printing method for thermal printing is simpler, and the method is more suitable for a portable thermal printer. In addition, the watermark depth level of the M-level watermark is changed averagely, so that the watermark selection of the depth effect is more convenient for a user.
As an embodiment of this embodiment, ten preset watermark depth levels S1, S2, and S10 are stored in the storage unit of the thermal printer, where the level S1 corresponds to a gray level value 0, the level S2 corresponds to a gray level value 25, the level S3 corresponds to a gray level value 50, and so on, the level S10 corresponds to a gray level value 225, and the watermark depths from the level S1 to the level S10 gradually become shallower.
Referring to the thermal printing effect diagram of the ten-level preset watermark depth levels S1, S2, and S10 shown in fig. 3, the ten-level watermark depth levels are preset in the embodiment to meet the watermark adding requirements of users, and the conversion algorithm corresponding to the ten-level watermark depth levels is simple and is more suitable for a portable thermal printer.
As an implementation manner of this embodiment, the processing unit converts the watermarked binary print data into grayscale data according to the acquired watermark command, and includes:
the processing unit obtains a watermark command, and converts the binary printing data 0 of the watermark into a preset gray-scale value N0, and converts 1 into a gray-scale value k 255 (rounding), wherein k is a set value, k is greater than 0 and less than 1, the larger the k is, the shallower the depth of the watermark is, and the 255 is greater than or equal to the preset gray-scale value N0 and greater than the gray-scale value k 255.
In this embodiment, the binary print data 1 of the watermark is converted into the gray-scale value k × 255 (rounded), so that the conversion algorithm of the watermark printing method of the thermal printing can be fixed, and the method is simplified to the greatest extent and is more suitable for the portable thermal printer. Since the binary print data 1 of this embodiment is converted into the gray-scale value k × 255 (rounded) and converted into a watermark with a fixed depth, the effect of adding watermarks in thermal printing is satisfied. Preferably, k of this embodiment may be selected to be 0.5.
As described above, the preset grayscale value N0 of the present embodiment should be binary print data 0 (white), and therefore N0 of the present embodiment should be selected to be close to or equal to 255.
Further, the error diffusion processing carries out transition processing on the gray scale data to form continuously-transitional gray scale data;
the image binarization algorithm processing is carried out on the continuously transitional gray scale data, the gray scale data which do not accord with the preset condition are converted into binary printing data 0, so that the original continuous heating points can form staggered spaced points due to the algorithm processing, and watermarks with different concentrations are formed and displayed.
Further, in the watermark printing method of the thermal printer according to the embodiment, the processing unit performs logical or operation and superposition on the received text printing data and the new binary printing data of the watermark obtained by the processing of the watermark data to form final printing data, and controls the thermal printing unit to print.
The watermark printing method of the thermal printer of the embodiment further includes:
receiving a text printing command, acquiring word stock character data in a printer according to GBK codes of a printed text, generating binary printing data of the printed text by combining character position coordinates of the printed text, storing the binary printing data in a cache, and waiting for calling and carrying out logical or operational superposition on the new binary printing data of the watermark obtained by processing the watermark data processing process to form final printing data.
As another implementation manner of this embodiment, the watermark printing method further includes:
receiving a watermark printing command, acquiring word stock character data in a printer according to GBK (global bit keying) codes of watermarks, generating initial binary printing data of the watermarks by combining position coordinates of characters for printing the watermarks, executing a watermark data processing process, and storing new binary printing data of the watermarks obtained by the watermark data processing process in a cache;
receiving a text printing command, acquiring word stock character data in a printer according to GBK codes of a printing text, generating binary printing data of the printing text by combining character position coordinates of the printing text, and calling a binary printing data memory in a cache to perform logical or operational superposition with the binary printing data of the printing text to form final printing data. The thermal printing method of the thermal printer in the embodiment is particularly suitable for the portable thermal printer because the logical operation method is simple and effective and the printed watermark effect is good, thereby not only meeting the portable requirements of users, but also providing good watermark printing effect. The portable thermal printer of the present embodiment includes, but is not limited to, a label/receipt printer, an express single-electron-face single printer, and a portable error-problem printer.
The embodiment also provides a storage medium storing at least one instruction, and/or at least one program, and/or a code set, and/or an instruction set, for implementing the watermark printing method for thermal printing. Optionally, the computer-readable storage medium includes a Read Only Memory (ROM), a Random Access Memory (RAM), a Solid State Disk (SSD), or an optical disk.
The present embodiment also provides a thermal printing apparatus including:
an acquisition unit that acquires the watermark command;
the processing unit is used for converting the initial binary printing data of the watermark into gray scale data according to the watermark command acquired by the acquisition unit; and after error diffusion processing is carried out on the gray scale data, new binary printing data are formed through an image binarization algorithm. Further, in the thermal printing apparatus of this embodiment, the processing unit performs logical or operation and superposition on the received text print data and the new binary print data of the watermark obtained by processing to form final print data, and generates a print instruction;
the thermal printing device comprises a thermal printing unit, a printing unit and a control unit, wherein the thermal printing unit receives the printing instruction sent by the processing unit and executes a printing process;
preferably, the thermal printing device further comprises a storage unit, configured to obtain font library character data in the printer according to the GBK code of the print text by the cache processing unit, and generate binary print data of the print text by combining with the character position coordinates of the print text, or configured to cache new binary print data of the watermark obtained by the watermark data processing process.
The above embodiments are only used to illustrate the present invention and not to limit the technical solutions described in the present invention, and although the present invention has been described in detail in the present specification with reference to the above embodiments, the present invention is not limited to the above specific embodiments, and therefore, any modifications or equivalents of the present invention may be made; all such modifications and variations are intended to be included herein within the scope of this disclosure and the appended claims.