A rapid printing method and storage medium based on a portable thermal printer

By employing a 16th-order error diffusion algorithm and serial port transmission technology in a portable thermal printer, efficient 16th-order printing was achieved, solving the problems of long printing time and quality degradation caused by equipment limitations, and improving printing efficiency and quality.

CN115390774BActive Publication Date: 2026-03-06HUIZHOU BOSHIJIE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211033074.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-26
Publication Date
2026-03-06
Estimated Expiration
2042-08-26

AI Technical Summary

Technical Problem

Portable thermal printers are limited by their equipment and cannot effectively achieve 16-level printing, resulting in long printing times, low efficiency, and compromised image quality.

Method used

The image data is preprocessed using a 16th-order error diffusion algorithm, and pixel row data is sent in batches. The thermal sheet heating and the motor paper feeding are controlled to perform mixed printing through serial port transmission and progressive color level comparison.

Benefits of technology

It improves printing efficiency, reduces printing time to 1/5 of traditional 16-level printing, while maintaining image quality to meet user needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115390774B_ABST
    Figure CN115390774B_ABST
Patent Text Reader

Abstract

This invention relates to the field of thermal printing technology, and provides a rapid printing method and storage medium based on a portable thermal printer. A preset algorithm is established to segment the row data of each pixel row, resulting in 5 groups of segment data. Each group of segment data is then grouped by color level to obtain 3 filtering groups. For each of the 3 filtering groups of segment data, it is compared one by one with the corresponding filtering color level group to calculate the 16-level printing dot matrix of the current pixel row. By sequentially obtaining the first N filtering color levels in each target color level group, 5 comparison color level groups are obtained. These are then compared with the corresponding filtering groups to obtain a continuous mixed color level printing dot matrix. A progressive determination is made as to whether pixels in the filtering groups need continuous heating, thereby achieving continuous mixed color level printing and reducing printing time to 1 / 5 of the traditional 16-level printing time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of thermal printing technology, and more particularly to a rapid printing method and storage medium based on a portable thermal printer. Background Technology

[0002] Portable thermal printers have high requirements for print quality when printing images. Ordinary second-order printing uses dithering or error diffusion algorithms to approximate the original image to obtain an image that is acceptable to the human eye. However, the image itself has obvious moiré patterns. Although there are some methods to reduce moiré patterns, the second-order algorithm processing is equivalent to lossy compression, which greatly reduces the image quality itself.

[0003] Using dithering or error diffusion algorithms for 16-level image compression can make the image closer to the original and render the moiré patterns in the printed image almost imperceptible to the human eye; however, due to various limitations of real-world printing equipment and the demand for faster printing speeds, 16-level printing is difficult to achieve. Specifically:

[0004] (1) The limitations of portable thermal printers include: the use of ordinary batteries, thermal pad voltage, maximum battery load current, and the need for segmented printing of the thermal pad. The use of ordinary batteries dictates that the thermal pad voltage cannot be too high, such as 7.2V or 4.2V; the battery's maximum current is generally 4.5A. In practical use, the heating time for a single point in this type of printer is typically around 800µs. Due to the battery's maximum current limitation, the thermal pad needs to be printed in segments; otherwise, the current will be too high.

[0005] (2) In 16-level printing, assuming a line is printed in 5 segments, each color level requires 800us, then a line of dots requires 800us*5*16=64ms. The number of pixel lines printed per second is 1000 / 64, which is approximately 16 lines. Therefore, it takes 50 seconds to print an image with a height of 800 pixels. This is a long waiting time for users and loses its practical value in many scenarios.

[0006] (3) The thermal sheet needs 30-50us to transmit data, and the heating time difference between some adjacent color levels in the 16 color levels is less than 30us, so some color levels cannot be printed at the same time, and therefore it is not possible to directly perform synchronous mixed printing of multiple color levels. Summary of the Invention

[0007] This invention provides a rapid printing method and storage medium based on a portable thermal printer, which solves the technical problems of existing thermal printing technology, which cannot effectively achieve 16-level printing due to equipment limitations, and is time-consuming and inefficient.

[0008] To address the above technical problems, this invention provides a rapid printing method based on a portable thermal printer, comprising the following steps:

[0009] S1. The acquired target image is converted into corresponding image data using a 16th-order error diffusion algorithm;

[0010] S2. The image data is sent to the terminal in batches, in units of pixels;

