Image rendering and binary conversion control method, system and device and storage medium

By analyzing the data to be printed to calculate memory requirements and selecting an appropriate rendering strategy, the memory overflow problem of large-format, high-resolution printing tasks is solved. This achieves efficient rendering when memory resources are sufficient and block processing when memory is insufficient, ensuring the continuity and stability of the printing process.

CN121722341AActive Publication Date: 2026-03-24BEIJING SHUOFANG INFORMATION TECH CO LTD
View PDF 8 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-02-27
Publication Date
2026-03-24

AI Technical Summary

Technical Problem

Existing technologies are prone to memory overflow when handling large-format, high-resolution, or lengthy print jobs because memory requirements exceed the available memory limit of the printing device, leading to system crashes and the inability to execute print jobs.

Method used

The system parses the data to be printed to obtain the total width and height of the image, calculates the memory requirements, and selects an appropriate rendering strategy. When memory is sufficient, it creates a bitmap at once and performs binary conversion. When memory is insufficient, it processes the data to be printed in blocks, dynamically creates temporary bitmaps, and sends the binary data in sequence.

Benefits of technology

It ensures rendering efficiency when memory resources are sufficient, avoids memory overflow during large-scale printing tasks, ensures the continuity and stability of the printing process, and adapts to the needs of different printing scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121722341A_ABST
    Figure CN121722341A_ABST
Patent Text Reader

Abstract

The invention discloses an image rendering and binary conversion control method, system and device and a storage medium, and relates to the technical field of electronic printing device control. Receiving to-be-printed data, and determining a total memory space value according to the total image width, the total height and the unit pixel byte number of the to-be-printed data; if the total memory space value is smaller than or equal to the available memory threshold value, creating a first bitmap in the memory and drawing the to-be-printed data at one time to obtain a rendered image; if the total memory space value is greater than the available memory threshold value, dividing the to-be-printed data, creating a temporary bitmap in the memory based on the divided data blocks, and drawing the data blocks to obtain a temporarily rendered image; and performing binary conversion on the rendered image or the temporarily rendered image to obtain binary data corresponding to the second bitmap or the data block, and sending the binary data corresponding to the second bitmap or the data block to a printing head for printing. By implementing the provided technical scheme, the risk of memory overflow during large-scale printing tasks is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of electronic printing equipment control technology, specifically to an image rendering and binary conversion control method, system, device, and storage medium. Background Technology

[0002] Electronic printing equipment is increasingly widely used, especially in industrial automation, logistics warehousing, and retail. With the continuous improvement of production efficiency and information traceability requirements, printing tasks are trending towards higher speeds, wider formats, and higher resolutions. Therefore, designing an efficient and stable image rendering and printing control method to meet the real-time printing needs in complex scenarios has become a key problem urgently needing to be solved in this technical field.

[0003] In existing technologies, common image rendering methods involve creating a complete rendering bitmap in memory, corresponding to the final printed size, based on the overall dimensions of the image to be printed. Subsequently, all image elements, such as text, barcodes, and graphics, contained in the data to be printed are drawn onto this rendering bitmap, and finally, the rendered bitmap data is sent to the printer for printing.

[0004] However, the above approach employs a "one-time full-image rendering" strategy, which relies on the printing device having sufficient contiguous memory to accommodate the entire image to be printed. When handling large-format, high-resolution, or extremely lengthy print jobs, the size of the rendered bitmap to be created increases dramatically, and its memory requirements may easily exceed the printing device's available memory limit. In such cases, the first step of attempting to create the complete rendered bitmap will be interrupted due to memory allocation failure, causing the entire print job to fail and potentially leading to a system crash. Summary of the Invention

[0005] This application provides an image rendering and binary conversion control method, system, device, and storage medium. The method solves the risk of memory overflow during large-scale printing tasks and also ensures overall rendering efficiency when memory resources are sufficient.

[0006] In a first aspect, this application provides an image rendering and binary conversion control method, applied in a printing device. The method includes: receiving data to be printed; parsing the total width and total height of the image from the data to be printed; determining the number of bytes per unit pixel based on a preset rendering pixel format; calculating the total width, total height, and number of bytes per unit pixel to obtain the total memory space value required to render the entire data to be printed; obtaining an available memory threshold from the printing device; comparing the total memory space value with the available memory threshold; when the total memory space value is less than or equal to the available memory threshold, creating a first-bit image in memory based on the total memory space value; drawing the data to be printed onto the first-bit image at once to obtain the rendered image; performing binary conversion on the rendered image to obtain a second-bit image, and converting the second-bit image into a second-bit image. Figure 1 The data is sent to the print head for printing in one go. When the total memory space value is greater than the available memory threshold, the data to be printed is divided into multiple data blocks based on preset rules. A temporary bitmap is created in memory based on the target data block, and the target data block is drawn on the temporary bitmap to obtain a temporarily rendered image. The target data block is any one of the multiple data blocks. The temporarily rendered image is binary converted to generate the binary data corresponding to the target data block. The binary data is sent to the print head as part of the printing data in sequence until all data blocks have been processed and sent.

[0007] By adopting the above technical solution, the printing device first parses the data to be printed to obtain the total width and height of the image, and determines the number of bytes per pixel based on the preset rendering pixel format. It then calculates the required total memory space value and compares it with the printing device's available memory threshold to select the optimal processing path. When the total memory space value does not exceed the available memory threshold, a one-time rendering strategy is adopted, directly creating the first bitmap and drawing the entire data to be printed. Subsequently, a binary conversion is performed to obtain the second bitmap, which is then sent to the print head in one go to complete printing. When the total memory space value exceeds the available memory threshold, it automatically switches to a block processing mode, dividing the data to be printed into multiple data blocks according to preset rules. A temporary bitmap is dynamically created for each data block for rendering, and the corresponding binary data is sent to the print head immediately after binary conversion, until all data blocks are processed. This ensures overall rendering efficiency when memory resources are sufficient and also solves the risk of memory overflow during large-scale printing tasks. The dynamic creation and reuse of temporary bitmaps reduces memory resource consumption, and the sequential sending mechanism ensures the continuity and stability of the printing process, thereby achieving efficient adaptation to various printing scenarios.

[0008] Optionally, the data to be printed can be drawn onto the first image at once to obtain the rendered image. Specifically, this includes: parsing the data to be printed to obtain multiple image elements to be drawn; obtaining the type, position coordinates, and first content data of the first image element, where the first image element is any one of the multiple image elements; determining the first pixel area of ​​the type and first content data of the first image element on the first image, and generating a corresponding grayscale value for each pixel in the first pixel area; directly writing the grayscale values ​​corresponding to each pixel into the byte storage unit corresponding to each pixel in the first image, and obtaining the rendered image after writing all pixels in the first pixel area.

[0009] By employing the above technical solution, multiple image elements to be drawn are obtained by parsing the data to be printed. For each image element, information such as its type, position coordinates, and initial content data is acquired. Based on this information, the pixel region corresponding to the image element on the first-order image is determined, and the corresponding grayscale value is calculated for each pixel within the pixel region. These grayscale values ​​are directly written to the corresponding byte storage unit in the first-order image, avoiding intermediate caching and data conversion processes, thus improving data processing efficiency. Once all pixels have been written, a high-quality rendered image is obtained, achieving optimal resource utilization.

[0010] Optionally, the rendered image is subjected to binary conversion to obtain a second bitmap. Specifically, this includes: when the printing mode of the printing device is in forward sequence mode, obtaining the first grayscale value of the target pixel from the rendered image, where the target pixel is any pixel in the rendered image; when the first grayscale value is greater than or equal to a preset first threshold, marking the position corresponding to the target pixel in the second bitmap as a first state with ink dots; when the first grayscale value is less than the preset first threshold, marking the position corresponding to the target pixel in the second bitmap as a second state without ink dots; until all pixels in the rendered image are marked, a complete second bitmap is obtained.

[0011] By employing the above technical solution, each target pixel in the rendered image is scanned point by point to obtain the corresponding first grayscale value. This grayscale value is then compared with a preset first threshold to determine whether the pixel needs to be printed as an ink dot in the final output. When the first grayscale value exceeds the preset first threshold, the corresponding position in the second bitmap is marked as the first state with an ink dot; otherwise, it is marked as the second state without an ink dot. This simplifies the data structure and can accurately restore the image's brightness and darkness levels based on subtle differences in grayscale values, ensuring the clarity and contrast of the printed output. All pixels in the rendered image undergo uniform binarization processing to ultimately form a complete second bitmap, providing standardized printing control data for printing devices.

