Thermosensitive gray scale printing method and device, storage medium and electronic equipment

By receiving and storing grayscale data and reference information of specified lines in thermal printers, the problem of large memory usage is solved, and low-cost and efficient grayscale printing on large-sized printers are achieved.

CN120371232APending Publication Date: 2025-07-25ZHUHAI QUIN TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510312236.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-14
Publication Date
2025-07-25

AI Technical Summary

Technical Problem

The existing thermally sensitive grayscale printing methods limit their application on large-sized printers due to their large memory usage.

Method used

By receiving the grayscale data and reference information of the specified rows, it stores it in memory, including the number of points to be heated, the starting byte and the end byte of each grayscale data, the thermal print head is sequentially extracted and controlled based on these information, and the complex traversal and data retrieval process is avoided.

Benefits of technology

Reduces memory footprint, achieves low-cost grayscale printing on large-size printers, and improves printing efficiency and quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120371232A_ABST
    Figure CN120371232A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a thermosensitive gray scale printing method and device, a storage medium and electronic equipment, and is applied to a thermosensitive printer, the method comprises the steps that to-be-printed Mth row of gray scale data is received, the Mth row of gray scale data is the Mth row of data in a K-order gray scale image, M is a positive integer larger than or equal to 1, and K is a positive integer larger than or equal to 2; the M-th line of gray scale data and first reference information are stored in a first memory, and the first reference information comprises the number of points to be heated of each level of gray scale data in the M-th line of gray scale data, a starting byte of each level of gray scale data in the M-th line of gray scale data and an ending byte of each level of gray scale data in the M-th line of gray scale data; and based on the first reference information, sequentially extracting gray scale data of each scale in the M-th line of gray scale data, and controlling the thermal printing head to execute thermal printing operation on the thermal medium according to the gray scale data of each scale in the M-th line of gray scale data until the M-th line of gray scale data is printed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the technical field of image printing. Specifically, the embodiments of the present application relate to a thermal gray-scale printing method, apparatus, storage medium, and electronic device. Background Art

[0002] Compared with the dot matrix printing method that realizes different gray levels of an image through the distribution density of dot matrices, the thermal gray-scale printing method that realizes gray-scale printing by dynamically adjusting the heating time of each gray level can improve the image printing effect. However, to implement the gray-scale printing function, a main control chip requires a large amount of memory, which increases the cost of the machine. Therefore, the thermal gray-scale printing methods in related technologies are mostly applied to small-size machines with a size of 3 inches or 4 inches or less. The size of the main control memory and the cost limit the application of the thermal gray-scale printing technology in large-size printers.

[0003] It can be seen that the thermal gray-scale printing method in related technologies has the problem of large memory occupation. Summary of the Invention

[0004] The embodiments of the present application provide a thermal gray-scale printing method, apparatus, storage medium, and electronic device, so as to at least solve the problem of large memory occupation existing in the thermal gray-scale printing method in related technologies.

[0005] According to one aspect of the embodiments of the present application, a thermal gray-scale printing method is provided, which is applied to a thermal printer. The thermal printer includes a thermal print head. The method includes: receiving the M-th row of gray-scale data to be printed, where the M-th row of gray-scale data is the M-th row data in a K-level gray-scale image, M is a positive integer greater than or equal to 1, and K is a positive integer greater than or equal to 2; storing the M-th row of gray-scale data and first reference information in a first memory, where the first reference information includes the number of dots to be heated for each gray level data in the M-th row of gray-scale data, the start byte of each gray level data in the M-th row of gray-scale data, and the end byte of each gray level data in the M-th row of gray-scale data; based on the first reference information, sequentially extracting each gray level data in the M-th row of gray-scale data, and controlling the thermal print head to perform a thermal printing operation on a thermal medium according to each gray level data in the M-th row of gray-scale data until the M-th row of gray-scale data is printed.

[0006] According to another aspect of the embodiments of the present application, there is also provided a thermal grayscale printing device, which is applied to a thermal printer. The thermal printer includes a thermal print head. The device includes: a first receiving unit, configured to receive the grayscale data of the M-th row to be printed, where the grayscale data of the M-th row is the data of the M-th row in a K-order grayscale image, M is a positive integer greater than or equal to 1, and K is a positive integer greater than or equal to 2; a first storage unit, configured to store the grayscale data of the M-th row and first reference information in a first memory, where the first reference information includes the number of dots to be heated for each grayscale data in the grayscale data of the M-th row, the start byte of each grayscale data in the grayscale data of the M-th row, and the end byte of each grayscale data in the grayscale data of the M-th row; a first execution unit, configured to sequentially extract each grayscale data in the grayscale data of the M-th row based on the first reference information, and control the thermal print head to perform a thermal printing operation on the thermal medium according to each grayscale data in the grayscale data of the M-th row until the grayscale data of the M-th row is printed out.

[0007] According to yet another aspect of the embodiments of the present application, there is also provided a computer-readable storage medium, in which a computer program is stored. The computer program is configured to execute the steps in any one of the above method embodiments when running.

[0008] According to yet another aspect of the embodiments of the present application, there is provided a computer program product or a computer program. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the steps in any one of the above method embodiments.

[0009] According to yet another aspect of the embodiments of the present application, there is also provided an electronic device, including a memory and a processor. A computer program is stored in the memory, and the processor is configured to execute the steps in any one of the above method embodiments through the computer program.

[0010] With this application, since the grayscale data of the original line and the corresponding reference information are stored in the memory, and each level of grayscale data is sequentially extracted based on the stored reference information for thermal printing. By receiving the grayscale data of the Mth row to be printed, where the grayscale data of the Mth row is the data of the Mth row in a K-level grayscale image, M is a positive integer greater than or equal to 1, and K is a positive integer greater than or equal to 2; storing the grayscale data of the Mth row and the first reference information in the first memory, where the first reference information includes the number of heating points to be applied to each level of grayscale data in the grayscale data of the Mth row, the start byte of each level of grayscale data in the grayscale data of the Mth row, and the end byte of each level of grayscale data in the grayscale data of the Mth row; based on the first reference information, sequentially extracting each level of grayscale data in the grayscale data of the Mth row, and controlling the thermal print head to perform a thermal printing operation on the thermal medium according to each level of grayscale data in the grayscale data of the Mth row until the grayscale data of the Mth row is printed. Since the grayscale data of a specific row and the corresponding reference information (including the number of heating points to be applied to each level of grayscale data, the start byte, and the end byte) are stored in the memory, and each level of grayscale data in the grayscale data is extracted based on the saved reference information and the print head is controlled to perform a thermal printing operation according to each level of grayscale data, without storing all levels of grayscale data simultaneously, the technical effect of reducing memory occupancy can be achieved, thereby solving the problem of high memory requirements in the thermal grayscale printing method in the related art. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] Figure 1 is a schematic diagram of an application scenario of a thermal grayscale printing method according to an embodiment of the present application;

