Home > Net >  C # how to show character lattice data efficiently to control
C # how to show character lattice data efficiently to control

Time:11-25

The younger brother novice, a word stock tool now doing,
Have the character data, 0 is blank, 1 on behalf of the black spots,
Currently the only can realize the way setpixel on bitmap, need to traverse lattice each byte of data to complete a character dot matrix display,

 
Private void DrawOneChar (Point loc, Size Size, byte [] data)
{
Int mask;
Int x=loc. X, y=loc. Y;
For (int row=0; The row & lt; FontHeight; Row++)
{
For (int col=0; Col & lt; (FontWidth + 7)/8; Col++)
{
Mask=0 x80;
For (int bits=0; Bits & lt; 8; Bits++)
{
PBitmap. SetPixel (x, y, (data [row + col * (FontWidth + 7)/8] & amp; Mask)==mask? Color. Black: Color. White);
Mask=mask & gt;> 1;
X +=1;
}
}
X=0;
Y +=1;
}
}



Consult everybody, if there is a more efficient way,

CodePudding user response:

https://bbs.csdn.net/topics/396386834
  •  Tags:  
  • C#
  • Related