[0012] Optionally, the rendered image is binary converted to obtain a second bitmap. Specifically, this includes: when the printing mode of the printing device is flip mode, creating an original second bitmap in memory based on the size of the rendered image, and setting the initial values ​​of all positions in the original second bitmap to a second state without ink dots; obtaining a first position from the original second bitmap, performing a 180-degree coordinate flip mapping on the target position based on the total width and total height to obtain a first source pixel, which is the pixel corresponding to the first position in the rendered image; obtaining the second grayscale value corresponding to the first source pixel, and when the second grayscale value is greater than or equal to a preset second threshold, updating the state of the first position in the original second bitmap from the second state without ink dots to the first state with ink dots; after processing all positions in the original second bitmap, outputting the complete original second bitmap as the second bitmap.

[0013] By employing the above technical solution, an original second bitmap is created based on the dimensions of the rendered image, and all positions are initialized to a second state without ink dots. First positions are obtained one by one from the original second bitmap, and a 180-degree coordinate flip mapping is performed based on the total width and total height to accurately locate the corresponding first source pixel in the rendered image. The second grayscale value of each first source pixel is obtained and compared with a preset second threshold. Only when the second grayscale value reaches the preset second threshold is the state of the corresponding first position in the original second bitmap updated from the second state to the first state with ink dots. This coordinate mapping-based processing achieves precise image flipping. After processing all positions, a complete original second bitmap is output as the final second bitmap, providing accurate control data for printing in flip mode.

[0014] Optionally, the data to be printed is divided into multiple data blocks based on preset rules. Specifically, this includes: dividing the available memory threshold by the product of the total width and the unit pixel byte value to obtain the maximum block height of the temporary bitmap; determining the current starting height of the data to be printed; if the current starting height is less than the total height, the sum of the current starting height and the maximum block height is used as the target partition boundary; defining the area from the current starting height to the target partition boundary as the target area; searching for all image elements in the data to be printed that overlap with the target area in the vertical direction, and summarizing the image elements into a candidate element set; finding the maximum value of the bottom coordinates of the image elements in the candidate element set, and using the maximum value as the preliminary actual partition boundary; if the preliminary actual partition boundary is greater than the current starting height, the final actual partition boundary is the preliminary actual partition boundary; if the preliminary actual partition boundary is less than or equal to the current starting height, the final actual partition boundary is the target partition boundary; defining the candidate element set as a data block, and updating the current starting height to the final actual partition boundary, to divide the data to be printed into the next data block.

[0015] By employing the above technical solution, the maximum block height of the temporary bitmap can be accurately calculated by dividing the available memory threshold by the product of the total width and the unit pixel byte value. The target partition boundary is determined based on the current partitioning start height and the maximum block height, and the area between the start height and the boundary is set as the target region. Image elements that overlap vertically with the target region in the data to be printed are searched and added to a candidate element set. The maximum value of the bottom coordinates of the image elements in the candidate element set is used as the initial actual partition boundary, and the final actual partition boundary is determined based on its comparison with the current partitioning start height. This achieves intelligent segmentation of image elements. This adaptive boundary adjustment mechanism not only avoids the risk of forced truncation of image elements but also ensures the continuity of data block partitioning by determining the candidate set as data blocks and updating the partitioning start height.

[0016] Optionally, a temporary bitmap is created in memory based on the target data block, and the target data block is drawn onto the temporary bitmap to obtain a temporarily rendered image. Specifically, this includes: calculating the difference between the final actual partition boundary and the current partition starting height to obtain the block height of the target data block; calculating the total width, block height, and number of bytes per unit pixel to obtain the block memory space value of the target data block; creating a temporary bitmap in memory based on the block memory space value and obtaining the second image element from the target data block; obtaining the type of the second image element and obtaining the original position coordinates and second content data of the second image element in the data to be printed; determining the type of the second image element and the second pixel area of ​​the second content data on the temporary bitmap, and generating a corresponding grayscale value for each pixel in the second pixel area; subtracting the current partition starting height from the ordinate of the original position coordinates to obtain the drawing ordinate in the temporary bitmap; writing the grayscale value corresponding to each pixel into the corresponding byte storage unit in the temporary bitmap based on the drawing ordinate and the abscissa of the original position coordinates; and outputting the temporary bitmap as a temporarily rendered image after completing the drawing of all image elements in the target data block.

[0017] By employing the above technical solution, the block height of the target data block is obtained by calculating the difference between the final actual partition boundary and the current partition starting height. Combined with the total width and the number of bytes per pixel, the required block memory space value is calculated, thus achieving precise allocation of memory resources. After creating a temporary bitmap based on the block memory space value, the type, original position coordinates, and second content data of each second image element in the target data block are obtained. The corresponding second pixel region is then determined on the temporary bitmap, and a grayscale value is generated for each pixel within that region. The drawing ordinate in the temporary bitmap is obtained by subtracting the current partition starting height from the original position coordinates, achieving precise mapping of the coordinate space. Based on the calculated drawing ordinate and the original position coordinates, the grayscale value of the pixel is precisely written into the corresponding byte storage unit of the temporary bitmap, ensuring the accuracy of the rendering data.

[0018] Optionally, the temporarily rendered image is subjected to binary transformation to generate binary data corresponding to the target data block. Specifically, this includes: when the printing mode of the printing device is in ascending order, obtaining the third grayscale value of the second pixel from the temporarily rendered image, where the second pixel is any pixel in the temporarily rendered image; when the third grayscale value is greater than or equal to a preset third threshold, marking the position corresponding to the second pixel in the binary data corresponding to the target data block as a first state with ink dots; when the third grayscale value is less than the preset third threshold, marking the position corresponding to the second pixel in the binary data corresponding to the target data block as a second state without ink dots; until all pixels in the temporarily rendered image are processed, the complete binary data corresponding to the target data block is obtained; when the printing mode of the printing device is in flip mode, obtaining the temporarily rendered... The image block height is calculated, and a temporary binary data bitmap is created based on the total width and block height. The initial values ​​of all positions in the temporary binary data bitmap are set to the second state (no ink dots). The second position is obtained from the temporary binary data bitmap, and its coordinates are flipped 180 degrees based on the total width and block height to obtain the second source pixel. The second source pixel is the pixel corresponding to the second position in the temporarily rendered image. The fourth grayscale value corresponding to the second source pixel is obtained. When the fourth grayscale value is greater than or equal to a preset fourth threshold, the state of the second position in the temporary binary data bitmap is updated from the second state (no ink dots) to the first state (ink dots). After processing all positions in the temporary binary data bitmap, the complete temporary binary data bitmap is output as the binary data corresponding to the target data block.

[0019] By employing the above technical solution, in forward mode, the third grayscale value of each second pixel in the temporarily rendered image is obtained one by one and compared with a preset third threshold. The corresponding position in the binarized data corresponding to the target data block is marked as either a first state with ink dots or a second state without ink dots, thus completing the precise binarization conversion of the temporarily rendered image. In flip mode, a temporary binarized data bitmap is created based on the block height and total width of the temporarily rendered image, and all positions are initialized to the second state. By performing a 180-degree coordinate flip mapping on the second position in the temporary binarized data bitmap, the corresponding second source pixel in the temporarily rendered image is accurately located, and the fourth grayscale value is obtained. When the fourth grayscale value reaches the preset fourth threshold, only the state of the corresponding second position in the temporary binarized data bitmap is updated from the second state to the first state, achieving selective data update. This binarization process, which supports both forward and flip modes, not only adapts to the needs of different printing scenarios but also ensures the quality of printed output through precise threshold control and coordinate mapping.

[0020] The second aspect of this application provides an image rendering and binary conversion control system. The system is a printing device, which includes a receiving unit, a calculation unit, a rendering unit, and a sending unit. The receiving unit receives data to be printed and parses the total width and total height of the image from the data. The calculation unit determines the number of bytes per unit pixel based on a preset rendering pixel format, calculates the total width, total height, and number of bytes per unit pixel to obtain the total memory space value required to render the entire data to be printed; obtains an available memory threshold from the printing device and compares the total memory space value with the available memory threshold. The rendering unit creates a first-bit image in memory based on the total memory space value when the total memory space value is less than or equal to the available memory threshold; draws the data to be printed onto the first-bit image at once to obtain the rendered image; when the total memory space value is greater than the available memory threshold, divides the data to be printed according to preset rules to obtain multiple data blocks; creates a temporary bitmap in memory based on the target data block, draws the target data block onto the temporary bitmap to obtain a temporary rendered image, where the target data block is any one of the multiple data blocks. The sending unit performs binary conversion on the rendered image to obtain a second bitmap and sends the second bitmap to the printer. Figure 1 The data is sent to the print head in one go for printing; the temporarily rendered image is binarized to generate binarized data corresponding to the target data block, and the binarized data is sent to the print head as part of the printing data in sequence until all data blocks have been processed and sent.