[0012] Figure 2 is a schematic flowchart of an optional thermal grayscale printing method according to an embodiment of the present application;

[0013] Figure 3 is a schematic flowchart of another optional thermal grayscale printing method according to an embodiment of the present application;

[0014] Figure 4 is a schematic flowchart of yet another optional thermal grayscale printing method according to an embodiment of the present application;

[0015] Figure 5 is a structural block diagram of an optional device for a thermal grayscale printing method according to an embodiment of the present application;

[0016] Figure 6 is a structural block diagram of a computer system of an optional electronic device according to an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0017] To enable those skilled in the art to better understand the solution of this application, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are only a part of the embodiments of this application, rather than all the embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of this application.

[0018] It should be noted that the terms "first", "second", etc. in the description and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that such used data can be interchanged under appropriate circumstances so that the embodiments of this application described here can be implemented in an order different from those illustrated or described here. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device including a series of steps or units does not necessarily limit to those clearly listed steps or units, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.

[0019] According to one aspect of the embodiments of this application, a thermal gray-scale printing method is provided. Optionally, in this embodiment, the above thermal gray-scale printing method can be but is not limited to being applied to a hardware environment such as Figure 1 shown in the figure, including a terminal device 102 and a printer 104. The printer 104 can be connected to the terminal device 102 through a network, and can be used to provide services (such as application services, etc.) for the terminal device 102 or a client installed on the terminal device 102. A database can be set on the printer 104 or independently of the printer 104 to provide data storage services for the printer 104.

[0020] The above network can include but is not limited to at least one of the following: a wired network, a wireless network. The above wired network can include but is not limited to at least one of the following: a wide area network, a metropolitan area network, a local area network. The above wireless network can include but is not limited to at least one of the following: WIFI (Wireless Fidelity), Bluetooth. The terminal device 102 can be but is not limited to a PC (Personal Computer), a mobile phone, a tablet computer, etc. The printer 104 can be but is not limited to a thermal printer.

[0021] The thermal grayscale printing method according to the embodiments of the present application can be executed by the printer 104, or by the terminal device 102, or jointly by the printer 104 and the terminal device 102. Among them, when the terminal device 102 executes the thermal grayscale printing method according to the embodiments of the present application, it can also be executed by the client installed thereon.

[0022] Taking the execution of the thermal grayscale printing method in this embodiment by the printer 104 as an example, Figure 2 is a schematic flowchart of an optional thermal grayscale printing method according to the embodiments of the present application, as Figure 2 shown, the process of this method can include the following steps:

[0023] Step S202, receive the Mth row of grayscale data to be printed, where the Mth row of grayscale data is the Mth row data in a K-order grayscale image, M is a positive integer greater than or equal to 1, and K is a positive integer greater than or equal to 2;

[0024] Step S204, store the Mth row of grayscale data and the first reference information in the first memory, where the first reference information includes the number of heating points to be heated for each order of grayscale data in the Mth row of grayscale data, the start byte of each order of grayscale data in the Mth row of grayscale data, and the end byte of each order of grayscale data in the Mth row of grayscale data;

[0025] Step S206, based on the first reference information, sequentially extract each order of grayscale data in the Mth row of grayscale data, and control the thermal print head to perform a thermal printing operation on the thermal medium according to each order of grayscale data in the Mth row of grayscale data until the Mth row of grayscale data is printed.

[0026] The thermal grayscale printing method in this embodiment can be applied to the field of image printing technology and applied to the scenario of image printing by a thermal printer. Here, the thermal grayscale printing technology is a printing technology that, during thermal printing, realizes different gray levels by controlling the heating intensity and time of the heating element. Different from the common dot matrix printing technology that realizes the dark display effect of an image by the density of dots, the dot matrix printing technology heats the printing medium by controlling the pixel dot matrix on the print head, thereby forming an image or text on the medium. Each pixel dot can be in the state of "heated" or "not heated", representing "printed" or "not printed" respectively. This binary printing mode can only achieve black and white effects, with a harsh transition and no delicate expressiveness of the image. However, the thermal grayscale printing technology can produce multiple intermediate gray effects from pure white to pure black to achieve delicate image performance. The key to realizing thermal grayscale printing lies in converting the gray information into heating control information, which usually requires the main control chip to have high processing capabilities and sufficient memory space to store and process complex grayscale data.

[0027] In traditional thermal grayscale printing technology, to achieve grayscale effects, the main control chip needs to store a large amount of heating data. For example, if the printer body uses a 300 DPI (Dots Per Inch) Rohm thermal film and an 8-inch machine has 2,592 pixel points per row, if dot matrix printing technology is used, printing each row by pixel points requires 324 bytes (in black and white printing, each pixel point can be represented by 1 bit as 0 or 1, and 1 byte has 8 bits, that is, 8 pixel points require 1 byte. Correspondingly, 2,592 pixel points require 2,592 / 8 = 324 bytes); however, if grayscale printing technology is used to print grayscale image data, the original data per row is 1,296 bytes (each pixel point requires 4-bit data to represent 16 gray levels, and 1 byte is 8 bits, so a total of 2,592*4 / 8 = 1,296 bytes are required). In addition, in existing grayscale printing schemes, after receiving data, a two-dimensional array of order N * single-row bytes is mostly used to store each-order data in the corresponding array, and the data is sent to the thermal printing head by SPI to print the data row by row by order. If 16-order grayscale is used, for each row of printed data, the chip needs to store 16 copies of heating information, each corresponding to the heating mode of one gray level. Still taking the example of printing an 8-inch-wide image at a resolution of 300 DPI, there are approximately 2,592 pixel points per row. Calculated according to 16-order grayscale, the memory requirement can be simply calculated as: original data 1,296 bytes + 16 orders * 324 bytes * 8 equal parts = 42,768 bytes (for each gray-level data in 16 gray levels, 324 bytes are required; considering the limited number of dots printed at one time, each gray-level data needs to be printed in 8 times, so the required storage data volume increases by 8 times), which will be very large, and the memory requirement increases exponentially. This not only increases the hardware cost but also limits the application of thermal grayscale printing technology in large-size printing devices because many low-cost printer designs are based on small MCUs (Microcontroller Units) with limited memory resources and it is difficult to meet the requirements of high-order grayscale printing.

[0028] It can be seen that the thermal grayscale printing method in the related technology has the problem of large memory occupation, which limits its random application in large-size printers.

