CN108197088B - Method for converting data into image and electronic equipment - Google Patents

Method for converting data into image and electronic equipment Download PDF

Info

Publication number
CN108197088B
CN108197088B CN201810057509.8A CN201810057509A CN108197088B CN 108197088 B CN108197088 B CN 108197088B CN 201810057509 A CN201810057509 A CN 201810057509A CN 108197088 B CN108197088 B CN 108197088B
Authority
CN
China
Prior art keywords
index value
current
data
error correction
array
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810057509.8A
Other languages
Chinese (zh)
Other versions
CN108197088A (en
Inventor
陆舟
于华章
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Feitian Technologies Co Ltd
Original Assignee
Feitian Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Feitian Technologies Co Ltd filed Critical Feitian Technologies Co Ltd
Priority to CN201810057509.8A priority Critical patent/CN108197088B/en
Publication of CN108197088A publication Critical patent/CN108197088A/en
Application granted granted Critical
Publication of CN108197088B publication Critical patent/CN108197088B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/12Use of codes for handling textual entities
    • G06F40/126Character encoding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T9/00Image coding

Abstract

The invention discloses a method for converting data into an image and electronic equipment, and belongs to the technical field of information security. The electronic equipment disclosed by the invention comprises a main control module, a driving module and a display module; the main control module comprises a first obtaining submodule, a coding submodule, an error correction code block generating submodule, a coding construction submodule, a two-dimensional array filling submodule and a drive calling submodule. The scheme disclosed by the invention converts the data into an image form, so that the information carried by the data can be effectively prevented from leaking; data are input into the terminal equipment without manual operation, and operation convenience is improved.

Description

Method for converting data into image and electronic equipment
Technical Field
The present invention relates to the field of information technologies, and in particular, to a method for converting data into an image and an electronic device.
Background
In the prior art, there are many situations that electronic equipment is required to generate data and then manually input the data into terminal equipment, so that the operation is inconvenient and information carried by the data is easily leaked. For example, when identity authentication is required in electronic transaction or system login, a dynamic authentication code generated by electronic equipment for identity authentication is mostly displayed through data, and then the dynamic authentication code is manually input into terminal equipment for electronic transaction or system login requiring authentication.
The prior art has the following defects: when the data displayed by the electronic equipment is confidential information, the data is easy to leak, and particularly, the dynamic authentication code is easy to leak when the identity authentication equipment displays the dynamic authentication code in a data form, so that electronic transactions or system login is unsafe; data generated by the electronic equipment needs to be manually input into the terminal equipment, so that the operation is inconvenient.
Disclosure of Invention
The present invention provides a method for converting data into an image and an electronic device to solve the above technical problems.
The invention provides a method for converting data into an image, which is suitable for electronic equipment comprising a main control module, a driving module and a display module, and comprises the following steps:
step S1: the method comprises the steps that a main control module obtains data to be converted, data coding is carried out on the data to be converted according to a version, a preset error correction level and a coding mode to obtain coded data, the coded data are divided into coded data blocks with a preset number according to the preset error correction level and the version, each coded data block comprises data code words with a preset data code word number, and the preset error correction code word number of an error correction code block corresponding to each coded data block is obtained;
step S2: the main control module generates corresponding error correction code blocks comprising error correction code words with preset error correction code word number according to the data code words in each coded data block, and constructs the final coded sequence according to the coded data blocks with the preset number and the error correction code blocks corresponding to each coded data block;
step S3: the main control module fills the two-dimensional coding array by using the final coding sequence according to a preset rule to obtain a filled two-dimensional coding array;
step S4: the main control module calls the driving module to send the data in the filled two-dimensional coding array to the display module;
step S5: and the display module generates and displays an image according to the received data in the filled two-dimensional coding array.
The invention provides electronic equipment for converting data into images, which comprises a main control module, a driving module and a display module, wherein the main control module is used for controlling the driving module to drive the display module to display images;
the master control module comprises:
the first acquisition submodule is used for acquiring data to be converted;
the encoding submodule is used for carrying out data encoding on the data to be converted acquired by the first acquisition submodule according to the version, the preset error correction level and the encoding mode to obtain encoded data, dividing the encoded data into encoded data blocks with the preset number according to the preset error correction level and the version, wherein each encoded data block comprises data code words with the preset number of the data code words, and acquiring the preset number of the error correction code words of the error correction code block corresponding to each encoded data block;
the error correction code block generation submodule is used for generating a corresponding error correction code block of an error correction code word comprising a preset number of error correction code words according to the data code word in each coded data block obtained by the coding submodule;
the coding construction submodule is used for constructing the final coding sequence according to the coding data blocks with preset number obtained by the coding submodule and the error correction code blocks corresponding to each coding data block generated by the error correction code block generation submodule;
the two-dimensional array filling submodule is used for filling the two-dimensional coding array by using the final coding sequence constructed by the coding construction submodule according to a preset rule to obtain a filled two-dimensional coding array;
the drive calling submodule is used for calling the drive module to send the data in the filled two-dimensional coding array obtained by the two-dimensional array filling submodule to the display module;
and the display module is used for generating and displaying an image according to the received data in the filled two-dimensional coding array of the main control module.
The invention has the beneficial effects that: the electronic equipment converts the data into an image form, so that the information carried by the data can be effectively prevented from leaking; data are input into the terminal equipment without manual operation, and operation convenience is improved.
Drawings
Fig. 1 is a flowchart illustrating a method for converting data into an image according to embodiment 1 of the present invention;
FIG. 2 is a flowchart of a method for converting data into an image according to embodiment 2 of the present invention;
fig. 3 is a flowchart of a method for generating error correction code words by using a table lookup method according to embodiment 2 of the present invention;
fig. 4 is a block diagram showing the module components of an electronic device for converting data into an image according to embodiment 3 of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention will be described in detail with reference to the accompanying drawings.
Example 1
The embodiment provides a method for converting data into an image, which is applicable to an electronic device including a main control module, a display module and a driving module, and as shown in fig. 1, the method specifically includes:
step S1: the method comprises the steps that a main control module obtains data to be converted, data coding is carried out on the data to be converted according to a version, a preset error correction level and a coding mode to obtain coded data, the coded data are divided into coded data blocks with a preset number according to the preset error correction level and the version, each coded data block comprises data code words with the preset number of the data code words, and the preset number of the error correction code words of an error correction code block corresponding to each coded data block is obtained;
step S2: the main control module generates corresponding error correction code blocks comprising error correction code words with preset error correction code word number according to the data code words in each coded data block, and constructs a final coded sequence according to the coded data blocks with the preset number and the error correction code blocks corresponding to each coded data block;
step S3: the main control module fills the two-dimensional coding array by using the final coding sequence according to a preset rule to obtain a filled two-dimensional coding array;
specifically, step S3 specifically includes: and the main control module calls a bitwise operation instruction to fill each bit of the binary number of the data code word in the final coding sequence into the two-dimensional coding array according to a preset sequence to obtain a filled two-dimensional coding array.
In this embodiment, the main control module calls the bitwise operation instruction to fill each bit of the binary number of the data code word in the final coding sequence into the two-dimensional coding array according to the preset sequence to obtain the filled two-dimensional coding array, so that the space can be effectively saved, and the operation speed can be increased.
Step S4: the main control module calls a driving module to send the data in the filled two-dimensional coding array to a display module;
step S5: and the display module generates and displays an image according to the received data in the filled two-dimensional coding array.
Optionally, before the step S4, the method further includes: the main control module maps the data in the filled two-dimensional coding array into a two-dimensional display array;
accordingly, the step S4 is specifically: the main control module calls the driving module to send data in the two-dimensional display array to the display module;
the step S5 is specifically: and the display module generates and displays an image according to the received data in the two-dimensional display array.
Accordingly, the step S3 is specifically: and the main control module calls a byte-based operation instruction to convert each bit of the binary number of the data code word in the final coding sequence into a byte of data and fills the byte of data into the two-dimensional coding array according to a preset sequence to obtain the filled two-dimensional coding array.
Optionally, after the main control module obtains the data to be converted, the method further includes: the main control module analyzes data of the data to be converted, selects a coding mode according to a data analysis result, and selects a version according to the data length of the data to be converted, a preset error correction level and the selected coding mode.
Optionally, the generating, by the main control module, a corresponding error correction code block including an error correction code word with a preset error correction code word number according to the data code word in each encoded data block specifically includes:
step M1: the main control module acquires a coded data block which does not generate a corresponding error correction code block as a current coded data block, copies a data code word in the current coded data block into an error correction array, sets an initial value of a data code word index value, and takes the initial value of the data code word index value as the current data code word index value;
step M2: the main control module judges whether the index value of the current data code word is smaller than the number of the data code words of the current coding data block, if so, the step M3 is executed, otherwise, the step M7 is executed;
step M3: the main control module judges whether the value of the first code word in the error correction array is 0, if yes, the step M4 is executed; otherwise, executing step M5;
step M4: the main control module sequentially shifts the code words behind the first code word in the error correction array to the left by the position of one code word, updates the index value of the current data code word and executes the step M2;
step M5: the main control module finds an index value corresponding to the value of the first code word in the error correction array from a preset data table, calculates and updates the value of the first code word in the error correction array to the value of the code word of the preset error correction word number corresponding to the current encoded data block according to the found index value, and executes step M6;
step M6: the main control module sequentially shifts the code words corresponding to the sum of the preset error correcting code word number corresponding to the current encoding data block to the data code word number of the current encoding data block and the corresponding preset error correcting code word number to the left by the position of one code word in the error correcting array, updates the index value of the current data code word and executes the step M2;
step M7: the main control module takes the code word sequence in the error correction array as an error correction code block of the current coded data block, adds the error correction code block of the current coded data block to the back of the data code word in the current coded data block, and executes step M1 when there are data coded blocks which have not generated corresponding error correction code blocks.
Specifically, the step M4 specifically includes:
step M41: the main control module sets an initial value of a first total code word index value, and takes the initial value of the first total code word index value as a current first total code word index value;
step M42: the main control module judges whether the index value of the current first total code word is smaller than the sum of the number of the data code words of the current coding data block and the corresponding preset error correcting code word number, if so, the step M43 is executed; otherwise, updating the index value of the current data code word, and executing the step M2;
step M43: the main control module assigns the value of a codeword following the codeword corresponding to the current first total codeword index value in the error correction array to the codeword corresponding to the current first total codeword index value, updates the current first total codeword index value, and performs step M42.
Specifically, the step M5 specifically includes:
step M51: the main control module searches a corresponding index value from a preset fifth data table according to the value of the first code word in the error correction array, sets an initial value of the index value of the error correction code word, and takes the initial value of the index value of the error correction code word as the index value of the current error correction code word;
step M52: the main control module judges whether the index value of the current error correction code word is smaller than the preset error correction code word number corresponding to the current encoding data block, if so, the step M53 is executed, otherwise, the step M6 is executed;
step M53: the main control module finds a power exponent corresponding to the index value of the current error correction code word from a preset sixth data table according to the preset error correction code word number corresponding to the current encoding data block, performs addition operation on the found power exponent and the found exponent value to obtain a first result, and performs remainder operation on preset data by using the first result to obtain a second result;
step M54: the main control module searches a corresponding coefficient value from a preset seventh data table by taking the second result as the item number, performs exclusive-or operation by using the searched coefficient value and the value of the next code word of the code word corresponding to the index value of the current error correction code word in the error correction code array to obtain an exclusive-or operation result, updates the value of the code word corresponding to the index value of the current error correction code word in the error correction array by using the exclusive-or operation result, updates the index value of the current error correction code word, and executes step M52.
Specifically, the step M6 specifically includes:
step M61: the main control module uses the preset error correcting code word number corresponding to the current coding data block to set the initial value of the index value of the second total code word, and uses the initial value of the index value of the second total code word as the index value of the current second total code word;
step M62: the main control module judges whether the index value of the current second total code word is smaller than the sum of the number of the data code words of the current coding data block and the corresponding preset error correcting code word number, if so, the step M63 is executed; otherwise, updating the index value of the current data code word, and executing the step M2;
step M63: the main control module assigns the value of a codeword following the codeword corresponding to the current second total codeword index value in the error correction array to the codeword corresponding to the current second total codeword index value, updates the current second total codeword index value, and performs step M62.
Optionally, the step M1 further includes: the main control module defines an error correction array, and the length of the error correction array is not less than the data code number of any one encoded data block and not less than the error correction code number of any one error correction code block.
Specifically, the mapping of the data in the filled two-dimensional code array to the two-dimensional display array by the main control module specifically includes:
step S41: the main control module sets an initial value of the column index value, and takes the initial value of the column index value as a current column index value;
step S42: the main control module judges whether the index value of the current row is smaller than the number of modules in each row corresponding to the version, if so, the step S43 is executed; otherwise, executing step S5;
step S43: the main control module assigns a value to each element of the two-dimensional display array corresponding to the current column index value according to a preset rule by using each element of which the value is 1 in the two-dimensional coding array corresponding to the current column index value, updates the current column index value, and executes step S42.
Specifically, the step S43 specifically includes:
step S431: the main control module sets an initial value of a row index value, and the initial value of the row index value is used as a current row index value;
step S432: the main control module judges whether the index value of the current row is smaller than the number of modules of each row corresponding to the version, if so, the step S433 is executed; otherwise, updating the current column index value, and executing step S42;
step S433: the main control module determines whether the values of the elements in the two-dimensional coding array corresponding to the current row index value and the current column index value are 1, if yes, step S434 is executed; otherwise, updating the index value of the current row, and executing the step S432;
step S434: the main control module uses the current row index value to carry out rounding on 8 to obtain a first rounding result, carries out complementation on the current row index value to 8 to obtain a first complementation result, leftwards shifts the bit of the first complementation result by using the bit with the median value of 1 in binary numbers of elements in a two-dimensional coding array corresponding to the current row index value and the current column index value, and uses the value of the shifted element as a shifting result;
step S435: the main control module performs an or operation on the values of the elements corresponding to the two-dimensional display array with the current column index value as the ordinate and the first rounding result as the abscissa, and the shift result, assigns the or operation result to the elements corresponding to the two-dimensional display array with the current column index value as the ordinate and the first rounding result as the abscissa, updates the current row index value, and executes step S432.
Or, specifically, the mapping of the data in the filled two-dimensional code array to the two-dimensional display array by the main control module specifically includes:
step S41-1: the main control module sets an initial value of a row index value, and the initial value of the row index value is used as a current row index value;
step S42-1: the main control module judges whether the current row index value is less than the number of modules in each row corresponding to the selected version, if so, the step S43-1 is executed; otherwise, executing step S5;
step S43-1: and the main control module assigns values to each element of the row corresponding to the current row index value in the two-dimensional display array according to a preset rule by using each element of which the value is 1 in the two-dimensional coding array corresponding to the current row index value, updates the current row index value and executes the step S42-1.
Specifically, the step S43-1 specifically includes:
step S431-1: the main control module sets an initial value of the column index value, and takes the initial value of the column index value as a current column index value;
step S432-1: the main control module judges whether the index value of the current row is smaller than the number of modules in each row corresponding to the version, if so, the step S433-1 is executed; otherwise, updating the index value of the current row, and executing the step S42-1;
step S433-1: the main control module judges whether the values of the elements in the two-dimensional coding array corresponding to the current row index value and the current column index value are 1, if yes, the step S434-1 is executed; otherwise, updating the index value of the current column, and executing the step S432-1;
step S434-1: the main control module uses the current column index value to carry out rounding on 8 to obtain a first rounding result, carries out complementation on the current column index value to 8 to obtain a first complementation result, leftwards shifts the bit of the first complementation result by using the bit of which the median value of binary numbers of elements in a two-dimensional coding array corresponding to the current row index value and the current column index value is 1, and uses the value of the shifted element as a shifting result;
step S435-1: the main control module performs an or operation on the values of the elements corresponding to the two-dimensional display array with the current row index value as the abscissa and the first rounding result as the ordinate and the shift result, assigns the or operation result to the elements corresponding to the two-dimensional display array with the current row index value as the abscissa and the first rounding result as the ordinate, updates the current column index value, and executes step S432-1.
Optionally, before the step S41, the method further includes: the main control module judges whether the number of each side module corresponding to the version is less than the number of short edge pixels of the screen in the screen information, if so, the step S41 is executed, otherwise, an error is reported.
Optionally, before the step S41-1, the method further includes: the main control module judges whether the number of each side module corresponding to the version is less than the number of short edge pixels of the screen in the screen information, if so, the step S41 is executed, otherwise, an error is reported.
Optionally, the step S3 is specifically: the main control module calls a bitwise operation instruction to use the final coding sequence to fill a two-dimensional coding array according to a preset rule to obtain a filled two-dimensional coding array;
the step S3 further includes: the main control module calls a bitwise operation instruction to mask the filled two-dimensional code array according to a preset mask pattern reference to obtain a two-dimensional code array of a mask;
accordingly, in step S4, specifically, the method includes: the main control module calls the driving module to send the two-dimensional coding array of the mask to the display module;
in the step S5, the specific steps are: the display module generates and displays an image from the data in the received two-dimensional code array of the mask.
Optionally, in the step S3, the main control module calls a bitwise operation instruction to use the final coding sequence to fill the two-dimensional coding array according to a preset rule, so as to obtain a filled two-dimensional coding array;
accordingly, the step S3 further includes: the main control module calls the bitwise operation instruction to perform mask evaluation on data in the filled two-dimensional code array according to a preset mask pattern reference, selects the mask pattern reference according to a mask evaluation result, and calls the bitwise operation instruction according to the selected mask pattern reference to perform mask on elements corresponding to a final coding sequence in the filled two-dimensional code array to obtain a masked two-dimensional code array;
specifically, the main control module calls a bitwise operation instruction to mask an element corresponding to a final coding sequence in the two-dimensional coding array according to the selected mask pattern reference, so as to obtain a masked two-dimensional coding array, specifically: the main control module calls a bitwise operation instruction to invert a value corresponding to a final coding sequence which meets the selected mask pattern reference condition in the two-dimensional coding array (for example, an element with a value of 1 is converted into 0, and an element with a value of 0 is converted into 1), so that the two-dimensional coding array of the mask is obtained.
Accordingly, in step S4, specifically, the method includes: the main control module calls the driving module to send the two-dimensional coding array of the mask to the display module;
in the step S5, the specific steps are: the display module generates and displays an image from the data in the received two-dimensional code array of the mask.
Optionally, the step S3 further includes: and the main control module generates format information according to the selected mask pattern reference and the error correction level, and fills the format information into the two-dimensional coding array of the mask.
Optionally, after the step S2 and before the step S3, the method further includes: and the main control module fills the functional graphic information at the preset position of the two-dimensional coding array.
Specifically, when the main control module calls the bitwise operation instruction in step S3 to fill each bit of the binary number of the data code word in the final code sequence into the two-dimensional code array according to the preset sequence to obtain the filled two-dimensional code array, the main control module calls the bitwise operation instruction to fill the format information into the two-dimensional code array of the mask; calling a bitwise operation instruction to fill functional graphic information in a preset position of the two-dimensional coding array;
when the main control module calls the byte operation instruction in the step S3 to convert each digit of the binary number of the data code word in the final coding sequence into data of one byte and fill the data into the two-dimensional coding array according to the preset sequence, and the filled two-dimensional coding array is obtained, the main control module calls the byte operation instruction to fill the format information into the two-dimensional coding array of the mask; and calling a byte-based operation instruction to fill functional graphic information in a preset position of the two-dimensional coding array.
The embodiment of the present invention can be referred to as example 2.
Example 2
The embodiment provides a method for converting data into an image, which is applicable to an electronic device including a main control module, a display module and a driving module, and as shown in fig. 2, the method specifically includes:
step 101: the main control module obtains data to be converted.
For example, the master control module obtains the dynamic authentication code 0123456789, and uses the dynamic authentication code 0123456789 as the data to be converted.
Step 102: the main control module carries out data analysis on the data to be converted and selects a coding mode according to the data analysis result.
Specifically, the main control module judges the type of each character in the data to be converted, and selects the coding mode according to the judgment result.
Further specifically, the main control module judges the type of each character in the data to be converted, and when the characters in the data to be converted are judged to be digital types, a digital coding mode is selected; when the characters in the data to be converted are judged to comprise a capital letter type and a number type or comprise the capital letter type, selecting an alphanumeric coding mode; when the characters in the data to be converted are judged to comprise a lower case letter type and a number type, or comprise an upper case letter type, a lower case letter type and the like, or comprise a lower case letter type, the 8-bit byte coding mode is selected.
For example, when the data to be converted is 0123456789, judging that the characters in the data to be converted are all digital types, and selecting a digital coding mode; when the data to be converted is 0123456ABC, judging that the characters in the data to be converted comprise capital letter types and number types, and selecting an alphanumeric coding mode; when the data to be converted is 0123456abc, the characters in the data to be converted are judged to comprise a lower case letter type and a number type, and an 8-bit byte coding mode is selected.
The coding mode further includes a japanese kanji coding mode, a chinese kanji structural link coding mode, and the like according to the type of the character in the data to be converted, and this embodiment mainly describes a digital coding mode.
Step 103: the main control module selects a version according to the data length of the data to be converted, the selected coding mode and the preset error correction level, and performs data coding on the data to be converted according to the selected coding mode, the version and the preset error correction level to obtain coded data.
Specifically, the main control module selects a version according to the data length of the data to be converted, the selected coding mode and a preset error correction level, specifically: the main control module finds data capacity information corresponding to the selected coding mode from a preset first data table, selects data capacity matched with the data length of the data to be converted and a preset error correction level from the data capacity information corresponding to the found coding mode, and selects a version according to the selected data capacity:
first data table
Figure GDA0001583712310000131
In this embodiment, the main control module may select different versions according to the data length of the data to be converted and a preset error correction level, where the versions include 1 to 40 versions in total, each version has four error correction levels, and only the version 1 and the version 2 in the first data table and the corresponding error correction level are listed in the table above.
For example, the data length of the data to be converted 0123456789 acquired by the main control module is 10, the preset error correction level is M, the coding mode is selected as the digital coding mode, the data capacity information corresponding to the digital coding mode is found from the preset first data table, the data capacity 34 matched with the data length 10 of the data to be converted and the preset error correction level M is found from the data capacity information corresponding to the found digital coding mode, and the version 1 is selected according to the selected data capacity 34.
If the length of the data to be converted is 50, the preset error correction level is M, the selected coding mode is the digital coding mode, the data capacity information corresponding to the digital coding mode is found from the first data table, whether the data capacity 34 of the error correction level M corresponding to the version 1 in the data capacity information corresponding to the digital coding mode is larger than the length 50 of the data to be converted or not is judged, if not, whether the data capacity 63 of the error correction level M corresponding to the version 2 in the data capacity information corresponding to the digital coding mode is larger than the length 50 of the data to be converted or not is judged, and if so, the version 2 is selected.
Specifically, the main control module performs data coding on data to be converted according to the selected coding mode, version and preset error correction level to obtain coded data, and specifically includes:
step N11: the main control module divides the data to be converted into one group of preset digits according to the selected coding mode to obtain grouped data to be converted;
for example, the data to be converted obtained by the main control module is 0123456789, and when the selected coding mode is the digital coding mode, the main control module divides the data to be converted 0123456789 into a group from high bits to low bits, and obtains the grouped data to be converted: 0123456789;
step N12: the main control module converts each group of data into binary number according to the selected coding mode and a preset rule;
for example, when a digital coding mode is selected, and the grouped data to be converted is 0123456789, the main control module converts each group of data into a 10-bit binary number, and converts the remaining 1 bit or 2 bits of the group into a 4-bit binary number or a 7-bit binary number, respectively:
012 to 0000001100;
convert 345 to 0101011001;
678 is converted to 1010100110;
converting 9 to 1001;
step N13, the main control module splices the binary numbers obtained by conversion to obtain a first sequence;
for example, the main control module splices the binary numbers obtained by conversion to obtain a first sequence 0000001100010101100110101001101001;
step N14: the main control module finds the indication digit of the data length of the data to be converted corresponding to the selected coding mode and version from a preset second data table, and converts the data length of the data to be converted into the binary number of the found indication digit to obtain the binary number of the data length to be converted;
for example, the main control module finds that the selected digital coding mode and the indicated bit number of the data length to be converted corresponding to the version 1 are 10 from the preset second data table, converts the data length 10 of the data to be converted 0123456789 into a 10-bit binary number, and obtains a binary number 0000001010 of the data length of the data to be converted;
second data table
Figure GDA0001583712310000151
Step N15: the main control module finds a mode indicator corresponding to the selected coding mode from a preset third data table, and adds the mode indicator and a binary number of the data length of the data to be converted to the front of the first sequence to obtain a second sequence;
for example, the main control module finds a pattern indicator 0111 corresponding to a digital coding pattern from a preset third data table, adds the pattern indicator 0111 and a binary number 0000001010 of a data length of data to be converted to the front of the first sequence, and obtains a second sequence 011100000010100000001100010101100110101001101001;
third data sheet
Figure GDA0001583712310000152
Figure GDA0001583712310000161
Step N16: the main control module calculates the data length of a second sequence according to the data length of the data to be converted and a preset rule, and takes the second sequence as coded data when the data length of the second sequence reaches a selected coding mode, a preset error correction level and a maximum bit number corresponding to a selected version; when the data length of the second sequence does not reach the selected coding mode, the preset error correction level and the maximum bit number corresponding to the selected version, filling the second sequence with preset data to obtain coded data;
for example, the selected coding mode is a digital coding mode, and the data length formula of the second sequence is: the data length of the second sequence is 4+ the number of bits of indication of the data length of the data to be converted +10 (the data length of the data to be converted DIV 3) + R; wherein:
when the data length MOD 3 of the data to be converted is 0, R is 0;
when the data length MOD 3 of the data to be converted is 1, R is 4;
when the data length MOD 3 of the data to be converted is 2, R is 7;
d IV is a rounding operator, MOD is a remainder operator, and when the data to be converted is 0123456789, 10MOD 3 is 1, R is 4, and the data length of the second sequence is 4+10+10 (10DIV 3) +4 is 4+10+ 3+4 is 48. The data length of the second sequence is 48 bits and does not reach the maximum number of bits 128 corresponding to the selected digital coding mode, the preset error correction level M and the selected version 1.
Specifically, the main control module uses the preset data to fill the second sequence to obtain the encoded data, and specifically includes:
step N161: the main control module uses a preset terminator to fill the second sequence to obtain a filling sequence, and when the bit number of the filling sequence is a multiple of 8 and reaches the maximum bit number corresponding to the selected coding mode, the preset error correction level and the selected version in the preset first data table, the filling sequence is used as coded data; when the number of bits of the padding sequence is not a multiple of 8, padding the padding sequence with first preset data to obtain a padding sequence with a total number of bits being a multiple of 8, and executing step N162;
for example, the main control module calculates the length of the second sequence data to be 48 bits, and the maximum number of bits 128 corresponding to the digital coding mode, the error correction level M and the selected version 1 in the preset first data table is not reached, the preset terminator 0000 is used for filling the second sequence to obtain a filling sequence 0111000000101000000011000101011001101010011010010000, the number of bits of the filling sequence is 52 bits and is not a multiple of 8, and the first filling sequence is subjected to bit filling by using the first preset data 0 to obtain a bit filling sequence 01110000001010000000110001010110011010100110100100000000 with a total number of bits being a multiple of 8 and 56 bits;
step N162: when the bit complementing sequence reaches the coding mode selected in the preset first data table, the preset error correction level and the maximum bit number corresponding to the selected version, taking the bit complementing sequence as coded data; when the bit complementing sequence does not reach the maximum bit number corresponding to the selected coding mode, the preset error correction level and the selected version in the preset first data table, alternately filling a first preset number sequence and a second preset number sequence behind the bit complementing sequence to obtain coded data of the maximum bit number;
for example, the total number of bits of the complementary bit sequence is 56, the maximum number of bits 128 corresponding to the digital coding mode, the preset error correction level M and the version 1 are not reached, and the first preset sequence 11101100 and the second preset sequence 00010001 are alternately filled behind the complementary bit sequence to obtain the coded data 01110000001010000000110001010110011010100110100100000000111011000001000111101100000100011110110000010001111011000001000111101100 with the maximum number of bits of 128 bits.
Step 104: the main control module divides the encoded data into encoded data blocks of a preset number according to a preset error correction level and a selected version, each encoded data block comprises data code words of a preset data code word number, and the preset error correction code word number of the error correction code block corresponding to each encoded data block is obtained.
Specifically, in step 104, the main control module divides the encoded data into a preset number of encoded data blocks according to a preset error correction level and the selected version, where each encoded data block includes a data codeword with a preset number of data codewords, specifically: the main control module divides the coded data into a group of 8-bit data code word sequences, and divides the data code word sequences into a preset number of coded data blocks comprising a preset number of data code words according to the selected version and a preset error correction level.
More specifically, step 104 specifically includes: the main control module finds an error correction block number block corresponding to a preset error correction level and a selected version from a preset fourth data table, divides the data codeword sequence into encoded data blocks of the error correction block number and including a preset data codeword number, and finds a preset error correction codeword number in the error correction codeword block corresponding to each encoded data block from the preset fourth data table.
Fourth data sheet
Figure GDA0001583712310000181
In this embodiment, the preset fourth data table includes a total number of codewords corresponding to versions 1 to 40, an error correction level, error correction codeword data, an error correction block number, and an error correction code of each block, and only data corresponding to version 1 in the preset fourth data table is listed in this embodiment. Wherein, three numbers in the error correction code of each block respectively represent the total number of code words (the sum of the number of error correction code words and the number of data code words) of each block, the number of data code words of each block, and the error correction capacity of each block. Taking version 1, error correction level M as an example, the error correction code (26,16,4) for each block indicates that the number of codewords per block is 26, the number of data codewords per block is 16, and the error correction capacity per block is 4.
Wherein, the recovery capacities corresponding to the 4 error correction levels are as follows:
Figure GDA0001583712310000182
Figure GDA0001583712310000191
in the fourth data table, the error correction capacity is the recovery capacity and the total number of codewords per block, and taking the M error correction levels of version 1 as an example, the error correction capacity is 15% × 26 ≈ 3.9 ≈ 4.
Each error correction codeword can correct 2 read reject errors (the location of the error codeword is known) and 1 replacement error (the location of the error codeword is unknown). A read reject error is a character that is not scanned or decoded, and a substitution error is a character that is decoded in error.
For example, the main control module divides the encoded data 01110000001010000000110001010110011010100110100100000000111011000001000111101100000100011110110000010001111011000001000111101100 into a data codeword sequence 01110000001010000000110001010110011010100110100100000000111011000001000111101100000100011110110000010001111011000001000111101100 of groups of 8 bits each, finds the number of blocks of error correction blocks corresponding to the preset error correction level M and the selected version 1 as 1 from a preset fourth data table, divides the codeword sequence in the data into 1 encoded data blocks including 16 data codewords (i.e., the data codeword sequence is taken as one encoded data block, and this encoded data block includes 16 data codewords), and finds the preset number of error correction codewords of the error correction codeword block corresponding to the encoded data block as 10 from the preset fourth data table.
Step 105: the main control module generates corresponding error correction code blocks comprising preset error correction code word numbers according to the data code words in each coded data block, and constructs a final coded sequence according to the coded data blocks with the preset numbers and the error correction code blocks corresponding to each coded data block.
Specifically, the main control module generates a corresponding error correction code block including a preset number of error correction code words according to the data code word in each encoded data block, specifically: and the main control module calculates each coded data block through an error correction algorithm to obtain a corresponding error correction code block comprising the preset error correction code word number. Further specifically, the main control module calls a function of an error correction algorithm to select an error correction code word generation polynomial according to the preset number of error correction code words to divide the error correction code word generation polynomial by a data code word polynomial in the encoded data block to obtain a remainder polynomial, and coefficients in the remainder polynomial are used as error correction code words in the corresponding error correction code block.
Or, specifically, the main control module generates a corresponding error correction code block including a preset number of error correction code words according to the data code word in each encoded data block, specifically: and the main control module generates a corresponding error correction code block comprising a preset error correction code word number according to the data code word in each coding data block by a table look-up method.
As shown in fig. 3, the main control module generates an error correction code block including a preset number of error correction code words according to the data code words in each encoded data block by using a table lookup method, which specifically includes:
step M100: the main control module defines an error correction array, and the length of the error correction array is not less than the data code number of any one encoded data block and not less than the error correction code number of any one error correction code block.
Step M101: the main control module obtains a coding data block which does not generate a corresponding error correction code block as a current coding data block, copies a data code word in the current coding data block into an error correction code array, sets an initial value of a data code word index value, and takes the initial value of the data code word index value as the current data code word index value.
For example, the initial value of the data codeword index value set by the master control module is 0.
Step M102: the main control module judges whether the index value of the current data code word is smaller than the number of the data code words in the current coding data block, if so, the step M103 is executed; otherwise, executing step M115;
for example, if the number of data codewords in the encoded data block is 16 and the index value of the current data codeword is 0, the main control module determines that the index value of the current data codeword is smaller than the number of data codewords in the encoded data block, and then executes step M103.
Step M103: the main control module judges whether the value of the first byte in the error correcting code array is 0, if so, the step M104 is executed, otherwise, the step M107 is executed;
for example, if the master module determines that the data 01110000 in the first byte of the error correction code array is not 0, step M104 is performed.
Step M104: the main control module sets an initial value of the first total code word index value, and takes the initial value of the first total code word index value as the current first total code word index value.
For example, the initial value of the first total codeword index value set by the main control module is 0.
And step M105, the main control module judges whether the index value of the current first total code word is smaller than the sum of the number of the data code words of the current coding data block and the number of the corresponding preset error correcting code words, if so, the step M106 is executed, and if not, the step M102 is executed.
For example, when the sum of the number of data codewords 16 and the corresponding number of preset error correcting codes 10 in the current data code block is 26, and the current first total codeword index value is 0, the current first total codeword index value 0 is smaller than the sum 26 of the number of data codewords and the corresponding number of preset error correcting codes in the current data code block, and step M106 is performed.
Step M106, the main control module assigns the value of a code word behind the code word corresponding to the current first total code word index value in the error correcting code array to the code word corresponding to the current first total code word index value, updates the current first total code word index value and executes the step M105;
for example, the main control module updates the current first total codeword index value, specifically: the main control module adds 1 to the current first total code word index value.
Step M107: and the main control module searches a corresponding index value from a preset fifth data table according to the value of the first code word in the error correction array.
Specifically, step M107 specifically is: and the main control module takes the value of the first byte in the error correcting code array as the item number and searches the index value of the corresponding item from a preset fifth data table.
Fifth data sheet
Figure GDA0001583712310000211
Figure GDA0001583712310000221
For example, the value of the first byte 01110000 in the error correction code array is 112, and the exponent value found from the eighth row, first column of the preset fifth data table with 112 as the entry number is 202.
And step M108, the main control module sets an initial value of the error correction code word index value and takes the initial value of the error correction code word index value as the current error correction code word index value.
For example, the initial value of the error correction codeword index value set by the master control module is 0.
M109, the main control module judges whether the index value of the current error correction code word is less than the preset number of error correction code words corresponding to the current coding data block, if so, the step M110 is executed, otherwise, the step M112 is executed;
for example, if the current error correction codeword index value is 0 and the preset number of error correction codewords corresponding to the current encoded data block is 10, the current error correction codeword index value 0 is smaller than the preset number of error correction codewords 10, and step M110 is performed.
Step M110: the main control module finds the power exponent corresponding to the current error correcting code index value from a preset sixth data table according to the preset error correcting code word number corresponding to the current encoding data block, adds the found power exponent and the found exponent value to obtain a first result, and performs remainder operation on preset data by using the first result to obtain a second result.
Sixth data sheet
Figure GDA0001583712310000222
Figure GDA0001583712310000231
For example, the main control module presets the error correction codeword number 10 to find the power 251 corresponding to the current error correction codeword index value 0 from the sixth data table, adds the found power 251 to the found index value 202 to obtain a first result 453, and performs a remainder operation on the preset data 255 using the first result 453 to obtain a second result 198.
Step M111: the main control module searches a corresponding coefficient value from a preset seventh data table by taking the second result as the item number, performs exclusive-or operation on the searched coefficient value and the next code word of the code word corresponding to the current error correction code index value in the error correction code array to obtain an exclusive-or operation result, updates the error correction code word corresponding to the current error correction code index value in the error correction code array by using the exclusive-or operation result, updates the current error correction code word index value, and returns to the step M109.
Seventh data sheet
Figure GDA0001583712310000232
Figure GDA0001583712310000241
For example, the main control module uses the second result 198 as an item number to search a preset seventh data table (the thirteenth row and the seventh column of the seventh data table) for a corresponding coefficient value of 7, performs an exclusive-or operation (performs an exclusive-or operation on 00000111 and 00101000) on the searched coefficient value of 7 and a next codeword 00101000 of a codeword corresponding to the current error correction code index value 0 in the error correction code array, so as to obtain an exclusive-or operation result 00101111, and updates the codeword corresponding to the current error correction code index value 0 by using the exclusive-or operation result 00101111.
Specifically, the main control module updates the index value of the current error correction codeword, specifically: the main control module adds 1 to the index value of the current error correction code word.
Step M112: and the main control module sets an initial value of a second total code word index value by using the preset error correcting code word number corresponding to the current encoding data block, and takes the initial value of the second total code word index value as the index value of the current second total code word.
For example, the main control module sets an initial value of the second total codeword index value using a preset error correction codeword number 10 corresponding to the current encoded data block.
Step M113: the main control module determines whether the current second total codeword index value is smaller than the sum of the data codeword number of the current encoded data block and the corresponding preset error correcting codeword number, if so, step M114 is executed, otherwise, step M102 is executed.
For example, when the sum of the number of data codewords 16 and the corresponding number of preset error correcting codewords 10 of the current data code block is 26, and the current first total codeword index value is 10, the current first total codeword index value 10 is smaller than the sum of the number of data codewords and the corresponding number of preset error correcting codewords 26 of the current encoded data block, and step M114 is performed.
Step M114: and the main control module assigns the value of a code word behind the code word corresponding to the current second total code word index value in the error correction array to the code word corresponding to the current second total code word index value and updates the current second total code word index value.
For example, the main control module updates the second total codeword index value, specifically: the main control module adds 1 to the second total codeword index value.
Step M115: the main control module takes the code word sequence in the error correction array as an error correction code block of the current coding data block, and adds the error correction code block of the current coding data block to the back of the data code word in the current coding data block.
For example, the data codeword in the current encoded data block is 01110000001010000000110001010110011010100110100100000000111011000001000111101100000100011110110000010001111011000001000111101100, the error correction codeword in the obtained error correction code block is 00101101101101110010011111111011111101011101001110101010100011111110100100010001, and the error correction codeword is added to the data codeword to obtain a codeword sequence 0111000000101000000011000101011001101010011010010000000011101100000100011110110000010001111011000001000111101100000100011110110000101101101101110010011111111011111101011101001110101010100011111110100100010001.
Step M116: the main control module judges whether a data coding block which does not generate a corresponding error correction code block exists, if so, a final coding sequence is constructed according to a preset number of coding data blocks and the error correction code block corresponding to each coding data block; otherwise, step M101 is performed.
For example, the number of encoded data blocks corresponding to version 1 and error correction level M is 1, and a final encoded sequence 0111000000101000000011000101011001101010011010010000000011101100000100011110110000010001111011000001000111101100000100011110110000101101101101110010011111111011111101011101001110101010100011111110100100010001 is constructed from the encoded data block 01110000001010000000110001010110011010100110100100000000111011000001000111101100000100011110110000010001111011000001000111101100 and the corresponding error correction code block 00101101101101110010011111111011111101011101001110101010100011111110100100010001.
Specifically, in step 105, the main control module constructs a final coding sequence according to the encoded data blocks of the preset number and the error correction code blocks corresponding to each encoded data block, specifically: the main control module generates a data code word column according to the data code word at the corresponding position in each coding data block, generates an error correction code word column according to the error correction code word at the corresponding position in each error correction code block, sequentially splices the data code words in each column to obtain a data code word splicing sequence, sequentially splices the error correction code word columns in each column to obtain an error correction code word splicing sequence, and adds the error correction code word splicing sequence to the back of the data code word splicing sequence to obtain a final coding sequence.
Taking version 1, error correction level M as an example (D1 represents a first data codeword; E1 represents an error correction codeword):
Figure GDA0001583712310000261
the final coding sequence is obtained as: d1, D2, … … D16, E1, E2, … … E10.
Take version 7, error correction level H for example (D1 represents the first data codeword; E1 represents an error correction codeword):
Figure GDA0001583712310000262
the final coding sequence is obtained as: d1, D14, D27, D40, D53, D2, D15, D28,.. to.. D13, D26, D39, D52, D65, D66, E1, E27, E53, E79, E105, E2, E28, E54, E80, E106,. to.. to. E26, E52, E78, E104, E130.
Step 106: and the main control module generates a two-dimensional coding array according to the selected version and fills functional graphic information in a preset position of the two-dimensional coding array.
Optionally, the main control module generates a two-dimensional coding array according to the selected version, specifically: and the main control module generates a two-dimensional coding array with the number of rows and columns consistent with the number of modules on each side of the selected version.
It should be noted that the number of modules on each side of each version is preset.
For example, if the version number of the selected version is version 1, and the number of modules per side of version 1 is 21, a two-dimensional code array of 21 rows and 21 columns is generated:
Figure GDA0001583712310000271
Figure GDA0001583712310000272
Figure GDA0001583712310000281
in step 106 of this embodiment, the main control module may generate the two-dimensional code array according to the selected version by replacing: the main control module fills functional graphic information in a preset position of a preset two-dimensional coding array; the predetermined two-dimensional code array is large enough to accommodate the data capacity corresponding to the selected version.
Specifically, the main control module fills the functional graphic information at the preset position of the two-dimensional coding array, specifically: the main control module calls a byte-based operation instruction to set the value of a preset dark color position in the two-dimensional coding array to be 1, and the value of the preset light color position is set to be 0; or the main control module sets the value of the preset dark color position in the two-dimensional coding array to be 30 and sets the value of the preset light color position to be 20.
Specifically, the functional graphics include a finder graphic, a separator, a positioning image, and a correction graphic. It should be noted that version 1 has no correction pattern, and versions 2 and above version 2 have correction patterns.
Step 107: and the main control module fills the two-dimensional coding array by using the final coding sequence according to a preset rule to obtain the filled two-dimensional coding array.
Specifically, step 107 specifically includes: and the main control module calls a byte-based operation instruction to convert each bit of the binary number of the data code word in the final coding sequence into a byte of data and fills the byte of data into the two-dimensional coding array according to a preset sequence to obtain the filled two-dimensional coding array.
More specifically, step 107 specifically includes: the main control module calls a byte-based operation instruction to convert data with each bit value of 1 of a binary number of a data code word in a final coding sequence into data with one byte of 02, converts data with each bit value of 0 into data with one byte of 00, and fills the converted data into the two-dimensional coding array according to a preset sequence to obtain the filled two-dimensional coding array.
For example, the obtained two-dimensional code array after padding is:
Figure GDA0001583712310000282
Figure GDA0001583712310000283
Figure GDA0001583712310000291
and 108, the main control module carries out mask evaluation on the data in the filled two-dimensional coding array according to a preset mask pattern reference and selects the mask pattern reference according to a mask evaluation result.
Specifically, the main control module performs mask evaluation on the data in the filled two-dimensional coding array according to a preset mask pattern reference, specifically: and calling the byte-based operation instruction by the main control module to mask the data in the filled two-dimensional coding array according to the condition suitable for each preset mask pattern reference to obtain a mask result, and obtaining a mask evaluation result corresponding to the mask pattern reference according to the mask result.
Further specifically, the main control module calls a byte-based operation instruction to mask the data in the filled two-dimensional code array according to the condition applicable to each preset mask pattern reference to obtain a mask result, obtains a mask evaluation result corresponding to the mask pattern reference according to the mask result, and selects the mask pattern reference according to the mask evaluation result, which specifically includes:
step L1: the main control module selects a mask pattern reference which is not subjected to mask evaluation, and calls a byte operation instruction to negate the value of an element corresponding to a final coding sequence which meets the condition applicable to the selected mask pattern reference in the filled two-dimensional coding array to obtain a mask result;
l2, the main control module obtains the mask evaluation result corresponding to the reference of the mask pattern according to the mask result:
step L3: the main control module judges whether a mask pattern reference which is not subjected to mask evaluation exists, if so, the step L1 is executed; otherwise, executing step L4;
step L4: the master control module selects the mask pattern reference with the lowest penalty point score for the mask evaluation results.
The default mask pattern is referenced in the following table:
mask pattern referencing Condition
000 (i+j)mod 2=0
001 i mod 2=0
010 j mod 3=0
011 (i+j)mod 3=0
100 ((i div 2)+(j div 3))mod 2=0
101 (i*j)mod 2+(i*j)mod 3=0
110 ((i*j)mod 2+(i*j)mod 3)mod 2=0
111 ((i*j)mod 3+(i+j)mod 2)mod 2=0
In the above table, div is the operator of rounding, mod is the remainder operator; i represents a row position in the two-dimensional code array, and j represents a column position in the two-dimensional code array, for example, (i, j) ═ 0,0 represents the position of the first element in the two-dimensional code array after padding.
Mask evaluation results refer to the following table:
Figure GDA0001583712310000311
in the above table, N1-N4 is a penalty weight (N1 is 3, N2 is 3, N3 is 40, and N4 is 10), i is the number of times that the number of elements having the same value of the immediately adjacent elements is greater than 5, k is a difference between the ratio of the dark element value in the whole array and 50%, and the step size is 5%; m and n are the side lengths of blocks composed of elements having the same element value (for example, the number of elements of a block composed of elements having the same element value is 20, that is, the side lengths m of the block are 4, n are 5).
For example, the mask evaluation result for each mask pattern reference (i.e., the penalty point score for the corresponding mask pattern reference) is obtained as follows:
mask pattern referencing Penalty point scoring
000 1138
001 1123
010 1214
011 1171
100 1134
101 1140
110 1157
111 1167
Then mask pattern reference 001 has the least penalty score and the mask pattern reference 001 with the lowest penalty score 1123 is selected.
Step 109: and the main control module masks elements corresponding to the final coding sequence in the two-dimensional coding array according to the selected mask pattern reference to obtain the masked two-dimensional coding array.
Specifically, step 109 specifically includes: the main control module calls an operation instruction according to bytes to convert an element with a value of 02 corresponding to a final coding sequence which accords with the selected mask pattern reference condition in the two-dimensional coding array into 00, convert an element with a value of 00 corresponding to a final coding sequence which accords with the selected mask pattern reference condition in the two-dimensional coding array into 01 to obtain an inverted two-dimensional coding array, convert an element with a median value of 30 in the inverted two-dimensional coding array into 01, convert an element with a median value of 02 into 01, and convert an element with a median value of 20 into 00 to obtain a two-dimensional coding array of the mask.
For example, the main control module masks the final coding sequence in the two-dimensional coding array according to the selected mask pattern reference 001, and obtains the two-dimensional coding array of the mask as follows:
Figure GDA0001583712310000321
Figure GDA0001583712310000322
Figure GDA0001583712310000331
step 110: and the main control module generates format information according to the selected mask pattern reference and the error correction level and fills the format information into the two-dimensional coding array of the mask.
Specifically, in step 110, the main control module fills the format information into the two-dimensional coding array of the mask, specifically: and the main control module calls a byte-based operation instruction to fill the format information into the two-dimensional coding array of the mask.
Optionally, after step 110, the method further includes: the main control module judges whether the version number of the selected version is higher than a preset version number, if so, version information is generated according to the selected version, the version information is filled into a two-dimensional coding array of the mask, and the step 111 is executed; otherwise, step 111 is performed.
For example, if the version number of the selected version is 1 and is not higher than the preset version number 7, step 111 is performed.
Step 111: the main control module generates a two-dimensional display array according to preset screen information;
specifically, step 111 specifically includes: the main control module generates a two-dimensional display array with the number of rows and the number of columns respectively consistent with the number of pixels of each row and the number of pixels of each column in the screen information.
For example, 128 pixels per row and 64 pixels per column in the screen information generate a 128-column and 64-row two-dimensional display array.
Optionally, in step 111, the main control module generates a two-dimensional display array according to preset screen information, which may be replaced with: the main control module presets a two-dimensional display array according to the screen information.
Step 112: the main control module judges whether the number of each side module corresponding to the selected version is less than the number of short edge pixels of the screen in the screen information, if so, the step 113 is executed; otherwise, error is reported and the process is finished.
For example, if there are 128 pixels per line and 64 pixels per column in the screen information, the number of short edge pixels is 64, the number of modules per edge corresponding to the selected version 1 is 21, which is smaller than the number of short edge pixels 64 in the screen information, and step 113 is executed.
Step 113: the main control module sets an initial value of the column index value, and takes the initial value of the column index value as a current column index value.
For example, the master module sets the initial value of the column index value to 0.
Step 114: the main control module determines whether the current row index value is less than the number of modules in each row corresponding to the selected version, if yes, step 115 is executed, otherwise step 120 is executed.
Step 115: the main control module sets an initial value of the row index value, and the initial value of the row index value is used as the current row index value.
For example, the master control module sets the initial value of the row index value to 0.
Step 116: the main control module judges whether the index value of the current row is less than the number of modules in each row corresponding to the selected version, if yes, step 117 is executed; otherwise, the current column index value is updated, and step 114 is performed.
For example, the main control module updates the current row index value, specifically: the main control module adds 1 to the current row index value.
Step 117: the main control module judges whether the element value in the two-dimensional coding array of the mask corresponding to the current row index value and the current column index value is 1, if yes, step 118 is executed; otherwise, the current row index value is updated, and step 116 is performed.
For example, updating the current row index value specifically includes: the current column index value is incremented by 1.
Step 118: the main control module uses the current row index value to carry out rounding on the 8 to obtain a first rounding result, carries out complementation on the current row index value to obtain a first complementation result, leftwards shifts the bit with the median value of 1 in the binary numbers of the elements in the two-dimensional coding array of the mask corresponding to the current row index value and the current column index value to the left, and uses the value of the shifted element as the shift result.
Step 119: the main control module performs an or operation on the values of the elements corresponding to the two-dimensional display array with the current column index value as the ordinate and the first rounding result as the abscissa and the shift result, assigns the or operation result to the elements corresponding to the two-dimensional display array with the current column index value as the ordinate and the first rounding result as the abscissa, updates the current row index value, and executes step 116.
Step 120: the main control module calls the driving module to send data in the two-dimensional display array to the display module, and the display module displays images according to the two-dimensional display array.
For example, the data in the two-dimensional display array is:
Figure GDA0001583712310000351
Figure GDA0001583712310000352
or, the data of the two-dimensional display array is:
Figure GDA0001583712310000353
Figure GDA0001583712310000354
Figure GDA0001583712310000361
or, the data in the two-dimensional display array is:
Figure GDA0001583712310000362
Figure GDA0001583712310000363
alternatively, the steps 113 to 119 may be replaced by:
step 113-1: the main control module sets an initial value of the row index value, and the initial value of the row index value is used as the current row index value.
For example, the master control module sets the initial value of the row index value to 0.
Step 114-1: the main control module determines whether the current row index value is less than the number of modules in each row corresponding to the selected version, if so, step 115-1 is executed, otherwise, step 120 is executed.
Step 115-1: the main control module sets an initial value of the column index value, and takes the initial value of the column index value as a current column index value.
For example, the master module sets the initial value of the column index value to 0.
Step 116-1: the main control module judges whether the index value of the current row is smaller than the number of modules in each row corresponding to the selected version, if so, the step 117-1 is executed; otherwise, the current row index value is updated and step 114-1 is performed.
For example, the main control module updates the current column index value, specifically: the main control module adds 1 to the current column index value.
Step 117-1: the main control module judges whether the element value in the two-dimensional coding array of the mask corresponding to the current row index value and the current column index value is 1, if yes, the step 118-1 is executed; otherwise, the column index value is updated and step 116-1 is performed.
For example, the update column index value is specifically: the column index value is incremented by 1.
Step 118-1: the main control module uses the current column index value to carry out rounding on the 8 to obtain a first rounding result, carries out complementation on the 8 to obtain a first complementation result, leftwards shifts the bit of the value 1 in the binary number of the element in the two-dimensional coding array of the mask corresponding to the current row index value and the current column index value by the first complementation result bit, and uses the value of the element after the shift as the shift result.
Step 119-1: the main control module performs an or operation on the current row index value in the two-dimensional display array as the abscissa, the value of the element corresponding to the first rounding result as the ordinate and the shift result, assigns the or operation result to the element corresponding to the two-dimensional display array with the current row index value as the abscissa and the first rounding result as the ordinate, updates the current column index value, and executes step 116-1.
Preferably, the step 107 is specifically: the main control module calls a bitwise operation instruction to fill each bit of the binary number of the data code word in the final coding sequence into the two-dimensional coding array according to a preset sequence to obtain a filled two-dimensional coding array;
for example, the two-dimensional code array after padding is obtained as follows:
Figure GDA0001583712310000371
Figure GDA0001583712310000372
accordingly, the step 106 specifically includes: and the main control module generates a two-dimensional coding array with the selected version and calls a bitwise operation instruction to fill functional graphic information in a preset position of the two-dimensional coding array.
For example, if the selected version number is version 1, the main control module generates a two-dimensional code array as
Figure GDA0001583712310000373
Figure GDA0001583712310000381
Or the master control module generates a two-dimensional coding array as
Figure GDA0001583712310000382
Figure GDA0001583712310000383
The step 108 is specifically: the main control module calls a bitwise operation instruction to perform mask evaluation on the data in the filled two-dimensional coding array according to a preset mask pattern reference, and selects the mask pattern reference according to a mask evaluation result;
the step 109 is specifically: and calling a bitwise operation instruction by the main control module to mask the elements corresponding to the final coding sequence in the two-dimensional coding array according to the selected mask pattern reference to obtain the masked two-dimensional coding array.
It should be noted that, in the present invention, the element targeted by the main control module when calling the byte-based operation instruction is a byte, and the element targeted by the main control module when calling the bitwise operation instruction is a bit.
Specifically, the main control module calls a bitwise operation instruction to mask an element corresponding to a final coding sequence in the two-dimensional coding array according to the selected mask pattern reference, so as to obtain a masked two-dimensional coding array, specifically: the main control module calls a bitwise operation instruction to invert a value corresponding to a final coding sequence which meets the selected mask pattern reference condition in the two-dimensional coding array (for example, an element with a value of 1 is converted into 0, and an element with a value of 0 is converted into 1), so that the two-dimensional coding array of the mask is obtained.
For example, the obtained two-dimensional code array of the mask is specifically:
Figure GDA0001583712310000391
Figure GDA0001583712310000392
or, the obtained two-dimensional coding array of the mask is specifically:
Figure GDA0001583712310000393
Figure GDA0001583712310000394
Figure GDA0001583712310000401
or, the obtained two-dimensional coding array of the mask is specifically:
Figure GDA0001583712310000402
Figure GDA0001583712310000403
in the step 110, the main control module fills the format information into the two-dimensional coding array of the mask, specifically: and the main control module calls a bitwise operation instruction to fill the format information into the two-dimensional coding array of the mask.
Accordingly, steps 111-120 above are replaced with: and the main control module calls the driving module to send the two-dimensional coding array of the mask after the format information is filled to the display module, and the display module displays the image according to the received two-dimensional coding array of the mask after the format information is filled.
In this embodiment, the main control module calls the bitwise operation instruction to fill each bit of the binary number of the data code word in the final coding sequence into the two-dimensional coding array according to the preset sequence to obtain the filled two-dimensional coding array, so that the space can be effectively saved, and the operation speed can be increased.
Example 3
The embodiment provides an electronic device for converting data into an image, as shown in fig. 4, including a main control module 1, a driving module 2 and a display module 3;
the main control module 1 includes:
the first obtaining submodule 11 is configured to obtain data to be converted;
the encoding submodule 12 is configured to perform data encoding on the data to be converted acquired by the first acquisition submodule 11 according to the version, the preset error correction level and the encoding mode to obtain encoded data, divide the encoded data into a preset number of encoded data blocks according to the preset error correction level and the version, where each encoded data block includes data code words with a preset number of data code words, and acquire a preset number of error correction code words of an error correction code block corresponding to each encoded data block;
an error correction code block generation submodule 13, configured to generate, according to the data code word in each encoded data block obtained by the encoding submodule 12, an error correction code block including a corresponding error correction code word with a preset number of error correction code words;
the encoding construction submodule 14 is configured to construct a final encoding sequence according to the encoded data blocks of the preset number obtained by the encoding submodule 12 and the error correction code blocks corresponding to each encoded data block generated by the error correction code block generation submodule 13;
the two-dimensional array filling submodule 15 is used for filling the two-dimensional code array by using the final coding sequence constructed by the code construction submodule 14 according to a preset rule to obtain a filled two-dimensional code array;
the drive calling submodule 16 is used for calling the drive module 2 to send the data in the two-dimensional coding array obtained by the two-dimensional array filling submodule 15 after filling to the display module 3;
and the display module 3 is used for generating and displaying an image according to the received data in the filled two-dimensional coding array of the main control module 1.
Optionally, the main control module 1 further includes a mapping sub-module;
the mapping submodule is used for mapping the data in the two-dimensional coding array after filling, which is obtained by the two-dimensional array filling submodule 15, into the two-dimensional display array;
the driving calling submodule 16 is specifically used for calling the driving module 2 to send the data in the two-dimensional display array mapped by the mapping submodule to the display module 3;
and the display module 3 is specifically configured to generate and display an image according to the received data in the two-dimensional display array of the main control module 1.
Optionally, the main control module 1 further includes a data analysis sub-module;
and the data analysis submodule is used for performing data analysis on the data to be converted acquired by the first acquisition submodule 11, selecting a coding mode according to a data analysis result, and selecting a version according to the data length of the data to be converted, a preset error correction level and the selected coding mode.
Specifically, the error correction code block generation sub-module 13 specifically includes:
a first acquiring unit configured to acquire, as a current encoded data block, an encoded data block for which a corresponding error correction code block has not been generated;
the first copying unit is used for copying the data code words in the current coded data block acquired by the first acquiring unit into an error correction array;
the first setting unit is used for setting an initial value of the data code word index value, and taking the initial value of the data code word index value as the current data code word index value;
a first judgment unit, configured to judge whether a current data codeword index value is smaller than a data codeword number of a current encoded data block;
the second judging unit is used for judging whether the value of the first code word in the error correction array copied by the first copying unit is 0 or not when the judging result of the first judging unit is yes;
the first shift updating unit is used for sequentially shifting the code words behind the first code word in the error correction array to the left by the position of one code word when the judgment result of the second judging unit is yes, and updating the index value of the current data code word;
the first judging unit is also used for judging whether the index value of the current data code word after the index value of the current data code word is updated by the first shifting updating unit is smaller than the number of the data code words of the current encoded data block;
the first searching and calculating unit is used for finding the index value corresponding to the value of the first code word in the error correction array from the preset data table when the judgment result of the second judging unit is negative, and calculating and updating the value of the first code word in the error correction array to the value of the code word of the preset error correction code word number corresponding to the current encoding data block according to the found index value;
the second shift updating unit is used for calculating and updating a value from a first code word in the error correction array to a code word of the preset error correction code word number corresponding to the current encoding data block by the first searching and calculating unit according to the found index value, and then sequentially shifting a code word corresponding to the sum of the data code word number corresponding to the current encoding data block and the corresponding preset error correction code word number from the preset error correction code word number corresponding to the current encoding data block to the left by one code word position in the error correction array, so as to update the index value of the current data code word;
the first judgment unit is further used for judging whether the index value of the current data code word after the index value of the current data code word is updated by the second shift updating unit is smaller than the number of the data code words of the current encoded data block;
the adding unit is used for taking the code word sequence in the error correction array as an error correction code block of the current coded data block and adding the error correction code block to the back of the data code word in the current coded data block when the judgment result of the first judging unit is negative;
the first acquiring unit is further configured to acquire, when the adding unit adds the error correction code block to the rear of the data code word in the current encoded data block and there is a data encoded block in which the corresponding error correction code block has not been generated, one encoded data block in which the corresponding error correction code block has not been generated as the current encoded data block.
Optionally, the error correction code block generation sub-module 13 further includes a first updating unit:
accordingly, the first shift update unit specifically includes:
the first setting subunit is used for setting an initial value of the first total code word index value, and taking the initial value of the first total code word index value as the current first total code word index value;
the first judging subunit is used for judging whether the index value of the current first total code word is smaller than the sum of the number of the data code words of the current coding data block and the number of the corresponding preset error correcting code words;
the first assignment updating subunit is configured to, when the first determining subunit determines that the first total codeword index value is the first value, assign a value of a codeword subsequent to the codeword corresponding to the current first total codeword index value in the error correction array to the codeword corresponding to the current first total codeword index value, and update the current first total codeword index value;
the first judging subunit is further configured to judge whether the current first total codeword index value after the first assignment updating subunit updates the current first total codeword index value is smaller than the sum of the data codeword number of the current encoded data block and the corresponding preset error correcting codeword number;
the first updating unit is used for updating the index value of the current data code word when the judgment result of the first judging subunit is negative;
the first judging unit is further configured to judge whether the current data codeword index value after the first updating unit updates the current data codeword index value is smaller than the data codeword number of the current encoded data block.
Specifically, the first search calculation unit specifically includes:
the first searching subunit is used for searching a corresponding index value from a preset fifth data table according to the value of the first code word in the error correction array;
the second setting subunit is used for setting an initial value of the error correction code word index value, and taking the initial value of the error correction code word index value as the current error correction code word index value;
the second judgment subunit is used for judging whether the index value of the current error correction code word is smaller than the preset number of error correction code words corresponding to the current encoded data block;
the second searching subunit is used for finding the power exponent corresponding to the current error correction code word index value from a preset sixth data table according to the preset error correction code word number corresponding to the current encoded data block when the judgment result of the second judging subunit is yes;
the first operation subunit is used for performing addition operation on the power exponent found by the second search subunit and the found exponent value to obtain a first result, and performing remainder operation on preset data by using the first result to obtain a second result;
the third searching subunit is used for searching the corresponding coefficient value from a preset seventh data table by taking the second result obtained by the first operation subunit as the item number;
the second operation subunit is configured to perform an exclusive-or operation on the coefficient value found by the third searching subunit and a value of a next codeword of the codeword corresponding to the current error correction codeword index value in the error correction code array to obtain an exclusive-or operation result;
the first updating subunit is used for updating the code word value corresponding to the current error correction code word index value in the error correction array by using the XOR operation result obtained by the second operation subunit, and updating the current error correction code word index value;
the second judging subunit is further configured to judge whether the current error correction codeword index value after the first updating subunit updates the current error correction codeword index value is smaller than the preset error correction codeword number corresponding to the current encoded data block;
and the second shift updating unit is specifically configured to, when the second judgment result of the second judgment subunit is negative, shift codewords, corresponding to the sum of the data codeword number corresponding to the current encoded data block and the corresponding preset error correction codeword number, from the preset error correction codeword number corresponding to the current encoded data block in the error correction array to the left in sequence by one codeword position, and update the current data codeword index value.
Specifically, the second shift update unit specifically includes:
a third setting subunit, configured to set an initial value of the second total codeword index value using a preset error correction codeword number corresponding to the current encoded data block, and use the initial value of the second total codeword index value as an index value of the current second total codeword;
a third judging subunit, configured to judge whether the current second total codeword index value is smaller than a sum of the number of data codewords of the current encoded data block and a corresponding preset error correcting codeword number;
a second assignment updating subunit, configured to, when the third determining subunit determines that the result is yes, assign a value of a codeword subsequent to the codeword corresponding to the current second total codeword index value in the error correction array to the codeword corresponding to the current second total codeword index value, and update the current second total codeword index value;
the third judging subunit is further configured to judge whether the current second total codeword index value after the second assignment updating subunit updates the current second total codeword index value is smaller than the sum of the data codeword number of the current encoded data block and the corresponding preset error correcting codeword number;
the second updating subunit is used for updating the index value of the current data code word when the judgment result of the third judging subunit is negative;
the first judging unit is specifically configured to judge whether the current data codeword index value after the second updating subunit updates the current data codeword index value is smaller than the number of data codewords of the current encoded data block.
Optionally, the error correction code block generation sub-module 13 further includes:
and the error correction array defining unit is used for defining an error correction array, and the length of the error correction array is not less than the data codeword number of any one encoded data block and not less than the error correction codeword number of any one error correction code block.
Optionally, the two-dimensional array padding sub-module 15 is specifically configured to call a byte operation instruction to convert each bit of a binary number of a data code word in a final coding sequence constructed by the code construction sub-module 14 into a byte of data, and pad the data into the two-dimensional coding array according to a preset sequence, so as to obtain a padded two-dimensional coding array.
Specifically, the mapping sub-module specifically includes:
a column index setting unit for setting an initial value of a column index value as a current column index value;
the third judging unit is used for judging whether the index value of the current row is smaller than the number of modules of each row corresponding to the version;
the assignment updating unit is used for assigning the assignment to each element of the two-dimensional display array corresponding to the current row index value by using the element of which each value is 1 in the two-dimensional coding array corresponding to the current row index value according to a preset rule and updating the current row index value when the judgment result of the third judging unit is yes;
the third judging unit is also used for judging whether the current column index value after the assignment updating unit updates the current column index value is smaller than the number of modules of each column corresponding to the version;
and the display module 3 is specifically configured to generate and display an image according to the received data in the two-dimensional display array of the main control module 1 when the determination result of the third determination unit is negative.
Specifically, the assignment updating unit specifically includes:
the line index setting subunit is used for setting an initial value of a line index value when the judgment result of the third judgment unit is yes, and taking the initial value of the line index value as the current line index value;
the fourth judging subunit is used for judging whether the index value of the current row is smaller than the number of modules in each row corresponding to the version;
a fifth judging subunit, configured to, when the judgment result of the fourth judging subunit is yes, judge whether the value of an element in the two-dimensional coding array corresponding to the current row index value and the current column index value is 1;
the third updating subunit is used for updating the current row index value when the judgment result of the fifth judging subunit is negative;
the fourth judging subunit is further configured to judge whether the current row index value after the current row index value is updated by the third updating subunit is smaller than the number of modules in each row corresponding to the version;
a shifting subunit, configured to, when the judgment result of the fifth judgment subunit is yes, use the current row index value to perform rounding on 8 to obtain a first rounding result, perform remainder on the current row index value to obtain a first remainder result, shift a bit with a median value of 1 in binary numbers of elements in the two-dimensional code array corresponding to the current row index value and the current column index value to the left by the number of bits of the first remainder result, and use the value of the shifted element as a shifting result;
the operation updating subunit is used for performing OR operation on the value of the element corresponding to the abscissa by taking the current column index value in the two-dimensional display array and the value of the element corresponding to the abscissa by taking the first rounding result obtained by the shifting subunit, and the shifting result obtained by the shifting subunit, assigning the OR operation result to the element corresponding to the abscissa by taking the current column index value in the two-dimensional display array and the first rounding result obtained by the shifting subunit, and updating the current row index value;
the fourth judging subunit is further configured to judge whether the current row index value after the current row index value is updated by the operation updating subunit is smaller than the number of modules in each row corresponding to the version;
the third updating subunit is further configured to update the current column index value when the fourth determining subunit determines that the result is negative;
the third judging unit is further configured to determine whether the current column index value after the third updating subunit updates the current column index value is smaller than the number of modules per column corresponding to the version.
Optionally, the mapping sub-module further includes a fourth determining unit;
the fourth judging unit is used for judging whether the number of the modules on each side corresponding to the version is less than the number of the pixels of the short edges of the screen in the screen information;
accordingly, the column index setting unit is specifically configured to set an initial value of the column index value when the fourth determination unit determines that the result is yes.
Optionally, the two-dimensional array filling sub-module 15 is specifically configured to invoke a bitwise operation instruction to fill each bit of the binary number of the data code word in the final coding sequence into the two-dimensional coding array according to a preset sequence to obtain a filled two-dimensional coding array.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (24)

1. A method for converting data into an image, which is suitable for an electronic device comprising a main control module, a driving module and a display module, and is characterized in that the method comprises the following steps:
step S1: the method comprises the steps that a main control module obtains data to be converted, data coding is carried out on the data to be converted according to a version, a preset error correction level and a coding mode to obtain coded data, the coded data are divided into coded data blocks with a preset number according to the preset error correction level and the version, each coded data block comprises data code words with a preset data code word number, and the preset error correction code word number of an error correction code block corresponding to each coded data block is obtained;
step S2: the main control module generates corresponding error correction code blocks comprising error correction code words with preset error correction code word number according to the data code words in each coded data block, and constructs a final coded sequence according to the coded data blocks with the preset number and the error correction code blocks corresponding to each coded data block;
step S3: the main control module fills the two-dimensional coding array by using the final coding sequence according to a preset rule to obtain a filled two-dimensional coding array;
step S4: the main control module calls the driving module to send the data in the filled two-dimensional coding array to the display module;
step S5: the display module generates and displays an image according to the received data in the filled two-dimensional coding array;
the main control module generates a corresponding error correction code block including an error correction code word with a preset error correction code word number according to the data code word in each encoded data block, and specifically includes:
step M1: the main control module acquires a coded data block which does not generate a corresponding error correction code block as a current coded data block, copies a data code word in the current coded data block into an error correction array, sets an initial value of a data code word index value, and takes the initial value of the data code word index value as the current data code word index value;
step M2: the main control module judges whether the index value of the current data code word is smaller than the number of the data code words of the current coding data block, if so, the step M3 is executed, otherwise, the step M7 is executed;
step M3: the main control module judges whether the value of the first code word in the error correction array is 0, if so, the step M4 is executed; otherwise, executing step M5;
step M4: the main control module sequentially shifts the code words behind the first code word in the error correction array to the left by the position of one code word, updates the index value of the current data code word and executes the step M2;
step M5: the main control module finds an index value corresponding to the value of the first code word in the error correction array from a preset data table, calculates and updates the value of the first code word in the error correction array to the value of the code word of the preset error correction code word number corresponding to the current encoded data block according to the found index value, and executes the step M6;
step M6: the main control module sequentially shifts code words corresponding to the sum of the data code word number corresponding to the current encoding data block and the corresponding preset error correcting code word number from the preset error correcting code word number corresponding to the current encoding data block to the left by one code word position in the error correcting array, updates the index value of the current data code word and executes the step M2;
step M7: and the main control module takes the code word sequence in the error correction array as an error correction code block of the current coded data block, adds the error correction code block of the current coded data block to the back of the data code word in the current coded data block, and executes the step M1 when a data coded block which does not generate a corresponding error correction code block exists.
2. The method according to claim 1, wherein the step S4 is preceded by: the main control module maps the data in the filled two-dimensional coding array into a two-dimensional display array;
the step S4 specifically includes: the main control module calls the driving module to send the data in the two-dimensional display array to the display module;
the step S5 specifically includes: and the display module generates and displays an image according to the received data in the two-dimensional display array.
3. The method according to claim 1 or 2, wherein after the master control module obtains the data to be converted, the method further comprises: the main control module analyzes the data to be converted, selects the coding mode according to the data analysis result, and selects the version according to the data length of the data to be converted, the preset error correction level and the selected coding mode.
4. The method according to claim 1, wherein the step M4 specifically comprises:
step M41: the main control module sets an initial value of a first total code word index value, and takes the initial value of the first total code word index value as a current first total code word index value;
step M42: the main control module judges whether the index value of the current first total code word is smaller than the sum of the number of the data code words of the current coding data block and the number of the corresponding preset error correcting code words, if so, the step M43 is executed; otherwise, updating the index value of the current data code word, and executing the step M2;
step M43: and the main control module assigns the value of a code word behind the code word corresponding to the current first total code word index value in the error correction array to the code word corresponding to the current first total code word index value, updates the current first total code word index value and executes the step M42.
5. The method according to claim 1, wherein the step M5 specifically comprises:
step M51: the main control module searches a corresponding index value from a preset fifth data table according to the value of the first code word in the error correction array, sets an initial value of an error correction code word index value, and takes the initial value of the error correction code word index value as the current error correction code word index value;
step M52: the main control module judges whether the index value of the current error correction code word is smaller than the preset error correction code word number corresponding to the current encoding data block, if so, the step M53 is executed, otherwise, the step M6 is executed;
step M53: the main control module finds a power exponent corresponding to the index value of the current error correction code word from a preset sixth data table according to the preset error correction code word number corresponding to the current encoding data block, performs addition operation on the found power exponent and the found exponent value to obtain a first result, and performs remainder operation on preset data by using the first result to obtain a second result;
step M54: the main control module searches a corresponding coefficient value from a preset seventh data table by taking the second result as the item number, performs exclusive-or operation by using the searched coefficient value and a value of a next codeword of the codeword corresponding to the index value of the current error correction codeword in the error correction code array to obtain an exclusive-or operation result, updates the value of the codeword corresponding to the index value of the current error correction codeword in the error correction code array by using the exclusive-or operation result, updates the index value of the current error correction codeword, and executes step M52.
6. The method according to claim 1, wherein the step M6 specifically comprises:
step M61: the main control module uses the preset error correcting code word number corresponding to the current encoding data block to set an initial value of a second total code word index value, and takes the initial value of the second total code word index value as an index value of the current second total code word;
step M62: the main control module judges whether the index value of the current second total code word is smaller than the sum of the number of the data code words of the current coding data block and the number of the corresponding preset error correcting code words, if so, the step M63 is executed; otherwise, updating the index value of the current data code word, and executing the step M2;
step M63: the main control module assigns a value of a codeword following the codeword corresponding to the current second total codeword index value in the error correction array to the codeword corresponding to the current second total codeword index value, updates the current second total codeword index value, and performs step M62.
7. The method according to claim 1, wherein the step M1 further comprises: the main control module defines the error correction array, and the length of the error correction array is not less than the data codeword number of any one encoding data block and not less than the error correction codeword number of any one error correction code block.
8. The method according to claim 2, wherein the step S3 is specifically: and the main control module calls a byte-based operation instruction to convert each bit of the binary number of the data code word in the final coding sequence into one byte of data and fills the data into the two-dimensional coding array according to a preset sequence to obtain the filled two-dimensional coding array.
9. The method according to claim 2 or 8, wherein the main control module maps the data in the filled two-dimensional code array to a two-dimensional display array, and specifically comprises:
step S41: the main control module sets an initial value of a column index value, and takes the initial value of the column index value as a current column index value;
step S42: the main control module judges whether the index value of the current row is smaller than the number of modules in each row corresponding to the version, if so, the step S43 is executed; otherwise, executing step S5;
step S43: and the main control module assigns values to each element of the two-dimensional display array corresponding to the current column index value by using each element of which the value is 1 in the two-dimensional coding array corresponding to the current column index value according to a preset rule, updates the current column index value and executes the step S42.
10. The method according to claim 9, wherein the step S43 specifically includes:
step S431: the main control module sets an initial value of a row index value, and the initial value of the row index value is used as a current row index value;
step S432: the main control module judges whether the index value of the current row is smaller than the number of modules in each row corresponding to the version, if so, the step S433 is executed; otherwise, updating the current column index value, and executing step S42;
step S433: the main control module determines whether the values of the elements in the two-dimensional coding array corresponding to the current row index value and the current column index value are 1, if yes, step S434 is executed; otherwise, updating the index value of the current row, and executing the step S432;
step S434: the main control module uses the current row index value to carry out rounding on 8 to obtain a first rounding result, carries out complementation on the current row index value to 8 to obtain a first complementation result, leftwards shifts the bit of the first complementation result by using the bit with the median value of 1 in binary numbers of elements in a two-dimensional coding array corresponding to the current row index value and the current column index value, and uses the value of the shifted element as a shifting result;
step S435: the main control module performs an or operation on the values of the elements corresponding to the two-dimensional display array with the current column index value as the ordinate and the first rounding result as the abscissa and the shift result, assigns the or operation result to the elements corresponding to the two-dimensional display array with the current column index value as the ordinate and the first rounding result as the abscissa, updates the current row index value, and executes step S432.
11. The method according to claim 9, wherein the step S41 is preceded by: and the main control module judges whether the number of each side module corresponding to the version is less than the number of short edge pixels of the screen in the screen information, if so, the step S41 is executed, and otherwise, an error is reported.
12. The method according to claim 1, wherein the step S3 specifically includes: and the main control module calls a bitwise operation instruction to fill each bit of the binary number of the data code word in the final coding sequence into the two-dimensional coding array according to a preset sequence to obtain a filled two-dimensional coding array.
13. An electronic device for converting data into images is characterized by comprising a main control module, a driving module and a display module;
the master control module comprises:
the first acquisition submodule is used for acquiring data to be converted;
the encoding submodule is used for carrying out data encoding on the data to be converted acquired by the first acquisition submodule according to a version, a preset error correction level and an encoding mode to obtain encoded data, dividing the encoded data into encoded data blocks with a preset number according to the preset error correction level and the version, wherein each encoded data block comprises data code words with a preset data code word number, and acquiring the preset error correction code word number of an error correction code block corresponding to each encoded data block;
the error correction code block generation submodule is used for generating a corresponding error correction code block of an error correction code word comprising a preset number of error correction code words according to the data code word in each coded data block obtained by the coding submodule;
the encoding construction submodule is used for constructing a final encoding sequence according to the encoding data blocks with the preset number obtained by the encoding submodule and the error correction code blocks corresponding to each encoding data block generated by the error correction code block generation submodule;
the two-dimensional array filling submodule is used for filling the two-dimensional coding array by using the final coding sequence constructed by the coding construction submodule according to a preset rule to obtain a filled two-dimensional coding array;
the drive calling submodule is used for calling the drive module to send the data in the filled two-dimensional coding array obtained by the two-dimensional array filling submodule to the display module;
the display module is used for generating and displaying an image according to the received data in the filled two-dimensional coding array of the main control module;
the error correction code block generation sub-module specifically includes:
a first acquiring unit configured to acquire, as a current encoded data block, an encoded data block for which a corresponding error correction code block has not been generated;
the first copying unit is used for copying the data code words in the current coded data block acquired by the first acquiring unit into an error correction array;
the first setting unit is used for setting an initial value of a data code word index value, and taking the initial value of the data code word index value as a current data code word index value;
a first judgment unit, configured to judge whether a current data codeword index value is smaller than a data codeword number of a current encoded data block;
a second judging unit, configured to judge whether a value of a first codeword in the error correction array after being copied by the first copying unit is 0 when the first judging unit judges that the result is yes;
a first shift updating unit, configured to, when the second determination unit determines that the first codeword is a data codeword, sequentially shift codewords following the first codeword in the error correction array to the left by a position of a codeword, and update the current data codeword index value;
the first judging unit is further configured to judge whether the current data codeword index value after the first shift updating unit updates the current data codeword index value is smaller than the data codeword number of the current encoded data block;
the first searching and calculating unit is used for finding an index value corresponding to the value of the first code word in the error correction array from a preset data table when the judgment result of the second judging unit is negative, and calculating and updating the value of the first code word in the error correction array to the value of the code word of the preset error correction code word number corresponding to the current encoded data block according to the found index value;
a second shift updating unit, configured to, after the first search calculating unit calculates and updates a value from a first codeword in the error correction array to a codeword with a preset error correction codeword number corresponding to the current encoded data block according to the found index value, sequentially shift a codeword, corresponding to a sum of the data codeword number corresponding to the current encoded data block and the corresponding preset error correction codeword number, in the error correction array by one codeword position to the left, and update a current data codeword index value;
the first judging unit is further configured to judge whether the current data codeword index value after the second shift updating unit updates the current data codeword index value is smaller than the data codeword number of the current encoded data block;
the adding unit is used for taking the code word sequence in the error correction array as an error correction code block of the current coded data block and adding the error correction code block to the back of the data code word in the current coded data block when the judgment result of the first judging unit is negative;
the first obtaining unit is further configured to, when the adding unit adds the error correction code block to the rear of the data codeword in the current encoded data block and there is a data encoded block in which the corresponding error correction code block has not been generated, obtain, as the current encoded data block, an encoded data block in which the corresponding error correction code block has not been generated.
14. The electronic device of claim 13, wherein the master module further comprises a mapping submodule;
the mapping submodule is used for mapping the data in the filled two-dimensional coding array obtained by the two-dimensional array filling submodule into a two-dimensional display array;
the driving calling submodule is specifically configured to call the driving module to send the data in the two-dimensional display array mapped by the mapping submodule to the display module;
the display module is specifically configured to generate and display an image according to the received data in the two-dimensional display array of the main control module.
15. The electronic device of claim 13 or 14, wherein the master control module further comprises a data analysis sub-module;
the data analysis submodule is used for carrying out data analysis on the data to be converted acquired by the first acquisition submodule, selecting the coding mode according to a data analysis result, and selecting the version according to the data length of the data to be converted, a preset error correction level and the selected coding mode.
16. The electronic device of claim 13, wherein the error correction code block generation sub-module further comprises a first updating unit:
the first shift update unit specifically includes:
the first setting subunit is used for setting an initial value of a first total code word index value, and taking the initial value of the first total code word index value as a current first total code word index value;
the first judging subunit is used for judging whether the index value of the current first total code word is smaller than the sum of the number of the data code words of the current coding data block and the number of the corresponding preset error correcting code words;
a first assignment updating subunit, configured to, when the first determining subunit determines that the first total codeword index value is the first value, assign a value of a codeword subsequent to a codeword corresponding to the current first total codeword index value in the error correction array to a codeword corresponding to the current first total codeword index value, and update the current first total codeword index value;
the first judging subunit is further configured to judge whether a current first total codeword index value after the first assignment updating subunit updates the current first total codeword index value is smaller than a sum of the number of data codewords of the current encoded data block and a corresponding preset number of error correcting codewords;
the first updating unit is configured to update the current data codeword index value when the first determining subunit determines that the result is negative;
the first judging unit is further configured to judge whether the current data codeword index value after the first updating unit updates the current data codeword index value is smaller than the data codeword number of the current encoded data block.
17. The electronic device according to claim 13, wherein the first search calculation unit specifically includes:
the first searching subunit is configured to search a corresponding index value from a preset fifth data table according to the value of the first codeword in the error correction array;
the second setting subunit is used for setting an initial value of the error correction code word index value, and taking the initial value of the error correction code word index value as the current error correction code word index value;
the second judgment subunit is used for judging whether the index value of the current error correction code word is smaller than the preset number of error correction code words corresponding to the current encoded data block;
the second searching subunit is configured to, when the second determining subunit determines that the current encoded data block corresponds to the error correction code word, find the power exponent corresponding to the current error correction code word index value from a preset sixth data table according to the preset error correction code word number corresponding to the current encoded data block;
the first operation subunit is used for performing addition operation on the power exponent found by the second search subunit and the found exponent value to obtain a first result, and performing remainder operation on preset data by using the first result to obtain a second result;
a third searching subunit, configured to search, by using the second result obtained by the first operation subunit as an item number, a corresponding coefficient value from a preset seventh data table;
the second operation subunit is configured to perform an exclusive-or operation on the coefficient value found by the third searching subunit and a value of a next codeword of the codeword corresponding to the current error correction codeword index value in the error correction code array to obtain an exclusive-or operation result;
the first updating subunit is configured to update, by using the xor operation result obtained by the second operation subunit, a value of a codeword corresponding to a current error correction codeword index value in the error correction array, and update the current error correction codeword index value;
the second judging subunit is further configured to judge whether the current error correction codeword index value after the first updating subunit updates the current error correction codeword index value is smaller than the preset error correction codeword number corresponding to the current encoded data block;
the second shift updating unit is specifically configured to, when the second determining subunit determines that the result is negative, shift codewords, corresponding to the sum of the number of data codewords corresponding to the current encoded data block and the corresponding number of preset error correcting codewords, of the error correction array to the left in sequence by one codeword position, and update the index value of the current data codeword.
18. The electronic device according to claim 13, wherein the second shift updating unit specifically includes:
a third setting subunit, configured to set an initial value of a second total codeword index value using a preset error correction codeword number corresponding to the current encoded data block, and use the initial value of the second total codeword index value as an index value of a current second total codeword;
a third judging subunit, configured to judge whether the current second total codeword index value is smaller than a sum of the number of data codewords of the current encoded data block and a corresponding preset error correcting codeword number;
a second assignment updating subunit, configured to, when the third determining subunit determines that the result is yes, assign a value of a codeword subsequent to a codeword corresponding to the current second total codeword index value in the error correction array to a codeword corresponding to the current second total codeword index value, and update the current second total codeword index value;
the third judging subunit is further configured to judge whether the current second total codeword index value after the second assignment updating subunit updates the current second total codeword index value is smaller than the sum of the number of data codewords of the current encoded data block and the corresponding preset number of error correcting codewords;
the second updating subunit is configured to update the current data codeword index value when the determination result of the third determining subunit is negative;
the first determining unit is specifically configured to determine whether the current data codeword index value after the second updating subunit updates the current data codeword index value is smaller than the number of data codewords of the current encoded data block.
19. The electronic device of claim 13, wherein the error correction code block generation sub-module further comprises:
and the error correction array defining unit is used for defining the error correction array, and the length of the error correction array is not less than the data codeword number of any one encoded data block and not less than the error correction codeword number of any one error correction code block.
20. The electronic device according to claim 14, wherein the two-dimensional array padding sub-module is specifically configured to invoke a byte-based operation instruction to convert each bit of a binary number of a data codeword in the final coding sequence constructed by the code construction sub-module into a byte of data, and pad the byte of data into the two-dimensional code array according to a preset sequence, so as to obtain the padded two-dimensional code array.
21. The electronic device according to claim 14 or 20, wherein the mapping sub-module specifically comprises:
the device comprises a column index setting unit, a column index setting unit and a column index setting unit, wherein the column index setting unit is used for setting an initial value of a column index value and taking the initial value of the column index value as a current column index value;
a third judging unit, configured to judge whether the current column index value is smaller than the number of modules in each column corresponding to the version;
the assignment updating unit is used for assigning the assignment of each element of the two-dimensional coding array corresponding to the current row index value to each element of the two-dimensional display array corresponding to the current row index value according to a preset rule by using each element of which the value is 1 in the two-dimensional coding array corresponding to the current row index value when the judgment result of the third judging unit is yes;
the third judging unit is further configured to judge whether the current column index value after the current column index value is updated by the assignment updating unit is smaller than the number of modules in each column corresponding to the version;
and the display module is specifically configured to generate and display an image according to the received data in the two-dimensional display array of the main control module when the determination result of the third determination unit is negative.
22. The electronic device according to claim 21, wherein the assignment updating unit specifically includes:
a line index setting subunit, configured to set an initial value of a line index value when the determination result of the third determining unit is yes, and use the initial value of the line index value as a current line index value;
a fourth judging subunit, configured to judge whether the current row index value is smaller than the number of modules in each row corresponding to the version;
a fifth judging subunit, configured to, when the judgment result of the fourth judging subunit is yes, judge whether a value of an element in the two-dimensional coding array corresponding to the current row index value and the current column index value is 1;
a third updating subunit, configured to update the current row index value when the determination result of the fifth determining subunit is negative;
the fourth judging subunit is further configured to judge whether a current row index value after the current row index value is updated by the third updating subunit is smaller than the number of modules in each row corresponding to the version;
a shifting subunit, configured to, when the judgment result of the fifth judgment subunit is yes, use the current row index value to perform rounding on 8 to obtain a first rounding result, perform complementation on 8 to obtain a first complementation result, shift a bit with a median value of 1 in binary numbers of elements in the two-dimensional code array corresponding to the current row index value and the current column index value to the left by the number of bits of the first complementation result, and use the value of the shifted element as a shifting result;
an operation updating subunit, configured to perform an or operation on a value of an element corresponding to the current column index value in the two-dimensional display array as a vertical coordinate and the first rounding result obtained by the shifting subunit as a horizontal coordinate, and the shifting result obtained by the shifting subunit, assign the or operation result to an element corresponding to the current column index value in the two-dimensional display array as a vertical coordinate and the first rounding result obtained by the shifting subunit as a horizontal coordinate, and update the current row index value;
the fourth judging subunit is further configured to judge whether the current row index value after the current row index value is updated by the operation updating subunit is smaller than the number of modules in each row corresponding to the version;
the third updating subunit is further configured to update the current column index value when the fourth determining subunit determines that the result is negative;
the third determining unit is further configured to determine whether a current column index value after the third updating subunit updates the current column index value is smaller than a number of modules per column corresponding to the version.
23. The electronic device of claim 21, wherein the mapping sub-module further comprises a fourth determination unit;
the fourth judging unit is used for judging whether the number of the modules on each side corresponding to the version is smaller than the number of the short edge pixels of the screen in the screen information;
the column index setting unit is specifically configured to set an initial value of a column index value when the fourth determination unit determines that the result is yes.
24. The electronic device according to claim 21, wherein the two-dimensional array padding sub-module is specifically configured to invoke a bitwise operation instruction to pad each bit of the binary number of the data code word in the final code sequence into the two-dimensional code array according to a preset sequence to obtain the padded two-dimensional code array.
CN201810057509.8A 2018-01-22 2018-01-22 Method for converting data into image and electronic equipment Active CN108197088B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810057509.8A CN108197088B (en) 2018-01-22 2018-01-22 Method for converting data into image and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810057509.8A CN108197088B (en) 2018-01-22 2018-01-22 Method for converting data into image and electronic equipment

Publications (2)

Publication Number Publication Date
CN108197088A CN108197088A (en) 2018-06-22
CN108197088B true CN108197088B (en) 2021-04-27

Family

ID=62589976

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810057509.8A Active CN108197088B (en) 2018-01-22 2018-01-22 Method for converting data into image and electronic equipment

Country Status (1)

Country Link
CN (1) CN108197088B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102624529A (en) * 2012-03-12 2012-08-01 深圳市文鼎创数据科技有限公司 Setting method and device for key factor of dynamic token
CN104376356A (en) * 2014-12-02 2015-02-25 合肥城市云数据中心有限公司 Two-dimensional code generating method with encryption function
CN106156820A (en) * 2015-03-25 2016-11-23 北大方正集团有限公司 two-dimensional code generation method and device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101950301A (en) * 2010-09-26 2011-01-19 北京飞天诚信科技有限公司 Data processing method and device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102624529A (en) * 2012-03-12 2012-08-01 深圳市文鼎创数据科技有限公司 Setting method and device for key factor of dynamic token
CN104376356A (en) * 2014-12-02 2015-02-25 合肥城市云数据中心有限公司 Two-dimensional code generating method with encryption function
CN106156820A (en) * 2015-03-25 2016-11-23 北大方正集团有限公司 two-dimensional code generation method and device

Also Published As

Publication number Publication date
CN108197088A (en) 2018-06-22

Similar Documents

Publication Publication Date Title
CN112711935B (en) Encoding method, decoding method, apparatus, and computer-readable storage medium
CN107563475B (en) Two-dimensional code encoding method and device
CN100377173C (en) Two-dimensional code construction based on hexadecimal coding
JP3847078B2 (en) Method of generating transformation matrix for encoding transmission format combination identifier in mobile communication system and transmission method of transmission format combination identifier
CN101682599A (en) Method for transmitting control information, and method for generating codeword for the same
CN108694918A (en) Coding method and device, coding/decoding method and device and display device
US7548175B2 (en) Encoding apparatus, decoding apparatus, encoding method, computer readable medium storing program thereof, and computer data signal
EP4236129A1 (en) Communication data processing method and apparatus, device, and storage medium
CN107239362A (en) A kind of computational methods and system of CRC parallel computing code
CN108197088B (en) Method for converting data into image and electronic equipment
US8699805B2 (en) Image processing apparatus and image processing method
CN104572994A (en) Method and device for searching data
CN114758728B (en) Genotype identification and visualization method for generating minimum hamming distance under mixed system
CN104468022A (en) Transport format combination decoding method and device
CN101365043B (en) Spot array stage pixel point color calibrating method and device
TWI744679B (en) Method and device for data processing using error codes
CN107122067A (en) Method, device and the readable storage medium storing program for executing of physical medium surface location encoding and decoding
CN107463542B (en) Method for representing binary number by using ASCII (ASCII) to print characters
CN102136885B (en) Parallel physical uplink shared channel (PUSCH) interleaving and scrambling realization method and system for 3rd-generation partnership project long term evolution (3GPP LTE)
EP4016849A1 (en) Ldpc coding method and apparatus, and base station and readable storage medium
CN102364441B (en) The display methods of GIF pictures, apparatus and system
CN117094349B (en) Two-dimensional code graph generation method, device, equipment and medium
US7191200B2 (en) Method and apparatus for binary number conversion
CN111757124B (en) STC-based undistorted steganography method and undistorted secret information extraction method
JPH0613915A (en) Error check method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
OL01 Intention to license declared