[0021] In a third aspect, this application provides an electronic device including a processor, a memory, a user interface, and a network interface. The memory is used to store instructions, the user interface and the network interface are used to communicate with other devices, and the processor is used to execute the instructions stored in the memory, causing the electronic device to perform any of the methods described above in this application.

[0022] In a fourth aspect, this application provides a computer-readable storage medium storing instructions that, when executed, perform any of the methods described above in this application.

[0023] In summary, one or more technical solutions provided in the embodiments of this application have at least the following technical effects or advantages: 1. The printing device first parses the data to be printed to obtain the total width and height of the image, and determines the number of bytes per pixel based on a preset rendering pixel format. It then calculates the required total memory space value and compares it with the printing device's available memory threshold to select the optimal processing path. When the total memory space value does not exceed the available memory threshold, a one-time rendering strategy is adopted, directly creating the first bitmap and drawing the entire data to be printed. Subsequently, a binary conversion is performed to obtain the second bitmap, which is then sent to the print head in one go to complete printing. When the total memory space value exceeds the available memory threshold, it automatically switches to a block processing mode, dividing the data to be printed into multiple data blocks according to preset rules. For each data block, a temporary bitmap is dynamically created for rendering, and the corresponding binary data is sent to the print head immediately after binary conversion, until all data blocks are processed. This ensures overall rendering efficiency when memory resources are sufficient and mitigates the risk of memory overflow during large-scale printing tasks. The dynamic creation and reuse of temporary bitmaps reduces memory resource consumption, and the sequential sending mechanism ensures the continuity and stability of the printing process, thus achieving efficient adaptation to various printing scenarios. Attached Figure Description

[0024] Figure 1 This is a schematic flowchart of an image rendering and binary conversion control method provided in an embodiment of this application; Figure 2 This is a schematic diagram of the structure of an image rendering and binary conversion control system provided in an embodiment of this application; Figure 3 This is a schematic diagram of the structure of an electronic device disclosed in an embodiment of this application.

[0025] Explanation of reference numerals in the attached drawings: 201, receiving unit; 202, computing unit; 203, rendering unit; 204, transmitting unit; 300, electronic device; 301, processor; 302, memory; 303, user interface; 304, network interface; 305, communication bus. Detailed Implementation

[0026] To enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments.

[0027] In the description of the embodiments of this application, the words "for example" or "for instance" are used to indicate examples, illustrations, or explanations. Any embodiment or design that is described as "for example" or "for instance" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design options. Rather, the use of the words "for example" or "for instance" is intended to present the relevant concepts in a specific manner.

[0028] In the description of the embodiments of this application, the term "multiple" means two or more. For example, multiple systems means two or more systems, and multiple screen terminals means two or more screen terminals. Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the indicated technical features. Thus, a feature defined with "first" or "second" may explicitly or implicitly include one or more of that feature. The terms "comprising," "including," "having," and variations thereof all mean "including but not limited to," unless otherwise specifically emphasized.

[0029] Therefore, mitigating the risk of memory overflow during large-scale printing tasks is a pressing issue that needs to be addressed. This application provides an image rendering and binary conversion control method, applied in a printing device. Figure 1 This is a flowchart illustrating an image rendering and binary conversion control method provided in an embodiment of this application. (Refer to...) Figure 1 The method includes the following steps S101-S109.

[0030] S101: Receive the data to be printed and parse the total width and total height of the image from the data to be printed.

[0031] In step S101 above, during the printing task execution, the printing device receives the data to be printed from the host computer via standard communication interfaces such as USB, network, and serial port. The data to be printed contains basic information about the image content. The received data to be printed is parsed and processed to extract key parameter information.

[0032] By parsing the header information and data structure of the data to be printed, the number of pixels in the horizontal and vertical directions of the image to be printed is obtained, i.e., the total width and total height of the image. These dimensional parameters are crucial for subsequent memory allocation, rendering calculations, and printing output. Based on the parsed total width and total height of the image, the data scale of the printing task can be accurately assessed, providing a basis for selecting an appropriate rendering strategy. In practical applications, the data to be printed may come from various file formats, such as PDF, BMP, and JPG. Appropriate parsing methods will be used to extract the total width and total height information of the image based on the data structure characteristics of different formats, ensuring the accuracy of the parsing results.

[0033] S102: Determine the number of bytes per unit pixel based on the preset rendering pixel format, calculate the total width, total height and the number of bytes per unit pixel, and obtain the total memory space value required to render the entire data to be printed.

[0034] In step S102 above, during the rendering process, a preset rendering pixel format with 8-bit grayscale values ​​is used, with each pixel independently occupying 1 byte of memory space, meaning the unit pixel byte count is 1 byte. Allocating 256 levels of grayscale values ​​to each pixel ensures image display quality while simplifying pixel data storage and retrieval operations. The total width and height of the parsed image are multiplied to obtain the total number of pixels in the image to be printed. Then, the total number of pixels is multiplied by the unit pixel byte count to calculate the total memory space required to render the entire data to be printed. This method of pre-calculating memory requirements accurately assesses the resource consumption of the printing task.

[0035] Taking an 800×800 pixel image as an example, since each pixel occupies 1 byte, the calculated total memory space is 640,000 bytes. By calculating the required memory space, the feasibility of the printing task can be effectively predicted, avoiding interruptions in the printing process due to insufficient memory. This memory calculation method based on a preset rendering pixel format provides a reliable data foundation for subsequent memory allocation and rendering processing, improving the stability of system operation. The above calculation method is not only applicable to the processing of small-sized images, but also to large-scale image data in wide-format, high-resolution printing scenarios.

[0036] S103: Obtain the available memory threshold from the printing device and compare the total memory space value with the available memory threshold.

[0037] In step S103 above, the printing device needs to maintain a certain amount of internal margin during operation to ensure stable operation of basic functions. The available memory threshold of the printing device is obtained by querying the hardware resource status. This available memory threshold is a preset safety threshold based on the printing device's hardware configuration, used to ensure operational stability. The calculated total memory space value is compared with the obtained available memory threshold. This comparison effectively predicts whether the current print job exceeds the printing device's processing capacity. Through this threshold comparison mechanism, potential memory overflow risks can be identified before the print job officially begins.

[0038] For example, in a printing device using an STM32MP157 processor, if the available memory threshold is 512KB, and the total memory space required for the 800×800 pixel image to be processed is 640KB, it can be determined that the current printing task exceeds the safe processing range of the device, which can effectively avoid system crashes caused by insufficient memory resources.

[0039] S104: When the total memory space value is less than or equal to the available memory threshold, create a first-order graph in memory based on the total memory space value.

[0040] In step S104 above, after confirming that the total memory space value is less than or equal to the available memory threshold, a one-time rendering strategy is adopted for printing data processing. A contiguous storage area equal in size to the total memory space value is allocated in the printing device's memory to create a first-bit image for image rendering. The first-bit image uses an 8-bit grayscale format, with each pixel occupying 1 byte of storage space to store the grayscale information of the image. By allocating a sufficient amount of memory space at once, all pixel data of the image to be printed can be completely loaded into the first-bit image, avoiding data splitting and repeated loading operations during block processing.

[0041] For example, for an 800×800 pixel image with a total memory space of 640KB, a 640KB bitmap is created in the printing device's memory to ensure that the complete image data can be accommodated. This method of creating the complete bitmap at once simplifies subsequent rendering logic and improves data processing efficiency. With ample memory resources, there's no need to consider complex memory management strategies, allowing focus on improving rendering performance and print quality.

[0042] S105: Draw the data to be printed onto the first plot at once to obtain the rendered image.

[0043] In step S105 above, the data to be printed is drawn onto the first image at once to obtain the rendered image. Specifically, this includes: parsing the data to be printed to obtain multiple image elements to be drawn; obtaining the type, position coordinates, and first content data of the first image element, where the first image element is any one of the multiple image elements; determining the first pixel area of ​​the type and first content data of the first image element on the first image, and generating a corresponding grayscale value for each pixel in the first pixel area; directly writing the grayscale values ​​corresponding to each pixel into the byte storage unit corresponding to each pixel in the first image, and after writing all pixels in the first pixel area, the rendered image is obtained.

