Disclosure of Invention
The invention aims to provide a printing data processing method for improving the quality of printing vector data of a dot matrix printer.
It is a second object of the present invention to provide a print data processing apparatus for improving the quality of print vector data of a dot matrix printer.
It is a third object of the present invention to provide a computer apparatus for improving the quality of print vector data for a dot matrix printer.
It is a fourth object of the present invention to provide a storage medium for improving the quality of print vector data for a dot-matrix printer.
In order to achieve the first object, the present invention provides a print data processing method comprising: acquiring vector printing data; respectively carrying out dot matrix conversion on vector pictures and vector characters in the vector printing data to obtain dot matrix printing data; and sending the dot matrix printing data to a printer. Respectively carrying out dot matrix conversion on vector pictures and vector characters in the vector printing data, wherein the dot matrix conversion comprises the following steps: acquiring a character outline corresponding to the vector character; zooming the character outline by a preset size to obtain the coordinates of the character outline by taking pixels as units; performing rasterization processing on the character outline according to the coordinates; and generating dot matrix characters corresponding to the vector characters.
According to the scheme, before vector data is printed, the vector data is converted into dot matrix data, so that the data to be printed conforms to the printing parameter setting of the dot matrix printer, and the printing quality of the dot matrix printer for printing the vector data is improved. In addition, the printing data comprises picture data and/or character data, and different conversion modes are adopted for different types of data through respectively converting dot matrixes of vector pictures and vector characters, so that the vector characters and the vector pictures printed by the dot matrix printer are clearer and have better quality. In addition, when the dot matrix conversion of the vector character is carried out, firstly, the character outline corresponding to the character in the vector character is obtained, the character outline of the character is subjected to scaling processing, the coordinate after the scaling processing is obtained, and the character outline corresponding to the character is subjected to rasterization processing after the coordinate information is obtained, so that the dot matrix character corresponding to the vector character is generated. By carrying out scaling processing on the character outline of the character, the coordinate data required by the character during printing can be obtained, and the size of the character is more in line with the printing requirement. In addition, the character outline of the character is subjected to rasterization processing, so that the high-resolution vector data is converted into the low-resolution dot matrix data, and the vector data is more in line with the printing parameters of the dot matrix printer.
In a further scheme, the rasterizing processing is carried out on the character outline according to the coordinates, and the method comprises the following steps: acquiring intersection point coordinates of the character outline and a grid with pixels as units; and carrying out pixel filling on the character outline according to a preset rule to obtain the rasterized character.
Therefore, when the character outline is rasterized, firstly, the coordinates of the intersection points of the character outline and the grids taking the pixel as the unit are determined, so that the distribution condition of the character outline in the grids taking the pixel as the unit is judged, the area of each pixel grid falling into the character outline is determined, the character outline can be subjected to pixel filling by using a preset rule, and the rasterized character is obtained.
In a further aspect, the performing dot matrix conversion on the vector image and the vector character in the vector print data includes: carrying out graying processing on the vector picture to obtain a grayed picture; carrying out binarization processing on the grayed picture to obtain a binarized picture; carrying out Gaussian filtering on the binary image; and converting the filtered binary picture into a dot matrix picture.
Therefore, when the vector picture is subjected to dot matrix conversion, the vector picture is converted into a gray picture, binarization processing is performed on the gray picture, the vector picture can be conveniently converted into the dot matrix picture, the binary picture is smoother in the course of filtering the binary picture, the distortion degree is reduced, and the quality of converting the vector picture into the dot matrix picture can be improved.
In order to achieve the second object, the present invention provides a print data processing apparatus comprising: the data acquisition module is used for acquiring vector printing data; the data conversion module is used for respectively carrying out dot matrix conversion on the vector pictures and the vector characters in the vector printing data to obtain dot matrix printing data; and the data sending module is used for sending the dot matrix printing data to the printer. The data conversion module respectively carries out dot matrix conversion on the vector picture and the vector character in the vector printing data, and the data conversion module comprises the following steps: acquiring a character outline corresponding to the vector character; scaling the character outline by a preset size to obtain the coordinates of the character outline with pixels as a unit; performing rasterization processing on the character outline according to the coordinates; and generating dot matrix characters corresponding to the vector characters.
According to the scheme, the printing data processing device converts the vector data into the dot matrix data before printing the vector data, so that the data to be printed conforms to the printing parameter setting of the dot matrix printer, and the printing quality of the dot matrix printer for printing the vector data is improved. In addition, the printing data comprises picture data and/or character data, and different conversion modes are adopted for different types of data through respectively converting dot matrixes of vector pictures and vector characters, so that the vector characters and the vector pictures printed by the dot matrix printer are clearer and have better quality.
In order to achieve the third object, the present invention provides a computer device comprising a processor for implementing the steps of the above-mentioned print data processing method when executing a computer program stored in a memory.
In order to achieve the fourth object, the present invention provides a storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the above-described print data processing method.
Detailed Description
The printing data processing method is applied to intelligent terminal equipment capable of carrying out data transmission with a dot matrix printer, and preferably, the intelligent terminal equipment comprises intelligent terminal equipment such as a desktop computer, a notebook computer, a tablet computer and a mobile phone. The printing data processing method can convert the vector data into dot matrix data and send the dot matrix data to the dot matrix printer for printing. The printing data processing device is applied to intelligent terminal equipment capable of carrying out data transmission with a dot matrix printer, and is used for realizing the printing data processing method. The present invention also provides a computer device, which includes a processor, and the processor can execute the instructions of the application program, so as to implement the steps of the above-mentioned print data processing method. The storage medium provided by the present invention stores a computer program, and the computer program realizes the steps of the above-described print data processing method when executed by a processor.
Print data processing method embodiment:
as shown in fig. 1, when the print data processing method of the present invention performs the print data processing, step S1 is first executed to acquire vector print data. The vector print data is acquired when the vector print data is processed. The acquired vector print data may be acquired by means of data import or by means of editing. For example, the printing data of characters or pictures to be printed is imported by clicking a virtual key for importing the printing of the printing data on an editing interface of software, so that vector printing data is obtained; or editing characters and pictures on an editing interface of the software to obtain vector printing data after the editing is finished.
After the vector print data is acquired, step S2 is executed to perform dot matrix conversion on the vector image and the vector character in the vector print data, respectively, and dot matrix print data is obtained. In order to enable the vector data to have better printing effect in the dot matrix printer, before printing, the vector printing data needs to be converted into dot matrix data, so that the data to be printed is more in line with the parameter setting of the dot matrix printer. The vector print data includes a vector picture and/or vector characters, so that when dot matrix conversion is performed, dot matrix conversion needs to be performed on the vector picture and the vector characters respectively.
The step of respectively performing dot matrix conversion on the vector picture and the vector character in the vector print data comprises the following steps: carrying out graying processing on the vector picture to obtain a grayed picture; carrying out binarization processing on the grayed picture to obtain a binarized picture; performing Gaussian filtering on the binary image; and converting the filtered binary picture into a dot matrix picture.
When the step of performing graying processing on the vector picture is executed, graying processing is performed by using an algorithm for converting color image RGB pixels into gray, wherein the algorithm for converting color image RGB pixels into gray is common knowledge of those skilled in the art, and is not described herein again. After the grayed picture is obtained, binarization processing is performed on the grayed picture, and during binarization processing, the binarization processing can be performed by using a currently known binarization algorithm, which is not described herein any more.
And after obtaining the binary image, performing Gaussian filtering on the binary image. In this embodiment, a two-dimensional gaussian function known to those skilled in the art is used for gaussian filtering, where the two-dimensional gaussian function is:
where x and y are pixel coordinates and σ is the standard deviation of the gaussian distribution. When Gaussian filtering is carried out, the standard deviation of Gaussian distribution can be set, so that a weight matrix is constructed by using a Gaussian function, the gray values of all pixel points in the binarized picture are calculated by using the weight matrix, and the filtered binarized picture is obtained.
For example, setting σ equal to 1, calculating a weight value of each pixel point through a gaussian function and performing weighted average, and obtaining a weight matrix with a filter radius of 1 as follows:
0.07511361
|
0.12384140
|
0.07511361
|
0.12384140
|
0.20417996
|
0.12384140
|
0.07511361
|
0.12384140
|
0.07511361 |
suppose the gray value of each pixel point is as follows:
11
|
12
|
13
|
35
|
36
|
37
|
18
|
19
|
20 |
multiplying the gray value of each pixel point by the corresponding weight value in the weight matrix to obtain the gray value of Gaussian filtering of the central pixel point:
0.82624969
|
1.486096838
|
0.976476903
|
4.33444911
|
7.350478401
|
4.582131917
|
1.35204494
|
2.35298666
|
1.502272159 |
repeating the steps for all the pixel points to obtain the image after Gaussian filtering.
In addition, the step of performing dot matrix conversion on the vector picture and the vector character in the vector print data respectively further includes: acquiring a character outline corresponding to the vector character; scaling the character outline by a preset size to obtain a coordinate taking a pixel as a unit; performing rasterization processing on the character outline according to the coordinates; and generating dot matrix characters corresponding to the vector characters.
The acquired vector print data includes vector characters, and therefore, when dot matrix conversion of the vector characters is performed, character outlines corresponding to the vector characters are acquired first. The font of each vector font is described by a mathematical curve, which contains key points on the boundary of the font, derivative information of a connecting line and the like, and the character outline corresponding to the vector character can be obtained by obtaining the mathematical vectors.
In this embodiment, a character outline corresponding to a vector character is obtained through a getglyphronoune function. Taking the TrueType vector text as an example, the TrueType file structure has the following common information:
head
|
font header global information of font
|
cmap
|
Mapping character codes to primitive, mapping character codes to primitive indices
|
glyf
|
Primitive data primitive profile definition and grid adjustment instructions
|
maxp
|
Maximum requirement table, summary data of memory allocation required in font
|
loca
|
Position table index converting element index into position of element
|
name
|
Name list of copyright description, font name, font family name, style name, etc
|
hhea
|
Horizontal layout information
|
hmtx
|
Level metric information
|
post
|
PostScript FontInfo directory entry and PostScript name for all primitives
|
OS/2
|
OS/2 and Windows specific Specifications |
When the contour information is obtained, the encoding mode of the vector character (for example, the encoding mode of the national standard GB 18030) needs to be determined, and the encoded value corresponding to the vector character is obtained according to the encoding mode. And finally, acquiring the initial position, the contour information and the like of the character contour through a GetGlyphOutline function according to the index number, so as to acquire the contour information corresponding to the vector character. The method for obtaining the character outline by using the GetGlyphOutline function is well known in the art and will not be described herein.
After the character outline corresponding to the vector character is obtained, the character outline is zoomed according to the preset size, and the coordinate of the character outline with the pixel as the unit is obtained. The preset size may be set according to the resolution of the printer and the size of the characters to be printed. For example, if the printer resolution is 180dpi and the size to be printed is 14.5 lbs., the character outline of the character is scaled to a character outline of 14.5 lbs font, and the scaled character outline is placed in a grid of 180 pixels per inch, thereby obtaining the coordinates of the pixels occupied by the character outline.
And after the coordinates of the character outline in pixel units are obtained, rasterization processing is carried out on the character outline according to the coordinates. The step of rasterizing the character outline according to the coordinates comprises the following steps: acquiring intersection point coordinates of the character outline and a grid with pixels as units; and carrying out pixel filling on the character outline according to a preset rule to obtain the rasterized character. The acquired contour information includes contour point coordinates and information such as a bezier line and a straight line segment for describing the contour. When rasterization processing is performed, a character outline is placed in a grid with pixels as units, and the character outline and the grid have intersection points, so that intersection point coordinates are obtained. And after the intersection point coordinates are obtained, pixel filling is carried out on the character outline according to a preset rule, and then the rasterized character can be obtained. In this embodiment, referring to fig. 2, the character outline of the character "edge" is placed in a grid using pixels as a unit, and when the area of a certain pixel point falling in the character outline is larger than half of the area of the pixel point, the pixel point is filled with black.
And performing rasterization processing on the character outline to obtain rasterized characters, and then generating dot matrix characters corresponding to the vector characters. When the rasterized character outline is subjected to dot matrix conversion, the raster with the character outline placed and taking pixels as units is scanned, when the scanned pixel points are filling pixel points, the scanned pixel points are expressed as '1', and when the scanned pixel points are not filling pixel points, the scanned pixel points are expressed as '0', so that dot matrix data of the character are obtained.
After the dot matrix print data is obtained, step S3 is executed to send a status confirmation command to the printer to confirm that the printer is in a normal operating state. In an optional scheme, before the status confirmation instruction is sent to the printer, whether the connection with the port of the dot matrix printer is successful is judged. Whether the dot matrix printer is successfully connected or not can be judged by sending a detection signal to the printer end and judging whether a response signal is received or not. And when the connection is successful, sending a status inquiry command to the printer, acquiring the current running status of the printer, and confirming that the printer works normally. The printer status query is well known to those skilled in the art and will not be described herein.
After confirming that the printer is operating normally, step S4 is executed to send dot-matrix print data to the printer. The dot matrix printer can print the printing data after receiving the printing data.
It should be noted that step S3 may be executed before step S1, and the dot matrix conversion process is performed on the vector print data after it is confirmed that the printer can operate normally. For example, after the editing interface clicks a printed virtual key, a state confirmation instruction is sent to the dot matrix printer, after the printer is confirmed to be in a normal working state, dot matrix conversion is carried out on the obtained vector printing data, and the dot matrix printing data is sent to the printer for printing after being converted.
Print data processing apparatus embodiment:
as shown in fig. 3, the print data processing apparatus of the present invention includes a data acquisition module 1, a data conversion module 2, a status confirmation module 3, and a data transmission module 4.
The data acquisition module 1 is used to acquire vector print data. The vector print data is acquired when the vector print data is processed. The data acquisition module 1 may acquire the vector print data by data import or by editing. For example, the printing data of characters or pictures to be printed is imported by clicking a virtual key for importing the printing of the printing data on an editing interface of software, so that vector printing data is obtained; or editing characters and pictures on an editing interface of the software to obtain vector printing data after the editing is finished.
The data conversion module 2 is configured to perform dot matrix conversion on the vector image and the vector character in the vector print data, respectively, to obtain dot matrix print data. In order to enable the vector data to have a better printing effect in the dot matrix printer, before printing, the data conversion module 2 needs to convert the vector printing data into dot matrix data, so that the data to be printed is more in line with the parameter setting of the dot matrix printer. Vector print data includes a vector picture and/or vector characters, so that when dot matrix conversion is performed, dot matrix conversion needs to be performed on the vector picture and the vector characters respectively.
The data conversion module 2 respectively performs dot matrix conversion on the vector image and the vector character in the vector printing data, and the steps include: carrying out graying processing on the vector picture to obtain a grayed picture; carrying out binarization processing on the grayed picture to obtain a binarized picture; performing Gaussian filtering on the binary image; and converting the filtered binary picture into a dot matrix picture.
When the data conversion module 2 executes the step of performing the graying processing on the vector picture, the graying processing is performed by using the color image RGB pixel to grayscale algorithm, wherein the color image RGB pixel to grayscale algorithm is common knowledge of those skilled in the art and is not described herein again. After the grayed picture is obtained, the data conversion module 2 performs binarization processing on the grayed picture, and during the binarization processing, the binarization processing can be performed by using a known binarization algorithm, which is not described herein again.
After the binarized picture is obtained, the
data conversion module 2 performs gaussian filtering on the binarized picture. In this embodiment, a two-dimensional gaussian function known to those skilled in the art is used for gaussian filtering, where the two-dimensional gaussian function is:
where x and y are pixel coordinates and σ is the standard deviation of the gaussian distribution. When Gaussian filtering is carried out, the standard deviation of Gaussian distribution can be set, so that a weight matrix is constructed by using a Gaussian function, the gray values of all pixel points in the binarized picture are calculated by using the weight matrix, and the filtered binarized picture is obtained.
In addition, the step of the data conversion module 2 performing dot matrix conversion on the vector image and the vector character in the vector print data respectively further includes: acquiring a character outline corresponding to the vector character; scaling the character outline by a preset size to obtain a coordinate taking a pixel as a unit; performing rasterization processing on the character outline according to the coordinates; and generating dot matrix characters corresponding to the vector characters.
The acquired vector print data includes vector characters, and therefore, when performing dot matrix conversion of the vector characters, the data conversion module 2 first acquires character outlines corresponding to the vector characters. The font of each vector font is described by a mathematical curve, which contains key points on the boundary of the font, derivative information of a connecting line and the like, and the character outline corresponding to the vector character can be obtained by obtaining the mathematical vectors. In this embodiment, obtaining a character outline corresponding to a vector character through a getglyxoline function, and obtaining a character outline by using a getglyxoline function is a technique well known to those skilled in the art and will not be described herein again.
After the data conversion module 2 obtains the character outline corresponding to the vector character, the character outline is zoomed according to the preset size, and the coordinate of the character outline with the pixel as the unit is obtained. The preset size may be set according to the resolution of the printer and the size of the characters to be printed. For example, if the printer resolution is 180dpi and the size to be printed is 14.5 lbs., the character outline of the character is scaled to a character outline of 14.5 lbs font, and the scaled character outline is placed in a grid of 180 pixels per inch, thereby obtaining the coordinates of the pixel points occupied by the character outline.
The data conversion module 2 obtains the coordinates of the character outline in pixel units, and then performs rasterization processing on the character outline according to the coordinates. The step of rasterizing the character outline by the data conversion module 2 according to the coordinates comprises: acquiring intersection point coordinates of the character outline and a grid with pixels as units; and carrying out pixel filling on the character outline according to a preset rule to obtain the rasterized character. The acquired contour information includes contour point coordinates and information such as a bezier line and a straight line segment for describing the contour. When the data conversion module 2 performs rasterization processing, the character outline is placed in a grid with pixels as units, and the character outline and the grid have intersection points to acquire intersection point coordinates. After the intersection point coordinates are obtained, pixel filling is carried out on the character outline according to a preset rule, and the data conversion module 2 can obtain the rasterized character outline. In this embodiment, referring to fig. 2, the character outline of the character "edge" is placed in a grid using pixels as a unit, and when the area of a certain pixel point falling in the character outline is larger than half of the area of the pixel point, the pixel point is filled with black.
And the data conversion module 2 generates lattice characters corresponding to the vector characters after rasterizing the character outlines. When the rasterized character outline is subjected to dot matrix conversion, the raster with the character outline placed and taking pixels as units is scanned, when the scanned pixel points are filling pixel points, the scanned pixel points are expressed as '1', and when the scanned pixel points are not filling pixel points, the scanned pixel points are expressed as '0', so that dot matrix data of the character are obtained.
The status confirmation module 3 is used for sending a status confirmation instruction to the printer to confirm that the printer is in a normal working state. In an optional scheme, before the status confirmation module 3 sends the status confirmation instruction to the printer, it is determined whether the connection with the port of the dot matrix printer is successful. The status confirmation module 3 can determine whether the connection with the dot matrix printer is successful by sending a detection signal to the printer end and by receiving a response signal. When the connection is successful, the status confirmation module 3 sends a status inquiry command to the printer, acquires the current running status of the printer, and confirms that the printer works normally. The printer status query is well known to those skilled in the art and will not be described herein.
The data sending module 4 is used for sending the dot matrix printing data to the printer. The dot matrix printer can print the printing data after receiving the printing data.
The embodiment of the computer device comprises:
the computer device of the embodiment comprises: a processor, a memory, and a computer program, such as a query and interaction program, stored in the memory and executable on the processor. The steps in the above-described print data processing method embodiments are implemented when the processor executes the computer program. Alternatively, the processor realizes the functions of the respective modules in the above-described print data processing apparatus embodiment when executing the computer program.
For example, a computer program can be partitioned into one or more modules, which are stored in a memory and executed by a processor to implement the present invention. One or more of the modules may be a sequence of computer program instruction segments for describing the execution of a computer program in a computer device that is capable of performing certain functions.
For example, the computer device may be a computing device such as a mobile phone, a desktop computer, a notebook computer, and a palm computer. The computer device may include, but is not limited to, a processor, a memory. Those skilled in the art will appreciate that the computer apparatus may include more or fewer components, or combine certain components, or different components, e.g., the computer apparatus may also include input-output devices, network access devices, buses, etc.
For example, the Processor may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, and so on. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The processor is the control center of the computer device and is connected to various parts of the whole computer device by various interfaces and lines.
The memory may be used to store computer programs and/or modules, and the processor may implement various functions of the computer device by executing or executing the computer programs and/or modules stored in the memory, as well as by invoking data stored in the memory. For example, the memory may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function (e.g., a sound receiving function, a sound-to-text function, etc.), and the like; the storage data area may store data (e.g., audio data, text data, etc.) created according to the use of the cellular phone, etc. In addition, the memory may include high speed random access memory, and may also include non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), at least one magnetic disk storage device, a Flash memory device, or other volatile solid state storage device.
Storage medium embodiments:
the modules integrated by the computer device of the above embodiments, if implemented in the form of software functional units and sold or used as independent products, can be stored in a computer readable storage medium. Based on such understanding, all or part of the flow in the above-mentioned embodiment of the print data processing method may also be implemented by a computer program instructing related hardware to complete, where the computer program may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps in the above-mentioned embodiment of the print data processing method may be implemented. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The storage medium may include: any entity or device capable of carrying computer program code, recording medium, U.S. disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution media, and the like. It should be noted that the computer readable medium may contain other components which may be suitably increased or decreased as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, in accordance with legislation and patent practice, the computer readable medium does not include electrical carrier signals and telecommunications signals.
Therefore, before vector data is printed, the vector data is converted into dot matrix data, and the data to be printed conforms to the printing parameter setting of the dot matrix printer, so that the printing quality of the dot matrix printer for printing the vector data is improved. In addition, the printing data comprises picture data and/or character data, and different conversion modes are adopted for different types of data through respectively converting dot matrixes of vector pictures and vector characters, so that the vector characters and the vector pictures printed by the dot matrix printer are clearer and have better quality. In addition, when the dot matrix conversion of the vector character is carried out, firstly, the character outline corresponding to the character in the vector character is obtained, the character outline of the character is subjected to scaling processing, the coordinate after the scaling processing is obtained, and the character outline corresponding to the character is subjected to rasterization processing after the coordinate information is obtained, so that the dot matrix character corresponding to the vector character is generated. By carrying out scaling processing on the character outline of the character, the coordinate data required by the character during printing can be obtained, and the size of the character is more in line with the printing requirement. In addition, the character outline of the character is subjected to rasterization processing, so that the high-resolution vector data is converted into the low-resolution dot matrix data, and the vector data is more in line with the printing parameters of the dot matrix printer.
It should be noted that the above is only a preferred embodiment of the present invention, but the design concept of the present invention is not limited thereto, and any insubstantial modifications made by using the design concept also fall within the protection scope of the present invention.