[0029] In order to at least partially solve the above technical problems, in this embodiment, a thermal grayscale printing method for optimizing the data storage and processing process is proposed. Only the grayscale data of the specified row is received, and the grayscale data of the specified row and the relevant reference information (including the number of heating points to be heated for each grayscale data, the start byte, and the end byte) are stored in the memory. Based on the reference information, each grayscale data in the grayscale data is extracted and the print head is controlled to perform thermal printing operations according to each grayscale data. Thus, each grayscale data can be quickly extracted and processed based on the reference information, avoiding complex traversal and data retrieval processes, reducing memory occupancy. Therefore, the problem of high memory requirements in the thermal grayscale printing method in the related art can be solved, achieving the effect of reducing memory occupancy.

[0030] In this embodiment, the grayscale data of the Mth row to be printed can be received, where the grayscale data of the Mth row is the data of the Mth row in a K-order grayscale image. M is a positive integer greater than or equal to 1, and K is a positive integer greater than or equal to 2. Here, M represents the number of image rows. When printing an image, the printer usually prints row by row in the order from top to bottom; K represents the number of grayscale levels, that is, the number of different gray levels that each pixel in the image can present.

[0031] Here, the received data can be print instructions and data from an external application software. For example, print instructions and data from a computer-end application software or from a mobile-phone-end application software.

[0032] Optionally, the received grayscale data to be printed can be a data stream of the grayscale data obtained by preprocessing the picture to be printed. The preprocessing process that the picture to be printed needs to go through can include the following steps:

[0033] 1) In order to adapt to the printing size of the printer, the picture to be printed can be pre-adjusted in size to ensure that the picture to be printed can be completely printed on the thermal paper;

[0034] 2) The picture to be printed can be sharpened through image processing techniques and specific algorithms to enhance the sharpness of the picture;

[0035] 3) The picture to be printed can be converted into a 256-order grayscale image, where each pixel point only has a grayscale value, and the grayscale value represents the brightness of the pixel. In a grayscale image, the grayscale value range of the pixel is from 0 to 255, where 0 represents black, 255 represents white, and the intermediate values represent different gray levels;

[0036] 4) The 256 - level grayscale image can be processed by reducing its order through a dithering algorithm to generate a 16 - level grayscale image. Here, the dithering algorithm refers to a technique that can convert an image with a higher bit depth (such as a 256 - level grayscale image) into a lower bit depth (such as a 16 - level grayscale image) by adding tiny errors (noise) in the image to simulate the missing gray levels while trying to maintain the visual quality of the image.

[0037] 5) To protect the data security during transmission and reduce the data transmission volume, the 16 - level grayscale image data can be encrypted and compressed so that the application software can send it to the printer according to a specific printer communication protocol.

[0038] Optionally, the steps in the above - mentioned pre - processing process can be executed separately or in combination. The received data stream can be processed by some of the steps in the above - mentioned pre - processing process or by all of the steps in the above - mentioned pre - processing process.

[0039] Optionally, after receiving the data stream of the grayscale data obtained through the above pre - processing, the printer can parse the data stream. The parsed data can include, but is not limited to: start frame, picture size information, the number of occurrences of each gray level in a single - line grayscale data, the maximum print density attenuation ratio array, etc.

[0040] Optionally, the data stream received by the printer can include first reference information. The first reference information can include the number of pixels to be heated for each gray level in the M - th row of grayscale data (i.e., the number of pixel points that need to be heated for each gray level in the M - th row of grayscale data), the start byte of each gray level data in the M - th row of grayscale data (i.e., the position where each gray level data starts in the original data of the M - th row of grayscale data), and the end byte of each gray level data in the M - th row of grayscale data (i.e., the position where each gray level data ends in the original data of the M - th row of grayscale data).

[0041] Optionally, after receiving the data stream sent from the application software according to the specified protocol, the printer can create a data structure for storing the grayscale data of the M - th row and the first reference information.

[0042] Optionally, this data structure can include:

[0043] A one - dimensional array Buff_Data of unsigned char type for storing the original grayscale print data sent by the application software.

[0044] A 16 - dimensional array of unsigned short type for recording the number of pixels to be heated in the 16 - level grayscale data.

[0045] Two 16-dimensional arrays of unsigned short type are used to store the starting byte and ending byte of each gray level data respectively.

[0046] Optionally, for a 16-level grayscale image, the memory required for the printer to store data can be 1296 bytes (original data) + 2 * 16 bytes (the number of heating points for each of the 16 levels stored, 2 bytes for each level, used for the heating algorithm) + 2 * 2 * 16 bytes (the starting byte and ending byte for each of the 16 levels stored, used to speed up algorithm processing) = 1392 bytes.

[0047] In this embodiment, the printer can store the gray level data of the Mth row into the Buff_Data array, and at the same time store the information of the number of heating points to be heated, starting byte, and ending byte for each level into the above 16-dimensional array. For example, if in the gray level data of the first row, the number of heating points for the first gray level is 100, then the printer will store this value in the above array and record the starting position and ending position of the data of this level in the gray level data of the first row at the same time.

[0048] Optionally, based on the first reference information, each gray level data in the gray level data of the Mth row can be extracted in sequence, and the thermal print head can be controlled to perform a thermal printing operation on the thermal medium according to each gray level data in the gray level data of the Mth row until the gray level data of the Mth row is completely printed.

[0049] For example, it can start processing from the first gray level data of the specified row gray level data, read the number of heating points to be heated, starting byte, and ending byte of the first gray level, calculate the heating control data of the first gray level data according to the maximum print density attenuation ratio array, and control the thermal print head to heat the thermal medium according to the calculation result to print the data of this level; after completing the printing of the first gray level data, it can continue to extract the gray level data from the second level to the 16th level in sequence, and repeat the above calculation and printing process until all the specified row gray level data is printed.

[0050] Optionally, after all the 16-level gray level data of the specified row is printed, the stepper motor can be controlled to move the thermal film to prepare for printing the next row of data until the image to be printed is completely printed.

[0051] Optionally, the heating control data can be sent to the thermal print head through the SPI (Serial Peripheral Interface) communication protocol, so that the thermal print head heats the thermal medium (i.e., thermal paper) according to the received heating control data, thereby developing the gray level image of this row on the thermal paper.

[0052] Through the embodiments provided in this application, a thermal gray-scale printing method is applied to a thermal printer. The thermal printer includes a thermal print head, and the method includes: receiving the Mth row of gray-scale data to be printed, where the Mth row of gray-scale data is the Mth row data in a K-order gray-scale image, M is a positive integer greater than or equal to 1, and K is a positive integer greater than or equal to 2; storing the Mth row of gray-scale data and first reference information in a first memory, where the first reference information includes the number of heating points to be heated for each gray-scale data in the Mth row of gray-scale data, the start byte of each gray-scale data in the Mth row of gray-scale data, and the end byte of each gray-scale data in the Mth row of gray-scale data; based on the first reference information, sequentially extracting each gray-scale data in the Mth row of gray-scale data, and controlling the thermal print head to perform a thermal printing operation on the thermal medium according to each gray-scale data in the Mth row of gray-scale data until the Mth row of gray-scale data is printed, solving the problem of large memory occupation in the related thermal gray-scale printing method, and enabling low-memory occupation and low-cost gray-scale printing applicable to large-size printers.

