汉字变为点阵,很多字模软件都是这样做的,canvas 绘到stringgrid
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, DB, ADODB;
type
TForm1 = class(TForm)
Button1: TButton;
a: TStringGrid;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
b: TDrawGrid;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
i,j,dc:Integer;
c: Cardinal;
begin
dc := GetDC(handle);
form1.Canvas.Font.Name := Memo1.Font.Name;
form1.Canvas.Font.Size := Memo1.Font.Size;
form1.Canvas.TextOut(0,0,'汪浩');
a.Canvas.Pen.Color := rgb(255,0,0);
a.Canvas.Brush.Color:= rgb(255,0,0);
//memo1.Lines.Clear;
for i := 0 to 31 do
begin
//memo1.Lines.Add('');
for j := 0 to 31 do
begin
c := GetPixel(dc,j,i);
//Sleep(10);
//ShowMessage(IntToStr(c));
if c=0 then
begin
a.Canvas.FillRect(a.CellRect(j,i));
memo1.Lines := memo1.Lines+'*';
end
else
memo1.Lines := memo1.Lines+' ';
end;
end;
end;
end.