[0044] Specifically, during the rendering process, the content structure of the data to be printed is parsed, and the various image element information contained therein is identified and extracted. This image element information may include different types of content such as text, images, and barcodes. This content is stored as multiple image elements to be drawn. From these multiple image elements, a first image element is selected. The type information of the first image element (such as text, graphics, or barcode), its specific position coordinates in the image, and the first content data constituting the first image element are read. For example, for text-type image elements, information such as font, size, and style is obtained; for barcode types, features such as barcode specifications and data content are obtained. This element-based information acquisition method allows for the adoption of the most suitable rendering strategy for different types of content.

[0045] Based on the acquired first image element information, a first pixel region corresponding to the first image element is determined on the first image. The range of the first pixel region is determined by the element's position coordinates and the actual display size. According to the element type and the first content data, combined with the display requirements, a corresponding grayscale value is calculated for each pixel within the first pixel region. For example, pixels at the edges of text may require appropriate grayscale transitions to achieve a smooth effect, while pixels in the barcode area require clear contrast between light and dark areas.

[0046] A direct memory access method is used to write the calculated grayscale values ​​into the corresponding byte storage unit in the first image. The simple operation "_8bitmap[y*Width+x]=grayscale value" allows for quick and accurate setting of the grayscale value for each pixel. This direct write method avoids complex bitwise operations, significantly improving data processing efficiency. Once the grayscale values ​​of all pixels within the first pixel area have been written, the rendering process for the first image element is complete. By performing the same rendering process on all image elements, the complete rendered image is obtained. This element-based stepwise rendering strategy not only ensures rendering quality but also improves overall processing efficiency through simplified pixel operations, meeting the image processing performance requirements of high-speed printing equipment.

[0047] Actual testing showed that, compared to traditional binary bitmap rendering, the above rendering method reduced the processing time for an 800×800 pixel image from 300ms to 240ms, improving rendering efficiency by 2.5 times and effectively supporting the real-time requirements of wide-format high-speed printing equipment.

[0048] S106: Perform binary transformation on the rendered image to obtain a second bitmap, and then convert the second bitmap... Figure 1 It is sent to the print head for printing in one go.

[0049] In step S106 above, the print head of the printing device operates in binary output mode, so the rendered image in 8-bit grayscale format needs to be converted into a second bitmap in binary format. During the conversion process, the current printing mode of the printing device is determined, and then different conversion modes are selected to convert the rendered image. The two conversion modes will be described in turn below.

[0050] The first forward-order mode performs a binary transformation on the rendered image to obtain a second bitmap. Specifically, it includes: when the printing device is in forward-order mode, obtaining the first grayscale value of the target pixel from the rendered image, where the target pixel is any pixel in the rendered image; when the first grayscale value is greater than or equal to a preset first threshold, marking the position corresponding to the target pixel in the second bitmap as a first state with ink dots; when the first grayscale value is less than the preset first threshold, marking the position corresponding to the target pixel in the second bitmap as a second state without ink dots; until all pixels in the rendered image are marked, a complete second bitmap is obtained.

[0051] Specifically, in ascending order mode, the rendered image undergoes binary transformation. First, each target pixel in the rendered image is traversed, and its first grayscale value is read using direct memory access. This direct access method avoids complex bitwise operations, improving data reading efficiency. For example, for a target pixel with coordinates (x, y), its first grayscale value is directly obtained using the "_8bitmap[y*Width+x]" operation.

[0052] The acquired first grayscale value is compared with a preset first threshold, which is typically set to 128. This threshold can be adjusted according to actual printing needs to distinguish the printing status of ink dots. When the first grayscale value is greater than or equal to the preset first threshold, it indicates that the target pixel needs to be printed with ink dots. The value 1 is written to the corresponding position in the second bitmap to mark it as the first state with ink dots. The corresponding byte storage unit can be set to the first state through a simple assignment operation of "_1bitmap[y*Width+x]=1".

[0053] Furthermore, when the first grayscale value is less than a preset first threshold, it indicates that the target pixel does not need to be printed with ink. The value 0 is written to the corresponding position in the second bitmap, marking it as the second state without ink. The corresponding byte storage unit is set to the second state through the direct assignment operation "_1bitmap[y*Width+x]=0". This one-to-one pixel mapping method simplifies memory access logic and improves data processing efficiency.

[0054] The above binary conversion process is continuously executed until all pixels in the rendered image have been processed. Through point-by-point processing, the complete second bitmap data is finally generated. This grayscale threshold-based binary conversion strategy can accurately convert an 8-bit grayscale image into a binary format suitable for printhead output. Through direct memory access and simple assignment operations, data format conversion can be completed efficiently; for an 800×800 pixel image, the entire binary conversion process can be completed in just 240ms, meeting the data processing speed requirements of wide-format, high-speed printing equipment.

[0055] The second flip mode performs a binary conversion on the rendered image to obtain a second bitmap. Specifically, it includes: when the printing device is in flip mode, creating an original second bitmap in memory based on the size of the rendered image, and setting the initial values ​​of all positions in the original second bitmap to a second state without ink dots; obtaining a first position from the original second bitmap, performing a 180-degree coordinate flip mapping on the target position based on the total width and total height to obtain a first source pixel, which is the pixel corresponding to the first position in the rendered image; obtaining the second grayscale value corresponding to the first source pixel, and when the second grayscale value is greater than or equal to a preset second threshold, updating the state of the first position in the original second bitmap from the second state without ink dots to the first state with ink dots; after processing all positions in the original second bitmap, outputting the complete original second bitmap as the second bitmap.

[0056] Specifically, in flip mode, the required memory space is calculated based on the total width and total height of the rendered image. Since each pixel occupies 1 byte of storage, a contiguous memory space of total width * total height bytes is allocated to create the original second bitmap. The `memset` function is used to set the initial value of all byte storage units in the original second bitmap to 0, i.e., the second state without ink dots, laying the foundation for subsequent selective updates.

[0057] Iterate through each first position in the original second bitmap, and determine its corresponding first source pixel position in the rendered image through coordinate mapping. The 180-degree coordinate flip mapping is calculated as follows: the x-coordinate of the first source pixel equals the total width minus 1 minus the x-coordinate of the first position, and the y-coordinate equals the total height minus 1 minus the y-coordinate of the first position. For example, for an image of size 800×800, when the first position coordinates are (100, 200), its corresponding first source pixel coordinates are (699, 599). This mapping method achieves simultaneous horizontal and vertical flipping of the image.

[0058] The second grayscale value of the first source pixel is read using the operation "_8bitmap[Map_yWidth+Map_x]", where Map_x and Map_y are the coordinate values ​​after a 180-degree coordinate flip mapping. The obtained second grayscale value is compared with a preset second threshold (usually 128), which is used to distinguish ink dot states. When the second grayscale value is greater than or equal to the preset second threshold, it indicates that an ink dot needs to be printed at that location. The state of the first position in the original second bitmap is updated from the second state to the first state using the operation "_1bitmap[yWidth+x]=1". This selective update strategy avoids redundant processing of positions that do not require ink dot printing.

[0059] The above-described flip mapping and state update process continues until all positions in the original second bitmap have been processed. The complete original second bitmap is the desired second bitmap, in which the data has been flipped 180 degrees to adapt to the requirements of printheads with special installation angles. This binary conversion scheme based on flip mapping simplifies the data processing logic and improves conversion efficiency by using preset second states and selective updates.

[0060] The aforementioned binary conversion strategy based on printing mode generates a second bitmap adapted to the printhead's output requirements. After binary conversion, the complete second bitmap is sent to the printhead via a hardware interface. The printhead controls the ink ejection state of each nozzle based on the received binary data, completing the actual printing output of the image. This binary conversion scheme combining printing mode ensures print quality while improving printing efficiency through one-time data transmission, fully leveraging the performance advantages of wide-format, high-speed printing equipment.

[0061] S107: When the total memory space value is greater than the available memory threshold, the data to be printed is divided according to preset rules to obtain multiple data blocks.

[0062] In step S107 above, when the total memory space value is detected to be greater than the available memory threshold, a block processing strategy needs to be adopted to complete the rendering of large-size images. The maximum size of a single data block is calculated based on the available memory threshold to ensure that the memory usage of each data block does not exceed the processing capacity of the printing device.