[0011] S3. The terminal acquires the row data of each pixel row in the image data, and converts each row data into print data according to a preset algorithm;

[0012] S4. Read each line of the print data in sequence, control the thermal sheet to heat up, drive the motor to feed the paper and execute image printing.

[0013] In a further embodiment, step S1 includes the following steps:

[0014] S11. Obtain the target image to be printed, and perform grayscale processing on the target image to obtain a grayscale image;

[0015] S12. The grayscale image is preprocessed using a 16th-order error diffusion algorithm to obtain corresponding 16th-order image data.

[0016] This solution uses a 16th-order error diffusion algorithm for image processing. On the one hand, it can reduce the difficulty of printing images by reducing the order, thereby improving printing efficiency. On the other hand, it can also take into account the actual printing quality and meet user needs.

[0017] In a further embodiment, step S2 includes the following steps:

[0018] S21. The image data is stored as a print file using 4-bit storage;

[0019] S22. Sequentially obtain the row data of each pixel row of the image data from the printed file, and send it to the terminal via serial port.

[0020] This solution uses serial port transmission to send row data of each pixel row to the terminal in segments, which improves data transmission efficiency while meeting the color gradation mixing printing requirements of the printing equipment.

[0021] In a further embodiment, step S3 includes the following steps:

[0022] S31. The terminal acquires the row data of each pixel row in the image data;

[0023] S32. Divide each row of data into 5 groups of segment data. The corresponding print points of the segment data in the same group are not adjacent to each other.

[0024] S33. Obtain the mapped pixel value corresponding to the 16th order error diffusion algorithm and divide it into 3 groups of filtering color level groups. Then, according to the filtering color level groups, divide each group of the segment data into corresponding 3 groups of filtering groups. The filtering color levels in the filtering color level groups are not adjacent to each other.

[0025] S34. Traverse each of the filtering groups, perform a progressive color level comparison with the corresponding filtering color level group, and obtain the corresponding print data based on the comparison results.

[0026] This solution is based on the 16th-order error diffusion algorithm and its 16th-order color levels. It pre-obtains the mapped pixel values ​​corresponding to the 16th-order error diffusion algorithm and divides them into 3 groups of filtering color levels. Then, it divides each group of segment data into the corresponding 3 groups of filtering groups, thereby preparing for one-to-one comparison, reducing the computational difficulty and improving printing efficiency.

[0027] In a further implementation, step S32 specifically involves: obtaining the pixel coordinate value of each row of data and taking the remainder after dividing by 5, dividing the row of data with the same remainder into the same group, and obtaining 5 groups of segment data.

[0028] This solution is based on the 16th-order error diffusion algorithm with 16 levels of color. The pixel value of each data is modulo 5, which can evenly divide the row data into 5 non-adjacent groups of data. Since the color levels of the data within the group are not adjacent, it effectively avoids mutual interference between adjacent printing points and improves the printing quality of the image.

[0029] In a further embodiment, step S34 includes the following steps:

[0030] A. Read each of the filter groups in sequence;

[0031] B. Obtain the filter color level group corresponding to the filter group;

[0032] C. Add the 0 color level to the beginning of the filter color level group to obtain the target color level group;

[0033] D. Sequentially obtain the first N filter color levels in the target color level group to obtain 5 sets of comparison color level groups, where N = i++, i = 0, N < 6;

[0034] E. The color level of the pixels in the filtering group is compared with each of the comparison color level groups in turn. If the color level of the pixels in the filtering group is not equal to any value in the comparison color level group, it is marked as 1; otherwise, it is marked as 0. The marks are integrated to obtain the printing data.

[0035] Each pixel row corresponds to 15 rows of printed data.

[0036] This solution adds the 0-level color to the current group's filter color levels as the first filter color level to obtain the target color level group, thus adapting to the actual printing situation. For the three filter groups of segment data, each group is compared with the corresponding filter color level group to calculate the 16-level printing dot matrix of the current pixel row. By sequentially obtaining the first N filter color levels in each target color level group, five comparison color level groups are obtained. By comparing these groups with the corresponding filter groups, a continuous mixed color level printing dot matrix can be obtained. The progressive judgment of whether the pixels in the filter groups need continuous heating enables continuous color level mixed printing, reducing the printing time to 1 / 5 of the traditional 16-level printing time.