[0053] In an exemplary embodiment, based on the first reference information, sequentially extracting each gray-scale data in the Mth row of gray-scale data, and controlling the thermal print head to perform a thermal printing operation on the thermal medium according to each gray-scale data in the Mth row of gray-scale data until the Mth row of gray-scale data is printed, includes:

[0054] Based on the first reference information, sequentially extracting each gray-scale data in the Mth row of gray-scale data;

[0055] Taking the sequentially extracted each gray-scale data as the current gray-scale data in turn to perform the following data printing operation until the Mth row of gray-scale data is printed, where the number of heating points to be heated for the current gray-scale data is the current number of heating points to be heated:

[0056] When the current number of heating points to be heated is greater than the specified number of points, determining the current average grouping number according to the current number of heating points to be heated and the specified number of points, where the specified number of points is the maximum number of points that the thermal print head is allowed to print at a time;

[0057] Dividing the current gray-scale data into multiple segments of gray-scale data according to the current average grouping number, where the number of heating points included in each segment of gray-scale data in the multiple segments of gray-scale data is less than or equal to the specified number of points;

[0058] Controlling the thermal print head to perform a thermal printing operation on the thermal medium according to each segment of gray-scale data in turn.

[0059] In the traditional printing process, the printer needs to preprocess and store the entire row of gray-scale data by grading, which will occupy a large amount of memory. In this embodiment, only the original gray-scale data and the start and end byte information of each grade need to be stored, and the data of a specific gray-scale can be quickly located and processed during printing, greatly reducing the memory requirement.

[0060] Optionally, based on the first reference information, each gray-scale data of the Mth row can be sequentially extracted to obtain the number of points to be heated for the current gray-scale data, and the number of points to be heated for the current gray-scale data is used as the current number of points to be heated. Here, the number of points to be heated for the current gray-scale data can be pre-configured or obtained by traversing the current gray-scale data based on the start byte and the end byte of the current gray-scale data.

[0061] Limited by the physical characteristics of the thermal print head, the maximum number of heating points of the thermal print head is limited. When the number of points to be heated exceeds the maximum number of heating points of the used thermal print head, the current gray-scale data can be evenly divided to ensure that the number of points heated each time does not exceed the maximum number of heating points of the thermal print head.

[0062] Optionally, the above maximum number of heating points can be the maximum number of points allowed to be printed in a single time, which can be specified by a parameter. That is, the maximum number of heating points of the used thermal print head can be set as the specified number of points. According to the number of points to be heated in the current stage, it is judged whether it exceeds the specified number of points. When the current number of points to be heated is greater than the specified number of points, the current average grouping number is determined according to the current number of points to be heated and the specified number of points, and the current gray-scale data is evenly divided into multiple segments of gray-scale data according to the current average grouping number. Among them, the number of heating points included in each segment of gray-scale data in the multiple segments of gray-scale data is less than or equal to the specified number of points. Here, the specified number of points can be less than or equal to the maximum number of points that can be printed in a single time measured by experiments. The maximum number of points that can be printed in a single time can be determined based on the number of points already printed when the quality of the printed points is lower than the quality threshold. Setting the specified number of points to be less than or equal to the maximum number of points that can be printed in a single time measured by experiments can ensure the thermal printing effect.

[0063] For example, the maximum number of points that can be printed in a single time measured by experiments is 330, and the specified number of points is set to 320 (that is, only 320 points are allowed to be printed in a single time). Suppose the number of points to be heated for the first-order gray-scale data is 400 points and the specified number of points is 320 points. The number of points to be heated can be evenly divided into two segments, and each segment contains data with no more than 320 points.

[0064] Optionally, the thermal print head can be controlled to perform a thermal printing operation on the thermal medium according to each segment of gray-scale data in sequence. For example, the first-order gray-scale data can be evenly divided into two segments, each segment contains 200 points. The heating time is calculated for each segment of gray-scale data in sequence, and the thermal print head is controlled to heat the corresponding 200 points on the thermal medium until all the points in the first-order gray-scale data are printed.

[0065] Optionally, the thermal printing operation performed on each segment of the halftone data after equal division can be performed alternately. For example, assuming that the number of dots to be heated for the first-order halftone data is 400 dots, and the specified number of dots is 320 dots, the 400 dots to be heated can be evenly divided into two segments. For the first time, the 1st dot, the 3rd dot, the 5th dot, and so on can be heated until the 399th dot is heated; for the second time, the 2nd dot, the 4th dot, the 6th dot, and so on can be heated until the 400th dot is heated. Thus, the first-order halftone data is heated completely. By evenly dividing the data and heating it alternately, the uniformity of thermal printing can be improved, and the thermal printing effect can be enhanced.

[0066] Similarly, the above steps of equal division can be repeated for each order of the halftone data in the Mth row until all orders of data are printed.

[0067] Through this embodiment, by dynamically adjusting the number of equal division groups according to the currently to-be-printed data to ensure that the number of dots to be heated for each segment of data does not exceed the maximum number of dots that the thermal print head can heat, the printing speed and quality can be improved, and poor printing effects can be avoided.

[0068] In an exemplary embodiment, based on the first reference information, each order of the halftone data in the Mth row is extracted in sequence, including: traversing the halftone data in the Mth row based on the start byte and the end byte of each order of the halftone data in the Mth row to obtain each order of the halftone data in the Mth row.

[0069] Optionally, the start byte and the end byte of each order of the halftone data in the Mth row can be read from the stored first reference information, and the halftone data in the Mth row can be traversed to obtain each order of the halftone data in the Mth row. For example, the halftone data in the Mth row and the first reference information can be received and stored, and the halftone data in the Mth row can be traversed according to the start byte and the end byte of the first order in the first reference information (assuming that the start byte of the first order is 100 and the end byte is 150), the 100th byte of the halftone data in the Mth row can be located, and the data from the 100th byte to the 150th byte can be read and extracted to determine it as the data of the first-order halftone.

[0070] Similar to the foregoing embodiment, after reading the first-order halftone data, the above traversing and extracting process can be continued according to the start and end bytes of the second order in the first reference information until all 16 orders of halftone data are extracted.

[0071] Through this embodiment, by traversing the halftone data of the specified row based on the first reference information to obtain each order of the halftone data in the specified row, the memory occupancy can be reduced and the printing speed can be improved.