[0063] The data to be printed is divided into multiple data blocks based on preset rules. Specifically, this includes: dividing the available memory threshold by the product of the total width and the unit pixel byte value to obtain the maximum block height of the temporary bitmap; determining the current starting height of the data to be printed; if the current starting height is less than the total height, the sum of the current starting height and the maximum block height is used as the target partition boundary; defining the area from the current starting height to the target partition boundary as the target area; searching for all image elements in the data to be printed that overlap with the target area in the vertical direction and summarizing these image elements into a candidate element set; finding the maximum value of the bottom coordinates of the image elements in the candidate element set and using this maximum value as the preliminary actual partition boundary; if the preliminary actual partition boundary is greater than the current starting height, the final actual partition boundary is the preliminary actual partition boundary; if the preliminary actual partition boundary is less than or equal to the current starting height, the final actual partition boundary is the target partition boundary; defining the candidate element set as a data block and updating the current starting height to the final actual partition boundary to proceed with the next data block division of the data to be printed.

[0064] Specifically, when dividing data into blocks, it's necessary to determine the appropriate height for each temporary bitmap. The maximum block height of the temporary bitmap is calculated by dividing the available memory threshold by the product of the total image width and the unit pixel byte value. For example, if the available memory threshold is 512KB, the total image width is 2400 pixels, and the unit pixel byte value is 1 byte, then the maximum block height of the temporary bitmap is 218 pixels. This height calculation method based on memory constraints ensures that the memory usage of each data block does not exceed the device's processing capacity.

[0065] The process begins by dividing the data from position 0 in the vertical direction. The starting height of the current division is added to the maximum block height to obtain the target division boundary. Taking the first data block as an example, the starting height of the current division is 0, and the target division boundary is 218 pixels. This 218-pixel area is used as the target region, and all image elements in the data to be printed are scanned. For each image element, its vertical range is checked to see if it overlaps with the target region. If there is an overlap, the element is added to the candidate element set. All image elements in the candidate element set are traversed, and their bottom coordinate values ​​are compared. For example, when the set contains text elements (bottom coordinate 230) and graphic elements (bottom coordinate 245), 245 is selected as the initial actual division boundary. This boundary determination method based on element integrity avoids improper segmentation of image elements.

[0066] The initial actual partition boundary (245) is compared with the current partition start height (0). Since 245 is greater than 0, 245 is determined as the final actual partition boundary. This dynamic boundary adjustment strategy ensures the integrity of image elements and improves rendering. The set containing all candidate elements is determined as the first data block, and the current partition start height is updated to 245 to prepare for the partitioning of the next data block.

[0067] The above partitioning process continues until the current partition's starting height reaches or exceeds the total height. This intelligent partitioning scheme, which considers the integrity of image elements, not only ensures that the memory usage of each data block is within the device's capacity but also avoids display anomalies caused by truncated image elements. Real-world testing shows that a large 2400×2400 pixel image can be accurately divided into 11 appropriately sized data blocks, with the processing time for each block remaining within 240ms, achieving efficient block processing of large images.

[0068] In one possible implementation, the number of image elements constituting the image can be used as a benchmark to divide the data to be printed. A benchmark number of elements can be set based on historical experience. Starting from the current processing position in the image element list of the data to be printed, a benchmark number of image elements is selected sequentially to form a target candidate element set. All image elements in the target candidate element set are traversed to determine their minimum starting coordinates (block top) and maximum ending coordinates (block bottom) vertically, thus obtaining the actual block height of the current data block. Based on the block height of the current data block and the total width of the image, the memory space required to render the current data block is calculated. The calculated required memory space is compared with an available memory threshold. When the required memory space is less than or equal to the available memory threshold, the next image element is added to the target candidate element set, and the above steps for the current data block are repeated until adding an element causes the required memory to exceed the available memory threshold. At this point, the set before the element is added is determined as a final data block.

[0069] When the required memory space exceeds the available memory threshold, the last added image element is removed from the target candidate element set, and the above steps for the current data block are repeated until the required memory is less than or equal to the available memory threshold. This set is then determined as a final data block. The bottom coordinates of the current data block are used as the starting height for the next partition, and the above process is repeated starting from the next image element until all image elements have been partitioned, resulting in multiple data blocks.

[0070] S108: Create a temporary bitmap in memory based on the target data block, draw the target data block onto the temporary bitmap, and obtain the temporarily rendered image.

[0071] In step S108 above, a data block, namely the target data block, is obtained from multiple data blocks. Based on the size parameters of the target data block, space of the corresponding size is allocated in the memory of the printing device to create a temporary bitmap for rendering. The temporary bitmap uses an 8-bit grayscale format, with each pixel occupying 1 byte of storage space independently.

[0072] A temporary bitmap is created in memory based on the target data block. The target data block is then drawn onto the temporary bitmap to obtain a temporarily rendered image. Specifically, this includes: calculating the difference between the final actual partition boundary and the current partition starting height to obtain the block height of the target data block; calculating the total width, block height, and number of bytes per pixel to obtain the block memory space value of the target data block; creating a temporary bitmap in memory based on the block memory space value and obtaining the second image element from the target data block; obtaining the type of the second image element and obtaining the original position coordinates and second content data of the second image element in the data to be printed; determining the type of the second image element and the second pixel region of the second content data on the temporary bitmap, and generating a corresponding grayscale value for each pixel within the second pixel region; subtracting the current partition starting height from the ordinate of the original position coordinates to obtain the drawing ordinate in the temporary bitmap; writing the grayscale value corresponding to each pixel into the corresponding byte storage unit in the temporary bitmap based on the drawing ordinate and the x-coordinate of the original position coordinates; and outputting the temporary bitmap as the temporarily rendered image after completing the drawing of all image elements in the target data block.

[0073] Specifically, the block height of the target data block is obtained by calculating the difference between the final actual partition boundary and the starting height of the current partition boundary. For example, if the final actual partition boundary is 245 pixels and the starting height of the current partition boundary is 0 pixels, the block height of the target data block is 245 pixels. To determine the required memory space, the total width, block height, and number of bytes per pixel are multiplied to calculate the block memory space value. For example, if the total width is 2400 pixels, the block height is 245 pixels, and the number of bytes per pixel is 1 byte, the block memory space value is 588KB. This precise memory calculation method ensures that the temporary bitmap can completely store all the pixel data of the target data block.

[0074] Based on the calculated block memory space value, allocate contiguous storage space in memory and create a temporary bitmap in 8-bit grayscale format. Read the second image element from the candidate element set of the target data block and obtain the type information of the second image element, such as text, graphics, or barcode. At the same time, obtain the original position coordinates (e.g., x=100, y=180) and second content data (e.g., font, size, style, etc.) of the second image element in the data to be printed.

[0075] Based on the type of the second image element and the second content data, the second pixel area to be rendered is determined on a temporary bitmap. For text elements, the pixel range occupied by the text is calculated based on the font information; for graphic elements, the rendering area is determined based on the size of the graphic. A corresponding grayscale value is generated for each pixel within the second pixel area to achieve a smooth display effect.

[0076] To ensure the correct position of image elements in the temporary bitmap, the ordinate (180) of the original position coordinates is subtracted from the current partitioning start height (0) to obtain the drawing ordinate (180) in the temporary bitmap. The abscissa (100) of the original position coordinates is kept unchanged to ensure the accuracy of the horizontal position. Based on the calculated drawing coordinates, the grayscale values ​​of each pixel in the second pixel area are written to the corresponding byte storage unit of the temporary bitmap through the direct memory access operation "_8bitmap[y*Width+x]=grayscale value".

[0077] The same rendering process is performed on each image element in the target data block until all elements are drawn. Through this element-based, stepwise rendering strategy, the complete image content of the corresponding region of the target data block is reconstructed in the temporary bitmap. After rendering, the fully filled temporary bitmap is output as the temporary rendered image for subsequent binary transformation processing. This precise coordinate mapping and direct memory access rendering scheme not only ensures the integrity and continuity of the segmented image but also improves processing efficiency through optimized memory operations. This allows a large 2400×2400 pixel image to be stably output through multiple data blocks, with the processing time for each data block controlled within 240ms.

[0078] S109: Perform binary transformation on the temporarily rendered image to generate binary data corresponding to the target data block. Send the binary data as part of the print data to the print head in sequence until all data blocks have been processed and sent.