[0037] In a further implementation, step S4 specifically involves: traversing each row of print data corresponding to each segment of data, and controlling the thermal sheet to heat up and the drive motor to feed paper simultaneously to perform mixed printing of multiple color levels based on the print data;

[0038] If the printed data is marked as 1 / 0, it is used to indicate whether a point on the thermal sheet is heating up or not.

[0039] In a further embodiment, in S33,

[0040] After processing the target image using a 16th-order error diffusion algorithm, 16 pixel values ​​are obtained: [0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240].

[0041] The mapped pixel values ​​corresponding to the 16 pixel values ​​are:

[0042] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];

[0043] The mapped pixel values ​​corresponding to the three groups of filtered color levels are as follows:

[0044] (1, 4, 7, 10, 13), (2, 5, 8, 11, 14), (3, 6, 9, 12, 15).

[0045] This method obtains 16-level mapped pixel values ​​through pixel mapping and performs printing data calculations, which reduces computational difficulty and improves printing efficiency.

[0046] The present invention also provides a storage medium storing a computer program for implementing the above-described rapid printing method based on a portable thermal printer. The storage medium may be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc. Attached Figure Description

[0047] Figure 1 This is a flowchart illustrating a rapid printing method based on a portable thermal printer, as provided in an embodiment of the present invention. Detailed Implementation

[0048] The embodiments of the present invention are described in detail below with reference to the accompanying drawings. The embodiments are given for illustrative purposes only and should not be construed as limiting the present invention. The accompanying drawings are for reference and illustration only and do not constitute a limitation on the scope of patent protection of the present invention, because many changes can be made to the present invention without departing from the spirit and scope of the present invention.

[0049] Example 1

[0050] This invention provides a rapid printing method based on a portable thermal printer, such as... Figure 1 As shown, in this embodiment, steps S1 to S4 are included:

[0051] S1. The acquired target image is converted into corresponding image data using a 16th-order error diffusion algorithm, including steps S11 to S12:

[0052] S11. Obtain the target image to be printed, and perform grayscale processing on the target image to obtain a grayscale image;

[0053] S12. The grayscale image is preprocessed using a 16th-order error diffusion algorithm to obtain corresponding 16th-order image data.

[0054] This embodiment uses a 16th-order error diffusion algorithm for image processing. On the one hand, it can reduce the difficulty of printing images by reducing the order, thereby improving printing efficiency. On the other hand, it can also take into account the actual printing quality and meet user needs.

[0055] S2. Send the image data to the terminal in batches, in units of pixels, including steps S21 to S22:

[0056] S21. Use 4-bit storage to store the image data as a print file;

[0057] S22. Sequentially obtain the row data of each pixel row of the image data from the print file and send it to the terminal via serial port.

[0058] This embodiment uses serial port transmission to send row data of each pixel row to the terminal in segments, which improves data transmission efficiency while meeting the color gradation mixing printing requirements of the printing device.

[0059] S3. The terminal acquires the row data of each pixel row in the image data, and converts each row data into print data according to a preset algorithm, including steps S31 to S34:

[0060] S31. The terminal acquires the row data of each pixel row in the image data;

[0061] S32. Divide each row of data into 5 groups of segments. Specifically, obtain the pixel coordinates of each row of data (i.e., the position coordinates of the pixel on the pixel row) and take the remainder when divided by 5. Group the rows of data with the same remainder into the same group to obtain 5 groups of segments. Among them, the corresponding print points of the same group of segments are not adjacent to each other.

[0062] This embodiment uses a 16-level color scale based on a 16-level error diffusion algorithm. The pixel value of each data is modulo 5, which can evenly divide the row data into 5 non-adjacent groups of data. Since the color levels of the data within a group are not adjacent, the mutual influence between adjacent printing points is effectively avoided, thus improving the printing quality of the image.

[0063] S33. Obtain the mapped pixel value corresponding to the 16th order error diffusion algorithm and divide it into 3 groups of filtering color level groups. Then, divide each group of segment data into 3 corresponding filtering groups according to the filtering color level groups. The filtering color levels in the filtering color level group are not adjacent to each other.

[0064] After processing the target image using the 16th-order error diffusion algorithm, 16 pixel values ​​were obtained: [0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240].

[0065] The mapped pixel values ​​corresponding to the 16 pixel values ​​are:

[0066] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];

