小弟新手,現在在做一個字庫工具。
手上有字符資料,0是空白,1代表黑點。
目前能實作的方式只有在 bitmap上setpixel,需要遍歷點陣資料的每個位元組才能完成一個字符的點陣顯示。
private void DrawOneChar(Point loc, Size size, byte[] data)
{
int mask;
int x = loc.X, y = loc.Y;
for (int row = 0; row < FontHeight; row++)
{
for (int col = 0; col < (FontWidth + 7) / 8; col++)
{
mask = 0x80;
for (int bits = 0; bits < 8; bits++)
{
pBitmap.SetPixel(x, y, (data[row + col * (FontWidth + 7) / 8] & mask) == mask ? Color.Black : Color.White);
mask = mask >> 1;
x += 1;
}
}
x = 0;
y += 1;
}
}
請教各位大佬,是否有比較高效的方式實作。
uj5u.com熱心網友回復:
https://bbs.csdn.net/topics/396386834轉載請註明出處,本文鏈接:https://www.uj5u.com/net/39817.html
標籤:C#
下一篇:求解請撰寫代碼完成用戶登錄功能(登錄頁面名為Login.aspx,頁面控制元件名字自定義)并存盤用戶名到Cookie內