[0079] In step S109 above, the temporarily rendered image undergoes binary conversion, converting the 8-bit grayscale format to the binary format required by the print head of the printing device. During the conversion process, the current printing mode of the printing device is determined, and different conversion modes are selected according to the printing mode. The forward sequence mode and the flip mode are introduced in turn.

[0080] First, we introduce the forward-order mode, which performs binary transformation on the temporarily rendered image to generate binary data corresponding to the target data block. Specifically, this includes: when the printing device is in forward-order mode, obtaining the third grayscale value of the second pixel from the temporarily rendered image, where the second pixel is any pixel in the temporarily rendered image; when the third grayscale value is greater than or equal to a preset third threshold, marking the position corresponding to the second pixel as the first state with ink in the binary data corresponding to the target data block; when the third grayscale value is less than the preset third threshold, marking the position corresponding to the second pixel as the second state without ink in the binary data corresponding to the target data block; until all pixels in the temporarily rendered image are processed, the complete binary data corresponding to the target data block is obtained.

[0081] Specifically, in ascending order mode, the temporarily rendered image undergoes binary conversion, transforming the 8-bit grayscale image data into a binary format suitable for printhead output. Each second pixel in the temporarily rendered image is traversed using direct memory access, and the third grayscale value of the pixel is read using the "_8bitmap[y*Width+x]" operation. This direct access method avoids complex bitwise operations and improves data reading efficiency.

[0082] The acquired third grayscale value is compared with a preset third threshold, which is typically set to 128 and can be adjusted according to actual printing needs. When the third grayscale value is greater than or equal to the preset third threshold, it indicates that the second pixel needs to be printed with an ink dot. The operation "_1bitmap[y*Width+x]=1" marks this position as the first state with an ink dot in the binary data corresponding to the target data block. For example, for the second pixel at coordinates (100, 50), if the third grayscale value of the second pixel is 200, the value 1 will be written to the corresponding position in the binary data.

[0083] When the third grayscale value is less than the preset third threshold, it indicates that the second pixel does not need to be printed. The operation "_1bitmap[y*Width+x]=0" marks this position as the second state without ink dots in the binary data corresponding to the target data block. The same binary judgment and state marking process is performed on all pixels in the temporarily rendered image, with each pixel occupying 1 byte of storage space independently, ensuring the accuracy of data processing. This binary conversion process continues until all pixels in the temporarily rendered image have been processed. Through the above grayscale threshold-based binary conversion strategy, complete binary data corresponding to the target data block is generated. This efficient block-based binary conversion scheme not only ensures print quality but also improves data processing speed through optimized memory operations, enabling stable processing of large-size print data.

[0084] Next, let's introduce the flip mode. When the printing device is in flip mode, the block height of the temporarily rendered image is obtained, and a temporary binary data bitmap is created based on the total width and block height. The initial values ​​of all positions in the temporary binary data bitmap are set to the second state. The second position is obtained from the temporary binary data bitmap, and a 180-degree coordinate flip mapping is performed on the second position based on the total width and block height to obtain the second source pixel. The second source pixel is the pixel corresponding to the second position in the temporarily rendered image. The fourth grayscale value corresponding to the second source pixel is obtained. When the fourth grayscale value is greater than or equal to the preset fourth threshold, the state of the second position in the temporary binary data bitmap is updated from the second state to the first state. After processing all positions in the temporary binary data bitmap, the complete temporary binary data bitmap is output as the binary data corresponding to the target data block.

[0085] Specifically, in flip mode, the block height of 245 pixels is obtained by reading parameters from the temporarily rendered image. Based on the total width of 2400 pixels and the block height of 245 pixels, the required memory space is calculated, and a temporary binary data bitmap is created in memory. The `memset` function is used to set the initial value of all byte storage units in the temporary binary data bitmap to 0, i.e., the second state without ink dots, laying the foundation for subsequent selective updates.

[0086] Each second position in the temporary binary bitmap is traversed, and its corresponding second source pixel position in the temporarily rendered image is determined through coordinate mapping. The 180-degree coordinate flip mapping is calculated as follows: the x-coordinate of the second source pixel equals the total width minus 1 minus the x-coordinate of the second position, and the y-coordinate equals the block height minus 1 minus the y-coordinate of the second position. For example, when the second position coordinates are (100, 50), its corresponding second source pixel coordinates are (2299, 194). This mapping method enables simultaneous horizontal and vertical flipping of the image within the data block.

[0087] The fourth grayscale value of the second source pixel is read using the "_8bitmap[Map_yWidth+Map_x]" operation, where Map_x and Map_y are the coordinate values ​​after a 180-degree coordinate flip. The obtained fourth grayscale value is compared with a preset fourth threshold (usually 128). When the fourth grayscale value is greater than or equal to the preset fourth threshold, it indicates that the second source pixel position needs to be printed. The state of the second position in the temporary binary data bitmap is updated from the second state to the first state using the "_1bitmap[yWidth+x]=1" operation. This selective update strategy avoids repeated processing of positions that do not need to be printed. This flip mapping and state update process continues until all positions in the temporary binary data bitmap have been processed. The complete temporary binary data bitmap is the binary data corresponding to the target data block, where the data has been flipped 180 degrees to adapt to the requirements of printheads with special installation angles.

[0088] Based on the printing mode of the printing device, the corresponding conversion mode is selected to perform binary conversion on the temporarily rendered image. After the binary conversion is completed, the generated binary data is sent to the print head sequentially through the hardware interface. When receiving multiple parts of the printed data, the print head can use a buffer management method to ensure the integrity and continuity of the data. The print head stores each received part of the printed data in a dedicated data buffer, and simultaneously records the position information of the data block in the original image. Based on the aforementioned division rules, the starting height and actual division boundary of each data block are recorded. This information is used for the accurate stitching of subsequent data blocks.

[0089] For a large image of 2400×2400 pixels, the print head receives partial print data corresponding to 11 data blocks. The print head tracks the number of received data blocks using a data counter. When the counter reaches the expected total number of data blocks, it triggers data stitching processing. During stitching, the print head reorganizes the partial print data in the buffer according to the position information recorded for each data block, following the correct spatial order. Through direct memory copy operations, the binarized data of adjacent data blocks are seamlessly connected, ensuring the vertical continuity of the image. This integrity-based printing strategy avoids issues such as discontinuity, overlap, or misalignment that might occur when printing data blocks individually. The stitched print data contains all the information of the complete image. The print head controls the ink ejection state of each nozzle based on the stitched data, achieving continuous printing output of large-size images.

[0090] This application also provides an image rendering and binary conversion control system. Figure 2 This is a schematic diagram of the structure of an image rendering and binary conversion control system provided in an embodiment of this application, with reference to... Figure 2The system is a printing device, which includes a receiving unit 201, a computing unit 202, a rendering unit 203, and a sending unit 204. The receiving unit 201 receives the data to be printed and parses the total width and total height of the image from the data to be printed; The calculation unit 202 determines the number of bytes per unit pixel based on the preset rendering pixel format, calculates the total width, total height and the number of bytes per unit pixel to obtain the total memory space value required to render the entire data to be printed; obtains the available memory threshold from the printing device, and compares the total memory space value with the available memory threshold; Rendering unit 203, when the total memory space value is less than or equal to the available memory threshold, creates a first-bit image in memory based on the total memory space value; draws the data to be printed onto the first-bit image at once to obtain the rendered image; when the total memory space value is greater than the available memory threshold, divides the data to be printed according to preset rules to obtain multiple data blocks; creates a temporary bitmap in memory based on the target data block, draws the target data block onto the temporary bitmap to obtain a temporary rendered image, where the target data block is any one of the multiple data blocks; The transmitting unit 204 performs a binary conversion on the rendered image to obtain a second bitmap, and then converts the second bitmap into a second bitmap. Figure 1 The data is sent to the print head in one go for printing; the temporarily rendered image is binarized to generate binarized data corresponding to the target data block, and the binarized data is sent to the print head as part of the printing data in sequence until all data blocks have been processed and sent.

[0091] In one possible implementation, the receiving unit 201 is used to parse the data to be printed to obtain multiple image elements to be drawn; to obtain the type, position coordinates and first content data of the first image element, wherein the first image element is any one of the multiple image elements; the rendering unit 203 is used to determine the type of the first image element and the first content data in the first pixel area on the first pixel image, and to generate a corresponding grayscale value for each pixel in the first pixel area; to directly write the grayscale value corresponding to each pixel into the byte storage unit corresponding to each pixel in the first pixel image, and after writing all pixels in the first pixel area, the rendered image is obtained.