[0067] The mapped pixel values ​​(i.e., the filter levels) corresponding to the three filter level groups are as follows:

[0068] (1, 4, 7, 10, 13), (2, 5, 8, 11, 14), (3, 6, 9, 12, 15).

[0069] This embodiment obtains 16-level mapped pixel values ​​through pixel mapping and performs printing data calculations, which can reduce the computational difficulty and improve printing efficiency.

[0070] This embodiment is based on the 16th-order error diffusion algorithm and the 16th-order color levels. The mapped pixel values ​​corresponding to the 16th-order error diffusion algorithm are obtained in advance and divided into 3 groups of filtering color level groups. Then, each group of segment data is divided into the corresponding 3 groups of filtering groups, so as to prepare for one-to-one comparison, reduce the calculation difficulty and improve the printing efficiency.

[0071] S34. Traverse each filter group, perform a progressive color level comparison with the corresponding filter color level group, and obtain the corresponding print data based on the comparison results, including steps A to E:

[0072] A. Read each filtered group sequentially;

[0073] B. Obtain the filter color level group corresponding to the filter group;

[0074] C. Add the 0 color level to the beginning of the filter color level group to obtain the target color level group;

[0075] In this embodiment, the filter color levels (i.e., mapped pixel values) corresponding to the three target color level groups are as follows:

[0076] (0, 1, 4, 7, 10, 13), (0, 2, 5, 8, 11, 14), (0, 3, 6, 9, 12, 15).

[0077] D. Sequentially obtain the first N filter color levels in the target color level group to get 5 sets of comparison color level groups, where N = i++, i = 0, N < 6;

[0078] Taking the target color level group (0, 1, 4, 7, 10, 13) as an example, the 5 comparison color level groups are as follows:

[0079] (0), (0, 1), (0, 1, 4), (0, 1, 4, 7), (0, 1, 4, 7, 10).

[0080] E. Compare the color levels of the pixels in the filter group with each comparison color level group in sequence. If the color level of the pixel in the filter group is not equal to any value in the comparison color level group, mark it as 1; otherwise, mark it as 0. Combine the marks to obtain the print data.

[0081] Each pixel row corresponds to 15 rows of printed data.

[0082] Take the following set of filtering groups (pixel values) as an example:

[0083] 16, 64, 160, 160, 208, 16, 112, 112;

[0084] The corresponding 16th-order mapped pixel value is:

[0085] 1, 4, 10, 10, 13, 1, 7, 7;

[0086] If compared with the target color level group (0, 1, 4, 7, 10, 13) (i.e., compared with each of the 5 color level groups), the following 5 lines of printed data are obtained:

[0087] 1, 1, 1, 1, 1, 1, 1, 1;

[0088] 0, 1, 1, 1, 1, 0, 1, 1;

[0089] 0, 0, 1, 1, 1, 0, 1, 1;

[0090] 0, 0, 1, 1, 1, 0, 0, 0;

[0091] 0, 0, 0, 0, 1, 0, 0, 0;

[0092] In this way, the calculation is performed on the printed data of each group of filtered groups.

[0093] In this embodiment, level 0 is added to the current group's filter levels as the first filter level to obtain the target level group, thus adapting to the actual situation on the printing site. For the three filter groups of segment data, they are compared one by one with the corresponding filter level groups to calculate the 16-level printing dot matrix of the current pixel row. By sequentially obtaining the first N filter levels in each target level group, five comparison level groups are obtained. By comparing them with the corresponding filter groups, a continuous mixed level printing dot matrix can be obtained. The progressive judgment of whether the pixels in the filter groups need to be continuously heated can achieve continuous mixed level printing, reducing the printing time to 1 / 5 of the traditional 16-level printing time.

[0094] S4. Read each line of print data in sequence, control the thermal sheet to heat up and drive the motor to feed the paper to execute image printing. Specifically, iterate through each line of print data corresponding to each segment of data, and control the thermal sheet to heat up and drive the motor to feed the paper to execute mixed printing of multiple color levels simultaneously.

[0095] If the printed data is marked as 1 / 0, it is used to indicate whether a point on the thermal pad is heating up or not.

[0096] In this embodiment, since the printing of multiple color levels in each filtering group is performed synchronously, if the maximum heating time of each filtering group is preset to 800us, the total heating time of each pixel row is reduced to 800*15=12ms.

[0097] Example 2