[0072] In an exemplary embodiment, controlling a thermal print head to perform a thermal printing operation on a thermal medium in sequence according to each segment of grayscale data includes: determining a heating time corresponding to each segment of grayscale data, where the heating time corresponding to each segment of grayscale data is the heating time required for the thermal print head to print each segment of grayscale data; controlling the thermal print head to heat according to the heating time corresponding to each segment of grayscale data, and sending each segment of grayscale data as a print data stream to the thermal print head, so that the thermal print head performs a thermal printing operation on the thermal medium according to the received print data stream.

[0073] In this embodiment, according to each segment of grayscale data and the characteristics of the thermal print head, the heating time corresponding to this segment of grayscale data can be calculated. Here, each segment of grayscale data refers to the number of dots that need to be heated simultaneously in a segment of grayscale data after equal division. Similar to the foregoing embodiment, the number of heated dots is limited by the maximum number of heated dots of the thermal film. When the maximum number is exceeded, the data needs to be equally divided and heated in multiple times; the heating time corresponding to this segment of grayscale data is the time required for the thermal print head to heat the thermal medium to a level sufficient to display this segment of grayscale data. Generally, the length of the heating time corresponding to each segment of grayscale data is related to the depth of the grayscale in this segment of grayscale data. A deeper grayscale value requires a longer heating time to achieve the developing effect.

[0074] Optionally, the maximum print density attenuation ratio array can be parsed from the data stream of the grayscale data obtained after preprocessing. Here, the maximum print density attenuation ratio array refers to the adjustment coefficient of the heating time or heating intensity set for each grayscale in order to achieve accurate printing of different grayscales during the thermal printing process. It can be preset according to the characteristics of the thermal print head and the thermal medium. Each value in the array can correspond to each grayscale value. Thus, the heating time required for each segment of grayscale data can be calculated based on the maximum print density attenuation ratio array.

[0075] Optionally, each segment of grayscale data can be used as a print data stream and sent to the thermal print head through an appropriate communication protocol (such as the SPI communication protocol). The print data stream can include specific pixel position information and corresponding heating time information for each segment of grayscale data, so that after receiving the print data stream, the thermal print head heats the corresponding pixels on the thermal medium according to the heating time information indicated in the print data stream.

[0076] Through this embodiment, by determining the heating time corresponding to each segment of grayscale data and controlling the thermal print head to heat, the printing accuracy can be improved and the quality of the printed image can be enhanced.

[0077] In an exemplary embodiment, determining the heating time corresponding to each segment of grayscale data includes: calculating the heating time corresponding to each segment of grayscale data according to a set heating time calculation formula based on the input power of the thermal print head, the input voltage of the thermal print head, the average resistance of the thermal print head, and the number of heating points included in each segment of grayscale data.

[0078] In this embodiment, the accurate heating time can be determined according to the physical characteristics of the thermal print head (such as input power, input voltage, average resistance, etc.) and the number of heating points of each segment of grayscale data according to a preset heating time calculation formula.

[0079] In grayscale printing, an image can be divided into different grayscale data, and each segment of data corresponds to a specific set of pixel points to be heated. Correspondingly, the length of the heating time directly reflects the depth of that grayscale level in the image. Dark grayscale levels (such as those close to black) may require a longer heating time to ensure sufficient heat energy transfer to cause the chemical substances on the thermal paper to change color and form a clear image. On the contrary, light grayscale levels (such as those close to white) may require a shorter heating time.

[0080] Optionally, the heating time can depend on parameters such as the heating voltage of the thermal print head, various resistance values (such as the average resistance of the thermal print head, common resistance, driver saturation resistance, etc.), the number of heating elements working simultaneously (corresponding to the number of heating points included in each segment of grayscale), and the target energy (i.e., the energy required to be delivered to each heating point to achieve a specific grayscale development), etc.

[0081] In addition, the target energy can be pre-set or adjusted as needed during the printing process.

[0082] In this embodiment, the heating time of each segment of grayscale data can be calculated in real time according to the above parameters and the preset heating time calculation formula corresponding to the above parameters. For example, when printing a line of an image, the heating time can be calculated in real time according to the number of heating points of different grayscale data in this line, combined with parameters such as the input power, voltage, and average resistance of the thermal print head.

[0083] Optionally, the heating time corresponding to each segment of grayscale data can also be calculated by other methods. For example, the heating times required for different grayscale levels and different heating points can be pre-set and stored as a heating time table and directly looked up when needed. This embodiment does not limit this.

[0084] Through this embodiment, calculating the heating time corresponding to each segment of grayscale data based on the physical characteristics of the thermal print head and the number of heating points included in each segment of grayscale data can improve the quality and efficiency of grayscale printing.

[0085] In an exemplary embodiment, the extracted gray-scale data of each order is sequentially used as the current-order gray-scale data to perform the following data printing operations until the gray-scale data of the Mth row is printed. It further includes: when the current number of heating points to be processed is less than or equal to the specified number of points, controlling the thermal print head to perform a thermal printing operation on the thermal medium according to the current-order gray-scale data.

[0086] Similar to the foregoing embodiment, when processing the gray-scale data of each order, it can be determined whether the current number of heating points to be processed is within the specified number of points limit (i.e., less than or equal to the specified number of points). If so, it means that the current number of heating points does not exceed the maximum number of heating points of the thermal print head, and data equalization processing can be omitted. The thermal print head can be directly controlled to perform a thermal printing operation on the thermal medium according to the current-order gray-scale data.

[0087] Optionally, the data processing process for the gray-scale data of each order can be similar, and the time consumed for the data processing of the gray-scale data of each order can also be similar, which will not be elaborated here.

[0088] For example, as Figure 3 shown, thermal gray-scale printing can be completed through the steps in Figure 3 . Among them, in the algorithm for completing thermal gray-scale printing, data structures such as unsigned char*DataBuf, char GrayLevel, unsigned char Fill_Index, and unsigned char AvgIndex can be included to store the corresponding original gray-scale data, order index, data filling index, and equalization index, and the processed thermal printing data can be generated:

[0089] Step S301: Start;

[0090] Step S302: Judge the order index, equalization index, and filling index (judge whether it needs to be reset or adjusted);

[0091] Step S303: Judge whether it is the 0th order. If so, it is blank content that does not need to be printed, and directly end. If not, go to Step S304;

[0092] Step S304: Judge whether there are heating points (i.e., the number of heating points to be processed). If not, directly end. If there are, go to Step S305;

[0093] Step S305: Traverse from the start byte to the end byte of the single-line data (i.e., the end byte);

[0094] Step S306: Determine whether to perform equal division based on the order index (i.e., locate and track the order data being currently processed according to the order index and make a judgment based on the read grayscale data information). If so, go to step S307; if not, go to step 310;

[0095] Step S307: Determine whether the number of equal division groups is the default value (the default value is 1. If so, it means no equal division is required; if not, it means equal division is required). If so, go to step S309; if not, go to step 308;