[0092] In one possible implementation, the receiving unit 201 is used to obtain the first grayscale value of the target pixel from the rendered image when the printing mode of the printing device is in forward mode, wherein the target pixel is any pixel in the rendered image; the sending unit 204 is used to mark the position corresponding to the target pixel in the second bitmap as a first state with ink dots when the first grayscale value is greater than or equal to a preset first threshold; and to mark the position corresponding to the target pixel in the second bitmap as a second state without ink dots when the first grayscale value is less than the preset first threshold; until all pixels in the rendered image are marked, a complete second bitmap is obtained.

[0093] In one possible implementation, the receiving unit 201 is configured to, when the printing mode of the printing device is in flip mode, create an original second bitmap in memory based on the size of the rendered image, and set the initial values ​​of all positions in the original second bitmap to a second state without ink dots; obtain a first position from the original second bitmap, perform a 180-degree coordinate flip mapping on the target position based on the total width and total height to obtain a first source pixel, the first source pixel being the pixel corresponding to the first position in the rendered image; obtain a second grayscale value corresponding to the first source pixel, and when the second grayscale value is greater than or equal to a preset second threshold, update the state of the first position in the original second bitmap from the second state without ink dots to the first state with ink dots; the sending unit 204 is configured to, after completing the processing of all positions in the original second bitmap, output the complete original second bitmap as a second bitmap.

[0094] In one possible implementation, the calculation unit 202 is used to divide the available memory threshold by the product of the total width and the unit pixel byte value to obtain the maximum block height of the temporary bitmap; determine the current partitioning start height of the data to be printed; if the current partitioning start height is less than the total height, the sum of the current partitioning start height and the maximum block height is used as the target partitioning boundary; the area from the current partitioning start height to the target partitioning boundary is determined as the target area; all image elements that overlap with the target area in the vertical direction are searched from the data to be printed, and the image elements are summarized into the candidate element set; the receiving unit 201 is used to find the maximum value of the bottom coordinates of the image elements from the candidate element set, and the maximum value is used as the preliminary actual partitioning boundary; if the preliminary actual partitioning boundary is greater than the current partitioning start height, the final actual partitioning boundary is the preliminary actual partitioning boundary; if the preliminary actual partitioning boundary is less than or equal to the current partitioning start height, the final actual partitioning boundary is the target partitioning boundary; the candidate element set is determined as a data block, and the current partitioning start height is updated to the final actual partitioning boundary, so as to partition the data to be printed into the next data block.

[0095] In one possible implementation, the calculation unit 202 is used to calculate the difference between the final actual partition boundary and the current partition starting height to obtain the block height of the target data block; calculate the total width, block height, and number of bytes per unit pixel to obtain the block memory space value of the target data block; the receiving unit 201 is used to create a temporary bitmap in memory based on the block memory space value and obtain a second image element from the target data block; obtain the type of the second image element and obtain the original position coordinates and second content data of the second image element in the data to be printed; determine the type of the second image element and the second pixel area of ​​the second content data on the temporary bitmap, and generate a corresponding grayscale value for each pixel in the second pixel area; the calculation unit 202 is used to subtract the current partition starting height from the ordinate of the original position coordinates to obtain the drawing ordinate in the temporary bitmap; the rendering unit 203 is used to write the grayscale value corresponding to each pixel into the corresponding byte storage unit in the temporary bitmap based on the drawing ordinate and the abscissa of the original position coordinates; after completing the drawing of all image elements in the target data block, the temporary bitmap is output as a temporary rendered image.

[0096] In one possible implementation, the receiving unit 201 is used to obtain the third grayscale value of the second pixel from the temporarily rendered image when the printing mode of the printing device is in forward mode, wherein the second pixel is any pixel in the temporarily rendered image; the sending unit 204 is used to mark the position corresponding to the second pixel as a first state with ink dots in the binarized data corresponding to the target data block when the third grayscale value is greater than or equal to a preset third threshold; when the third grayscale value is less than the preset third threshold, the position corresponding to the second pixel is marked as a second state without ink dots in the binarized data corresponding to the target data block; until all pixels in the temporarily rendered image are processed, the complete binarized data corresponding to the target data block is obtained; the receiving unit 201 is used to obtain the block of the temporarily rendered image when the printing mode of the printing device is in flip mode. The system calculates the height and creates a temporary binary data bitmap based on the total width and block height, setting the initial values ​​of all positions in the temporary binary data bitmap to a second state with no ink dots. It then obtains the second position from the temporary binary data bitmap, performs a 180-degree coordinate flip mapping on the second position based on the total width and block height, and obtains the second source pixel, which is the pixel corresponding to the second position in the temporarily rendered image. The sending unit 204 obtains the fourth grayscale value corresponding to the second source pixel. When the fourth grayscale value is greater than or equal to a preset fourth threshold, the state of the second position in the temporary binary data bitmap is updated from the second state with no ink dots to the first state with ink dots. After processing all positions in the temporary binary data bitmap, the complete temporary binary data bitmap is output as the binary data corresponding to the target data block.

[0097] It should be noted that the system provided in the above embodiments is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the system and method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.

[0098] This application also discloses an electronic device. (See reference...) Figure 3 , Figure 3 This application provides a schematic diagram of the structure of an electronic device. The electronic device 300 may include: at least one processor 301, at least one network interface 304, a user interface 303, a memory 302, and at least one communication bus 305.

[0099] The communication bus 305 is used to enable communication between these components.

[0100] The user interface 303 may include a display screen and a camera. Optionally, the user interface 303 may also include a standard wired interface and a wireless interface.

[0101] The network interface 304 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface).

[0102] The processor 301 may include one or more processing cores. The processor 301 connects to various parts of the server using various interfaces and lines, and performs various server functions and processes data by running or executing instructions, programs, code sets, or instruction sets stored in memory 302, and by calling data stored in memory 302. Optionally, the processor 301 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 301 may integrate one or a combination of several of the following: Central Processing Unit (CPU), Graphics Processing Unit (GPU), and modem. The CPU primarily handles the operating system, user interface, and application requests; the GPU is responsible for rendering and drawing the content required for display; and the modem handles wireless communication. It is understood that the modem may also not be integrated into the processor 301 and may be implemented as a separate chip.

[0103] The memory 302 may include random access memory (RAM) or read-only memory. Optionally, the memory 302 may include a non-transitory computer-readable storage medium. The memory 302 may be used to store instructions, programs, code, code sets, or instruction sets. The memory 302 may include a program storage area and a data storage area. The program storage area may store instructions for implementing an operating system, instructions for at least one function (such as touch functionality, sound playback functionality, image playback functionality, etc.), instructions for implementing the various method embodiments described above, etc. The data storage area may store data involved in the various method embodiments described above. Optionally, the memory 302 may also be at least one storage device located remotely from the aforementioned processor 301.

[0104] like Figure 3 As shown, the memory 302, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and an application program for image rendering and binary conversion control.

[0105] exist Figure 3In the electronic device 300 shown, the user interface 303 is mainly used to provide an input interface for the user and to obtain the user input data; while the processor 301 can be used to call the application program for image rendering and binary conversion control stored in the memory 302. When executed by one or more processors, the electronic device performs one or more of the methods described in the above embodiments.

[0106] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.

[0107] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.

[0108] In the several embodiments provided in this application, it should be understood that the disclosed apparatus can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some service interfaces; indirect couplings or communication connections between devices or units may be electrical or other forms.

[0109] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0110] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0111] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned memory includes various media capable of storing program code, such as USB flash drives, portable hard drives, magnetic disks, or optical disks.

[0112] The above description is merely an exemplary embodiment of this disclosure and should not be construed as limiting the scope of this disclosure. Any equivalent changes and modifications made in accordance with the teachings of this disclosure shall still fall within the scope of this disclosure. Those skilled in the art will readily conceive of other embodiments of this disclosure upon considering the specification and the disclosure of practical truths. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not described in this disclosure.

Claims