[0098] This invention also provides a storage medium storing a computer program for implementing the rapid printing method based on a portable thermal printer provided in the above embodiments. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.

[0099] The above embodiments are preferred embodiments of the present invention, but the embodiments of the present invention are not limited to the above embodiments. Any changes, modifications, substitutions, combinations, or simplifications made without departing from the spirit and principle of the present invention shall be considered equivalent substitutions and shall be included within the protection scope of the present invention.

Claims

1. A quick printing method based on a portable thermal printer, characterized by, The method comprises the steps of: S1, using a 16-order error diffusion algorithm to convert the obtained target image into corresponding image data; S2, sending the image data to the terminal in batches in units of pixel rows; S3, the terminal obtains the row data of each pixel row in the image data, and converts each row data into printing data according to a preset algorithm; S4, sequentially reading each row of printing data, controlling the heat generation of the thermal sheet, driving the motor to feed the paper and executing image printing; The step S3 comprises the steps of: S31, the terminal obtains the row data of each pixel row in the image data; S32, segmenting each row data to obtain 5 groups of segment data, and the printing points corresponding to the segment data in the same group are not adjacent to each other; S33, obtaining the mapping pixel value corresponding to the 16-order error diffusion algorithm, and dividing it into 3 groups of screening color steps, and then dividing each group of segment data into corresponding 3 groups of screening subgroups according to the screening color step group, and the screening color steps in the screening color step group are not adjacent to each other; S34, traversing each screening subgroup, and progressively comparing it with the corresponding screening color step group, and obtaining the corresponding printing data according to the comparison result.

2. A fast printing method based on a portable thermal printer as claimed in claim 1, characterized in that, The step S1 comprises the steps of: S11, obtaining a target image to be printed, and performing grayscale processing on the target image to obtain a grayscale image; S12, preprocessing the grayscale image using a 16-order error diffusion algorithm to obtain image data corresponding to 16 orders.

3. A fast printing method based on a portable thermal printer as claimed in claim 2, characterized in that, The step S2 comprises the steps of: S21, storing the image data as a print file using 4-bit storage; S22, sequentially obtaining the row data of each pixel row of the image data from the print file, and sending it to the terminal using a serial port.

4. A fast printing method based on a portable thermal printer according to claim 3, characterized in that, The step S32 specifically comprises: obtaining the pixel coordinate value of each row data and taking the remainder of 5, and dividing the row data with the same remainder into the same group to obtain 5 groups of segment data.

5. A fast printing method based on a portable thermal printer according to claim 3, characterized in that, The step S34 comprises the steps of: A, sequentially reading each screening subgroup; B, obtaining the screening color step group corresponding to the screening subgroup; C, adding a 0 color step at the head of the screening color step group to obtain a target color step group; D, sequentially obtaining the first N screening color steps in the target color step group to obtain 5 comparison color step groups, wherein N=i++, i=0, N<6; E, comparing the color steps of the pixel points in the screening subgroup with each comparison color step group in sequence, and if the color steps of the pixel points in the screening subgroup are not equal to any value in the comparison color step group, marking 1, otherwise marking 0, and integrating the marks to obtain printing data; Wherein, each pixel row corresponds to 15 rows of printing data.

6. A fast printing method based on a portable thermal printer as claimed in claim 5, characterized in that, The step S4 specifically comprises: traversing each row of printing data corresponding to each segment data, and controlling the heat generation of the thermal sheet and driving the motor to feed the paper according to the printing data while executing mixed printing of multiple color steps; Wherein, if the printing data is marked as 1 / 0, it indicates that the point on the thermal sheet is heated / not heated.

7. A fast printing method based on a portable thermal printer according to claim 3, characterized in that, In the S33, After the target image is processed by using a 16-order error diffusion algorithm, 16 pixel values are obtained: [0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240]; The mapping pixel values corresponding to the 16 pixel values are: [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]; The mapping pixel values corresponding to the three groups of screening color steps are: (1,4,7,10,13),(2,5,8,11,14),(3,6,9,12,15)。 8. A storage medium having stored thereon a computer program, characterized in that: The computer program is used for realizing the quick printing method based on the portable thermal printer in any one of claims 1-7.

Citation Information

Patent Citations

  • Marking paper printing control method and printer

    CN106515231A

  • Method for realizing gray-scale printing of low-voltage thermosensitive sheet

    CN112508762A