[0096] Step S308: Calculate the number of equal division groups according to the maximum number of heating points;

[0097] Step S309: Fill the data required for SPI printing according to the order index and the equal division index;

[0098] Step S310: Fill the data required for SPI printing according to the order index;

[0099] Step S311: End.

[0100] Here, the equal division index refers to a counter used to track the number of equal division segments currently being processed when the grayscale data of the current order needs to be divided into multiple segments for printing. For example, if the data of the current order needs to be divided into 8 segments, the equal division index will increment from 0 to 7, and each increment represents the completion of printing one segment of data; the order index is used to track the order number being currently processed, starting from the grayscale data of the first order until the grayscale data of the 16th order, and the order index increments; the filling index is used to track the filling position of the current data segment in the SPI data buffer during equal division printing.

[0101] Optionally, the above processing algorithm for thermal grayscale printing data may also include a heating index, which is used to identify which order of heating printing is currently being processed. For example, as Figure 4 shown:

[0102] Step S401, Start;

[0103] Step S402, The algorithm obtains the data of the 0th order and records the heating time;

[0104] Step S403, Wait for the data transmission to complete;

[0105] Step S404, Determine whether the heating index is less than 15. If so, continue; if not, end;

[0106] Step S405, Determine whether the number of equal division groups is 1 (i.e., determine whether the current number of heating points does not exceed the single heating limit of the thermal print head). If so, go to step S406; if not, execute step S411;

[0107] Step S406, increment the order index by 1 (i.e., order index++);

[0108] Step S407, the timer fills in the recorded heating time;

[0109] Step S408, the algorithm obtains the current order heating data, the number of evenly divided groups, and the heating time;

[0110] Step S409, start heating;

[0111] Step S410, send the data to be heated next time;

[0112] Step S411, determine whether the evenly divided index is less than the number of evenly divided groups (i.e., determine whether all current data groups have been processed. If the evenly divided index is less than the number of evenly divided groups, it means there are still unprocessed data groups). If so, execute Step S412. If not, end;

[0113] Step S412, increment the evenly divided index by 1 (i.e., evenly divided index++);

[0114] Step S413, obtain the heating data and heating time of the next evenly divided index;

[0115] Step S414, the timer fills in the recorded heating time;

[0116] Step S415, start heating;

[0117] Step S416, send the data to be heated next time;

[0118] Step S417, end.

[0119] Through this embodiment, when the number of points to be heated is less than or equal to the specified number of points, directly controlling the thermal print head for heating and printing can improve the flexibility and efficiency of thermal grayscale printing.

[0120] In an exemplary embodiment, after storing the M-th row of grayscale data and the first reference information in the first memory, the method further includes: receiving the (M + 1)-th row of grayscale data to be printed, where the (M + 1)-th row of grayscale data is the (M + 1)-th row data in a K-level grayscale image; storing the (M + 1)-th row of grayscale data and the second reference information in the second memory, where the second reference information includes the number of heating points of each level of grayscale data in the (M + 1)-th row of grayscale data, the start byte of each level of grayscale data in the (M + 1)-th row of grayscale data, and the end byte of each level of grayscale data in the (M + 1)-th row of grayscale data, and the first memory and the second memory are used to alternately fill and print a row of grayscale data; based on the second reference information, sequentially extract each level of grayscale data in the (M + 1)-th row of grayscale data, and control a thermal print head to perform a thermal printing operation on a thermal medium according to each level of grayscale data in the (M + 1)-th row of grayscale data until the (M + 1)-th row of grayscale data is printed out.

[0121] Optionally, a double-buffer mechanism can be introduced, and two independent memory areas (i.e., the first memory and the second memory) are used to store and process different rows of data and the corresponding reference information.

[0122] Specifically, after receiving the M-th row of grayscale data to be printed and storing the machine's first reference information in the first memory, the next row of data to be printed (i.e., the (M + 1)-th row of grayscale data) can be continuously received, and the next row of data and the corresponding second reference information are stored in the second memory to prepare for subsequent printing operations. Thus, when printing a row of data, the preprocessing of the next row of data is already in progress, avoiding the printing delay caused by waiting for the data preprocessing to be completed and ensuring a seamless transition in the printing process.

[0123] Similarly, after the M-th row of data is printed, the first memory will be released to prepare for storing the next row of data (i.e., the (M + 2)-th row of grayscale data), and the data in the second memory starts to be printed. Here, based on the second reference information, the process of sequentially extracting each level of grayscale data in the (M + 1)-th row of grayscale data and controlling the thermal print head to perform a thermal printing operation on the thermal medium according to each level of grayscale data in the (M + 1)-th row of grayscale data is similar to that in the foregoing embodiment and will not be elaborated here.

[0124] Through this embodiment, by adopting a double-buffer storage mechanism and an alternating printing strategy, the printing speed of large-size grayscale printing can be improved.

[0125] It should be noted that for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that this application is not limited by the described action sequence, because according to this application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to this application.

[0126] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by means of software plus a necessary general hardware platform. Of course, it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of this application, in essence, or the part that makes a contribution to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM (Read-Only Memory), RAM (Random Access Memory), magnetic disk, optical disk), and includes several instructions for causing a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in various embodiments of this application.

[0127] According to another aspect of the embodiments of this application, a thermal grayscale printing device is also provided. This thermal grayscale printing device can be used to implement the thermal grayscale printing method provided in the above embodiments, and those that have been described will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that can achieve a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware is also possible and contemplated.

[0128] Figure 5 is a structural block diagram of an optional thermal grayscale printing device according to the embodiments of this application. As Figure 5 shown in, this thermal grayscale printing device includes:

[0129] A first receiving unit 502, configured to receive the grayscale data of the Mth row to be printed, where the grayscale data of the Mth row is the data of the Mth row in a K-order grayscale image, M is a positive integer greater than or equal to 1, and K is a positive integer greater than or equal to 2.

[0130] A first storage unit 504, configured to store the grayscale data of the Mth row and first reference information in a first memory, where the first reference information includes the number of heating points to be heated for each grayscale data in the grayscale data of the Mth row, the start byte of each grayscale data in the grayscale data of the Mth row, and the end byte of each grayscale data in the grayscale data of the Mth row.

[0131] The first execution unit 506 is configured to sequentially extract each gray-scale data of the Mth row of gray-scale data based on the first reference information, and control the thermal printing head to perform a thermal printing operation on the thermal medium according to each gray-scale data of the Mth row of gray-scale data until the Mth row of gray-scale data is printed completely.

[0132] It should be noted that the first receiving unit 502 in this embodiment can be used to execute the above step S202, the first storage unit 504 in this embodiment can be used to execute the above step S204, and the first execution unit 506 in this embodiment can be used to execute the above step S206.

