Disclosure of Invention
The invention aims to provide a method for calling a picture word stock, which solves the technical problems.
The technical problems solved by the invention can be realized by adopting the following technical scheme:
a method for calling a picture word stock comprises the following steps:
s100, defining an array through a header file, and taking the array as a data positioning chart of characters;
s200, obtaining coordinates according to the positions of the characters in a picture word stock, and extracting positioning data of a corresponding range in the data positioning chart according to the coordinates;
s300, defining a color formula of each point, and obtaining the color of each point according to the color formula;
s400, obtaining colored characters by making point sets of the characters in the positioning data range, and extracting the colored characters.
Preferably, each set of said positioning data in said data positioning chart corresponds to each said character.
Preferably, the color formula is:
C=(A*D+B*(256-D))/256;
c is the color value of the point, A is the preset color value of the character, B is the background color value of the picture word stock, and D is the color depth value.
Preferably, the color depth value is taken from a color value of any one color in the data location chart.
Preferably, the step of making the picture word stock includes:
s010, defining a rectangular window through drawing software;
s020, inputting all characters into a rectangular window in sequence;
s030, saving a picture word stock formed by the rectangular window and the characters as a BMP file in a 24-bit bitmap format;
s040, converting the BMP file into a BIN file through modular software.
Preferably, the rectangular window is used to accommodate all the characters.
Preferably, the background color of the rectangular window is black, and the color of the character is white.
Preferably, the heights of all the characters are equal, and the intervals between adjacent characters are equal.
Preferably, the character input step is as follows:
s021, starting from the left upper end of the rectangular window, and sequentially inputting the characters from left to right;
s022, starting to input the characters from the leftmost side of the rectangular window of the second row after the characters in the first row are input, and inputting the characters in the second row from left to right again;
s023, the character input principle of each row is from left to right, and the next row is started after the character input of each row is finished until all the characters are input.
The beneficial effects are that: the method has the advantages that the data positioning chart is built, the characters in the picture character library are conveniently positioned, then the characters needing to be discolored are dyed according to the positioning coordinates and the color formula, the character positioning is accurate, the dyeing is simple and quick, the fonts and the pictures in the picture character library are displayed on the LCD display screen in color, the appearance is more attractive, the design requirements of modern medical instruments are met, and important fonts are highlighted and dyed more clearly.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
It should be noted that, without conflict, the embodiments of the present invention and features of the embodiments may be combined with each other.
The invention is further described below with reference to the drawings and specific examples, which are not intended to be limiting.
As shown in fig. 1, the invention provides a method for retrieving a picture word stock, which comprises the following steps:
s100, defining an array through a header file, and taking the array as a data positioning chart of characters;
s200, obtaining coordinates according to the positions of the characters in the picture word stock, and extracting positioning data of a corresponding range in the data positioning chart according to the coordinates;
s300, defining a color formula of the point, and obtaining the color of each point according to the color formula;
s400, extracting colored characters by using a point set of characters in a positioning data range.
The method for calling the picture word stock has the following advantages:
the method has the advantages that the data positioning chart is built, the characters in the picture character library are conveniently positioned, then the characters needing to be discolored are dyed according to the positioning coordinates and the color formula, finally the dyed characters are extracted, important fonts are highlighted and dyed, the characters are clearer, the character positioning is accurate, the dyeing is simple and quick, the fonts and the pictures in the picture character library are displayed on the LCD display screen in color, the appearance is attractive, and the design requirements of modern medical instruments are met.
As a preferred embodiment of the present invention, each set of positioning data in the data positioning chart corresponds to each character. The positioning array is convenient to use to position any character in the picture character library, and subsequent dyeing operation is convenient.
As a preferred embodiment of the present invention, the color formula is:
C=(A*D+B*(256-D))/256;
c is the color value of the point, A is the color value of the preset character, B is the background color value of the picture word stock, and D is the color depth value. And defining a color calculation formula, and providing a basis for the color and the color depth of the point.
As a preferred embodiment of the present invention, the color depth value is taken from the color value of any one color in the data location chart. The color depth value D may determine the color depth of the point.
Specifically, the use method of the picture word stock is summarized as follows: converting the picture word stock into BIN file and storing in FLASH (FLASH is the most common file system storage medium of embedded system), confirming the positioning data according to the character position, taking out the positioning data according to the requirement, and then marking out a series of color points, combining into the required colored characters and displaying on LCD.
Specifically, as shown in fig. 2, the color of the words in the third column of the first row in the picture word stock needs to be changed, and the character size is 20×20, the corresponding positioning data X40. 60 in the data positioning chart is first fetched, Y0.20, all data within this range were extracted, the combination of points consisting of data in these ranges is the desired character. When the data picture is in RGB24 format, the picture information is stored in a manner of r=8, g=8, and b=8, and the numerical value of any one color is taken as the color depth value D to be displayed.
Assuming that the color of the character to be displayed is a, the background color of the rectangular window is B, the positioning data XY 0 of the character as described above. Dotting within the range of 20] [ 0...20 ], the MCU calculates the color of each point according to the color formula of the point, so that each proposed character and rectangular window are dyed, and the picture word stock is colorized and polychromatic, so that the picture word stock is more attractive.
As shown in fig. 2, as a preferred embodiment of the present invention, the steps for making the photo word stock include:
s010, defining a rectangular window through drawing software;
s020, inputting all characters into the rectangular window in sequence;
s030, saving a picture word stock formed by a rectangular window and characters as a BMP file in a 24-bit bitmap format;
s040, converting the BMP file into a BIN file through a modular software.
Preferably, the size of the rectangular window is defined according to the sizes of all the characters, so that the size is fully utilized, the storage space of the picture word stock is saved maximally, and the pictures stored into the 24-bit bitmap format facilitate the color change of the subsequent picture word stock. The picture word stock is simple to manufacture, high in efficiency and flexible, fonts and the size of the word stock can be defined according to requirements, the occupied storage space is small, and no support of any operating system is needed, so that the embedded system can manufacture the picture word stock, and the applicability is wide.
As a preferred embodiment of the present invention, a rectangular window is used to accommodate all characters. Specifically, for example, the character size is 20×20, and the total number of characters is 100, the size of the rectangular window may be designed to be 200×200, and the character size coincides with the size unit of the rectangular window. That is, the size of the rectangular window is not smaller than the occupied size of all the characters after being arranged, so that all the characters are ensured to be in the rectangular window. The size of the rectangular window is the same as the total size of all characters, the space of the rectangular window is greatly utilized, and the storage space of a picture word stock is saved.
As a preferred embodiment of the present invention, the background color of the rectangular window is black, and the color of the character is white. The method is convenient for dyeing characters and background colors.
As a preferred embodiment of the present invention, all characters are equal in height and the interval between adjacent characters is equal. The typesetting of the characters is more regular, and other character spaces are not occupied, so that the positioning of the characters is more accurate.
As a preferred embodiment of the present invention, the character input steps are:
s021, starting from the left upper end of the rectangular window, and sequentially inputting characters from left to right;
s022, starting to input from the leftmost side of the rectangular window of the second row after the first row of characters are input, and inputting the second row of characters from left to right again;
s023, the character input principle of each row is from left to right, and the next row is started after the character input of each row is finished, until all characters are input.
Preferably, each character is sequentially input, so that the subsequent characters can be conveniently searched and positioned, and each character can be conveniently filled in the corresponding space position.
As a preferred embodiment of the present invention, the first character of each row is aligned with the left side of the rectangular window and the last character of each row is aligned with the right side of the rectangular window. The space of the rectangular window is greatly utilized, and the storage capacity of the picture word stock is saved.
The foregoing description is only illustrative of the preferred embodiments of the present invention and is not to be construed as limiting the scope of the invention, and it will be appreciated by those skilled in the art that equivalent substitutions and obvious variations may be made using the description and illustrations of the present invention, and are intended to be included within the scope of the present invention.