1. An image rendering and binary conversion control method, characterized in that, When applied in a printing device, the method includes: Receive the data to be printed, and parse the total width and total height of the image from the data to be printed; Based on the preset rendering pixel format, the number of bytes per unit pixel is determined, and the total width, the total height, and the number of bytes per unit pixel are calculated to obtain the total memory space value required to render the entire data to be printed. Obtain the available memory threshold from the printing device, and compare the total memory space value with the available memory threshold; When the total memory space value is less than or equal to the available memory threshold, a first-order graph is created in memory based on the total memory space value; The data to be printed is drawn onto the first bitmap in one go to obtain the rendered image; The rendered image is binary converted to obtain a second bitmap, and the second bitmap is sent to the print head for printing at once. When the total memory space value is greater than the available memory threshold, the data to be printed is divided into multiple data blocks based on preset rules; A temporary bitmap is created in the memory based on the target data block, and the target data block is drawn onto the temporary bitmap to obtain a temporarily rendered image. The target data block is any one of the multiple data blocks. The temporarily rendered image is subjected to binary transformation to generate binary data corresponding to the target data block. The binary data is then sent to the print head as part of the printing data in sequence until all the data blocks have been processed and sent.

2. The method according to claim 1, characterized in that, The step of drawing the data to be printed onto the first bitmap in one go to obtain the rendered image specifically includes: The data to be printed is parsed to obtain multiple image elements to be drawn; Obtain the type, position coordinates, and first content data of a first image element, wherein the first image element is any one of the plurality of image elements; Determine the type of the first image element and the first pixel region of the first content data on the first image, and generate a corresponding grayscale value for each pixel in the first pixel region; The grayscale value corresponding to each pixel is directly written into the byte storage unit corresponding to each pixel in the first bitmap. After writing all pixels in the first pixel area, the rendered image is obtained.

3. The method according to claim 2, characterized in that, The step of performing a binary transformation on the rendered image to obtain a second bitmap specifically includes: When the printing mode of the printing device is in forward sequence mode, the first grayscale value of the target pixel is obtained from the rendered image, wherein the target pixel is any pixel in the rendered image; When the first gray value is greater than or equal to a preset first threshold, the position corresponding to the target pixel in the second bitmap is marked as the first state with ink dots. When the first gray value is less than the preset first threshold, the position corresponding to the target pixel in the second bitmap is marked as the second state with no ink dots. The complete second bitmap is obtained only after all pixels in the rendered image have been marked.

4. The method according to claim 2, characterized in that, The step of performing a binary transformation on the rendered image to obtain a second bitmap specifically includes: When the printing mode of the printing device is flip mode, an original second bitmap is created in the memory based on the size of the rendered image, and the initial values ​​of all positions in the original second bitmap are set to the second state without ink dots. The first position is obtained from the original second bitmap, and the target position is flipped and mapped by 180 degrees based on the total width and the total height to obtain the first source pixel. The first source pixel is the pixel corresponding to the first position in the rendered image. Obtain the second gray value corresponding to the first source pixel. When the second gray value is greater than or equal to a preset second threshold, update the state of the first position in the original second bitmap from the second state without ink dots to the first state with ink dots. After processing all positions in the original second bitmap, the complete original second bitmap is output as the second bitmap.

5. The method according to claim 1, characterized in that, The process of dividing the data to be printed into multiple data blocks based on preset rules specifically includes: The maximum block height of the temporary bitmap is obtained by dividing the available memory threshold by the product of the total width and the unit pixel byte value. Determine the current starting height of the partition of the data to be printed. If the current starting height of the partition is less than the total height, then the sum of the current starting height of the partition and the maximum block height is taken as the target partition boundary. The region from the current division starting height to the target division boundary is determined as the target region. All image elements that overlap with the target region in the vertical direction are found in the data to be printed, and the image elements are summarized into the candidate element set. Find the maximum value of the bottom coordinates of the image element from the candidate element set, and use the maximum value as the initial actual division boundary; If the preliminary actual partition boundary is greater than the current partition starting height, then the final actual partition boundary is the preliminary actual partition boundary; If the preliminary actual partition boundary is less than or equal to the current partition starting height, then the final actual partition boundary is the target partition boundary; The candidate element set is determined as a data block, and the current partitioning start height is updated to the final actual partitioning boundary, so as to partition the data to be printed into the next data block.

6. The method according to claim 5, characterized in that, The step of creating a temporary bitmap in memory based on the target data block, and drawing the target data block onto the temporary bitmap to obtain a temporarily rendered image, specifically includes: The difference between the final actual partition boundary and the current partition starting height is calculated to obtain the block height of the target data block; The total width, the block height, and the number of bytes per unit pixel are calculated to obtain the block memory space value for rendering the target data block; Based on the block memory space value, a temporary bitmap is created in the memory, and a second image element is obtained from the target data block; Obtain the type of the second image element, and obtain the original position coordinates and second content data of the second image element in the data to be printed; Determine the type of the second image element and the second pixel region of the second content data on the temporary bitmap, and generate a corresponding grayscale value for each pixel in the second pixel region; Subtract the current division start height from the ordinate of the original position coordinates to obtain the drawing ordinate in the temporary bitmap; Based on the drawn vertical coordinate and the horizontal coordinate of the original position coordinate, the grayscale value corresponding to each pixel is written into the corresponding byte storage unit in the temporary bitmap; After all image elements in the target data block are drawn, the temporary bitmap is output as the temporary rendered image.

7. The method according to claim 1, characterized in that, The step of performing binary transformation on the temporarily rendered image to generate binary data corresponding to the target data block specifically includes: When the printing mode of the printing device is in forward sequence mode, the third grayscale value of the second pixel is obtained from the temporarily rendered image, where the second pixel is any pixel in the temporarily rendered image; When the third gray value is greater than or equal to the preset third threshold, the position corresponding to the second pixel in the binarized data corresponding to the target data block is marked as the first state with ink dots. When the third gray value is less than the preset third threshold, the position corresponding to the second pixel in the binarized data corresponding to the target data block is marked as the second state without ink dots. The process continues until all pixels in the temporarily rendered image have been processed, resulting in complete binarized data corresponding to the target data block. When the printing mode of the printing device is flip mode, the block height of the temporarily rendered image is obtained, and a temporary binary data bitmap is created based on the total width and the block height. The initial values ​​of all positions in the temporary binary data bitmap are set to the second state without ink dots. The second position is obtained from the temporary binary data bitmap, and the second position is flipped and mapped by 180 degrees based on the total width and the block height to obtain the second source pixel. The second source pixel is the pixel corresponding to the second position in the temporary rendered image. Obtain the fourth gray value corresponding to the second source pixel. When the fourth gray value is greater than or equal to a preset fourth threshold, update the state of the second position in the temporary binarized data bitmap from the second state without ink dots to the first state with ink dots. After processing all positions in the temporary binary data bitmap, the complete temporary binary data bitmap is output as the binary data corresponding to the target data block.

8. An image rendering and binary conversion control system, characterized in that, The system is a printing device, which includes a receiving unit, a computing unit, a rendering unit, and a sending unit. The receiving unit receives the data to be printed and parses the total width and total height of the image from the data to be printed. The calculation unit determines the number of bytes per unit pixel based on a preset rendering pixel format, and calculates the total width, the total height, and the number of bytes per unit pixel to obtain the total memory space value required to render the entire data to be printed. Obtain the available memory threshold from the printing device, and compare the total memory space value with the available memory threshold; The rendering unit creates a first-order image in memory based on the total memory space value when the total memory space value is less than or equal to the available memory threshold. The data to be printed is drawn onto the first bitmap in one go to obtain the rendered image; When the total memory space value is greater than the available memory threshold, the data to be printed is divided into multiple data blocks based on preset rules; A temporary bitmap is created in the memory based on the target data block, and the target data block is drawn onto the temporary bitmap to obtain a temporarily rendered image. The target data block is any one of the multiple data blocks. The sending unit performs a binary conversion on the rendered image to obtain a second bitmap, and sends the second bitmap to the print head for printing at once. The temporarily rendered image is subjected to binary transformation to generate binary data corresponding to the target data block. The binary data is then sent to the print head as part of the printing data in sequence until all the data blocks have been processed and sent.

9. An electronic device, characterized in that, The device includes a processor, a memory, a user interface, and a network interface. The memory is used to store instructions, the user interface and the network interface are used to communicate with other devices, and the processor is used to execute the instructions stored in the memory to cause the electronic device to perform the method as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions that, when executed, perform the method as described in any one of claims 1-7.

Citation Information

Patent Citations

  • Image printing method and printer

    CN104423900A

  • Small-capacity cached image binarization method

    CN110569684A

  • Method for quickly converting resource image into print engine data

    CN120602591A

  • PDF drawing vector review method and system based on creative technology

    CN121435303A

  • Method and apparatus for compacting swath data for printers

    EP0855670A2