[0133] Through the embodiment provided by the present application, the Mth row of gray-scale data to be printed is received, where the Mth row of gray-scale data is the Mth row data in a K-order gray-scale image, M is a positive integer greater than or equal to 1, and K is a positive integer greater than or equal to 2; the Mth row of gray-scale data and the first reference information are stored in the first memory, where the first reference information includes the number of heating points to be heated for each gray-scale data in the Mth row of gray-scale data, the start byte of each gray-scale data in the Mth row of gray-scale data, and the end byte of each gray-scale data in the Mth row of gray-scale data; based on the first reference information, each gray-scale data of the Mth row of gray-scale data is sequentially extracted, and the thermal printing head is controlled to perform a thermal printing operation on the thermal medium according to each gray-scale data of the Mth row of gray-scale data until the Mth row of gray-scale data is printed completely, which solves the problem of large memory occupation in the thermal gray-scale printing method in the related art and reduces the memory requirement of the thermal gray-scale printing method.

[0134] In an exemplary embodiment, the first execution unit includes: an extraction module, configured to sequentially extract each gray-scale data of the Mth row of gray-scale data based on the first reference information; a first execution module, configured to sequentially use each extracted gray-scale data as the current gray-scale data to perform the following data printing operation until the Mth row of gray-scale data is printed completely, where the number of heating points to be heated for the current gray-scale data is the current number of heating points to be heated: when the current number of heating points to be heated is greater than the specified number of points, determine the current average grouping number according to the current number of heating points to be heated and the specified number of points, where the specified number of points is the maximum number of points that the thermal printing head is allowed to print at a single time; divide the current gray-scale data into multiple segments of gray-scale data according to the current average grouping number, where the number of heating points included in each segment of gray-scale data in the multiple segments of gray-scale data is less than or equal to the specified number of points; a second execution module, configured to sequentially control the thermal printing head to perform a thermal printing operation on the thermal medium according to each segment of gray-scale data.

[0135] In an exemplary embodiment, the extraction module includes: a traversal sub-module configured to traverse the grayscale data of the M-th row based on the start byte and the end byte of each level of grayscale data in the grayscale data of the M-th row, so as to obtain each level of grayscale data in the grayscale data of the M-th row.

[0136] In an exemplary embodiment, the first execution module includes: a determination sub-module configured to determine the heating time corresponding to each segment of grayscale data, where the heating time corresponding to each segment of grayscale data is the heating time required for the thermal print head to print each segment of grayscale data; an execution sub-module configured to control the thermal print head to heat according to the heating time corresponding to each segment of grayscale data, and send each segment of grayscale data as a print data stream to the thermal print head, so that the thermal print head performs a thermal printing operation on the thermal medium according to the received print data stream.

[0137] In an exemplary embodiment, the determination sub-module includes: a calculation sub-unit configured to calculate the heating time corresponding to each segment of grayscale data according to a set heating time calculation formula based on the input power of the thermal print head, the input voltage of the thermal print head, the average resistance of the thermal print head, and the number of heating points included in each segment of grayscale data.

[0138] In an exemplary embodiment, the first execution module further includes: a control sub-module configured to, when the number of points to be heated currently is less than or equal to the specified number of points, control the thermal print head to perform a thermal printing operation on the thermal medium according to the grayscale data of the current level.

[0139] In an exemplary embodiment, the above device further includes: a second receiving unit configured to receive the grayscale data of the (M + 1)-th row to be printed after storing the grayscale data of the M-th row and the first reference information into the first memory, where the grayscale data of the (M + 1)-th row is the data of the (M + 1)-th row in the K-level grayscale image; a second storage unit configured to store the grayscale data of the (M + 1)-th row and the second reference information into the second memory, where the second reference information includes the number of heating points of each level of grayscale data in the grayscale data of the (M + 1)-th row, the start byte of each level of grayscale data in the grayscale data of the (M + 1)-th row, and the end byte of each level of grayscale data in the grayscale data of the (M + 1)-th row, and the first memory and the second memory are used to alternately fill and print a row of grayscale data; a second execution unit configured to sequentially extract each level of grayscale data in the grayscale data of the (M + 1)-th row based on the second reference information, and control the thermal print head to perform a thermal printing operation on the thermal medium according to each level of grayscale data in the grayscale data of the (M + 1)-th row until the grayscale data of the (M + 1)-th row is printed completely.

[0140] It should be noted that the above-mentioned modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above-mentioned modules are all located in the same processor; or, the above-mentioned modules are respectively located in different processors in any combination form.

[0141] According to another aspect of the embodiments of the present application, there is provided a computer-readable storage medium. The computer-readable storage medium includes a stored program, wherein when the program runs, it executes the steps in any one of the above method embodiments.

[0142] In an exemplary embodiment, the above computer-readable storage medium may include, but is not limited to: various media such as USB flash drives, ROMs, RAMs, mobile hard disks, magnetic disks, or optical discs that can store computer programs.

[0143] According to another aspect of the embodiments of the present application, there is provided an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. The processor is configured to execute the steps in any one of the above method embodiments through the computer program. In an exemplary embodiment, the above electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the above processor, and the input / output device is connected to the above processor.

[0144] The specific examples in this embodiment may refer to the examples described in the above embodiments and exemplary embodiments, and will not be elaborated here.

[0145] According to another aspect of the embodiments of the present application, there is also provided a computer program product. The computer program product includes computer programs / instructions, and the computer programs / instructions include program codes for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the central processing unit 601, it executes various functions provided by the embodiments of the present application. The serial numbers of the above embodiments of the present application are only for description and do not represent the advantages or disadvantages of the embodiments.

[0146] Figure 6 Schematically shows a block diagram of a computer system of an electronic device for implementing the embodiments of the present application. As Figure 6As shown, computer system 600 includes a CPU (Central Processing Unit), i.e., central processing unit 601, which can perform various appropriate actions and processes according to programs stored in ROM 602 or programs loaded into RAM 603 from storage section 608. In random access memory 603, various programs and data required for system operations are also stored. Central processing unit 601, read-only memory 602, and random access memory 603 are connected to each other via bus 604. An I / O (Input / Output) interface 605 is also connected to bus 604.

[0147] The following components are connected to I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including, for example, a CRT (Cathode Ray Tube), an LCD (Liquid Crystal Display), etc. and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a local area network card, a modem, etc. Communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to input / output interface 605 as required. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on drive 610 as required so that a computer program read from it can be installed into storage section 608 as required.

[0148] In particular, according to an embodiment of the present application, the processes described in each method flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes program codes for performing the methods shown in the flowcharts. In such an embodiment, the computer program can be downloaded and installed from a network via communication section 609, and / or installed from removable medium 611. When the computer program is executed by central processing unit 601, various functions defined in the system of the present application are executed.

[0149] It should be noted that Figure 6 the computer system 600 of the electronic device shown is only an example and should not impose any limitations on the functions and scope of use of the embodiments of the present application.

[0150] Obviously, those skilled in the art should understand that the various modules or steps of the present application described above can be implemented by a general-purpose computing device. They can be concentrated on a single computing device or distributed over a network composed of multiple computing devices. They can be implemented by program codes executable by the computing device. Thus, they can be stored in a storage device and executed by the computing device. And in some cases, the steps shown or described can be executed in a different order from here, or they can be separately fabricated into individual integrated circuit modules, or multiple modules or steps among them can be fabricated into a single integrated circuit module for implementation. In this way, the present application is not limited to any specific combination of hardware and software.

[0151] The above are only the preferred embodiments of the present application and are not used to limit the present application. For those skilled in the art, the present application can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the principle of the present application shall be included within the protection scope of the present application.

Claims

1. A thermal gray-scale printing method, characterized in that, Applied to a thermal printer, the thermal printer includes a thermal print head, and the method includes: Receiving the M-th row of grayscale data to be printed, where the M-th row of grayscale data is the M-th row data in a K-order grayscale image, M is a positive integer greater than or equal to 1, and K is a positive integer greater than or equal to 2; Storing the M-th row of grayscale data and first reference information in a first memory, where the first reference information includes the number of heating points to be heated for each order of grayscale data in the M-th row of grayscale data, the start byte of each order of grayscale data in the M-th row of grayscale data, and the end byte of each order of grayscale data in the M-th row of grayscale data; Based on the first reference information, sequentially extracting each order of grayscale data in the M-th row of grayscale data, and controlling the thermal print head to perform a thermal printing operation on the thermal medium according to each order of grayscale data in the M-th row of grayscale data until the M-th row of grayscale data is printed.

2. The method according to claim 1, characterized in that, The based on the first reference information, sequentially extracting each order of grayscale data in the M-th row of grayscale data, and controlling the thermal print head to perform a thermal printing operation on the thermal medium according to each order of grayscale data in the M-th row of grayscale data until the M-th row of grayscale data is printed, includes: Based on the first reference information, sequentially extracting each order of grayscale data in the M-th row of grayscale data; Taking the sequentially extracted each order of grayscale data as the current order of grayscale data to perform the following data printing operation until the M-th row of grayscale data is printed, where the number of heating points to be heated for the current order of grayscale data is the current number of heating points to be heated: In the case where the current number of heating points to be heated is greater than the specified number of points, determining the current average grouping number according to the current number of heating points to be heated and the specified number of points, where the specified number of points is the maximum number of points that the thermal print head is allowed to print at a time; Dividing the current order of grayscale data into multiple segments of grayscale data according to the current average grouping number, where the number of heating points included in each segment of grayscale data in the multiple segments of grayscale data is less than or equal to the specified number of points; Controlling the thermal print head to perform the thermal printing operation on the thermal medium according to each segment of grayscale data in sequence.

3. The method according to claim 2, wherein The based on the first reference information, sequentially extracting each order of grayscale data in the M-th row of grayscale data, includes: Traversing the M-th row of grayscale data based on the start byte of each order of grayscale data in the M-th row of grayscale data and the end byte of each order of grayscale data in the M-th row of grayscale data to obtain each order of grayscale data in the M-th row of grayscale data.

4. The method according to claim 2, wherein The controlling the thermal print head to perform the thermal printing operation on the thermal medium according to each segment of grayscale data in sequence, includes: Determining the heating time corresponding to each segment of grayscale data, where the heating time corresponding to each segment of grayscale data is the heating time required for the thermal print head to print each segment of grayscale data; Control the thermal print head to heat according to the heating time corresponding to each segment of grayscale data, and send each segment of grayscale data as a print data stream to the thermal print head, so that the thermal print head performs a thermal printing operation on the thermal medium according to the received print data stream.

5. The method according to claim 4, wherein The determining the heating time corresponding to each segment of grayscale data includes: Based on the input power of the thermal print head, the input voltage of the thermal print head, the average resistance of the thermal print head, and the number of heating points included in each segment of grayscale data, calculate the heating time corresponding to each segment of grayscale data according to a set heating time calculation formula.

6. The method according to claim 2, wherein The sequentially taking each extracted grayscale data of each order as the current-order grayscale data to perform the following data printing operation until the Mth row of grayscale data is printed further includes: When the current number of points to be heated is less than or equal to the specified number of points, control the thermal print head to perform the thermal printing operation on the thermal medium according to the current-order grayscale data.

7. The method according to any one of claims 1 to 6, characterized in that, After storing the Mth row of grayscale data and the first reference information into the first memory, the method further includes: Receiving the (M + 1)th row of grayscale data to be printed, where the (M + 1)th row of grayscale data is the (M + 1)th row data in the K-order grayscale image; Storing the (M + 1)th row of grayscale data and the second reference information into the second memory, where the second reference information includes the number of heating points of each segment of grayscale data in the (M + 1)th row of grayscale data, the start byte of each segment of grayscale data in the (M + 1)th row of grayscale data, and the end byte of each segment of grayscale data in the (M + 1)th row of grayscale data, and the first memory and the second memory are used to alternately fill and print a row of grayscale data; Based on the second reference information, sequentially extract each segment of grayscale data in the (M + 1)th row of grayscale data, and control the thermal print head to perform a thermal printing operation on the thermal medium according to each segment of grayscale data in the (M + 1)th row of grayscale data until the (M + 1)th row of grayscale data is printed.

8. A thermal grayscale printing device, characterized in that, Applied to a thermal printer, the thermal printer includes a thermal print head, and the device includes: A first receiving unit, configured to receive the Mth row of grayscale data to be printed, where the Mth row of grayscale data is the Mth row data in a K-order grayscale image, M is a positive integer greater than or equal to 1, and K is a positive integer greater than or equal to 2; A first storage unit, configured to store the Mth row of grayscale data and the first reference information into the first memory, where the first reference information includes the number of points to be heated of each segment of grayscale data in the Mth row of grayscale data, the start byte of each segment of grayscale data in the Mth row of grayscale data, and the end byte of each segment of grayscale data in the Mth row of grayscale data; A first execution unit, configured to sequentially extract each segment of grayscale data in the Mth row of grayscale data based on the first reference information, and control the thermal print head to perform a thermal printing operation on the thermal medium according to each segment of grayscale data in the Mth row of grayscale data until the Mth row of grayscale data is printed.

9. A computer program product, comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium, characterized in that, A computer program is stored in the computer-readable storage medium, wherein when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

11. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Thermal printing method and device, storage medium and electronic equipment

    CN118144453A

  • Thermal printing method and apparatus, storage medium, and electronic device

    CN118144453B