📄 screendigits.~pas
字号:
// Create BMP and JPG (and optionally GIF) from string of digits.
//
// efg, November 2000
// www.efg2.com/Lab
//
// Requires LEDDIGITS bitmap in resource file assumed to have
// glyphs for digits 0..9 in that order. In the original case, the
// BMP is 150 pixels by 20 pixels.
//
// If you have TGIFImage from Anders Melander installed, define a
// conditional compilation variable GIF.
unit ScreenDigits;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, Spin, JPEG;
type
TFormDigits = class(TForm)
LabelBMP: TLabel;
ImageBMP: TImage;
LabelNumber: TLabel;
ImageJPG: TImage;
LabelJPG: TLabel;
LabelJPGSize: TLabel;
ImageGIF: TImage;
LabelGIF: TLabel;
LabelGIFSize: TLabel;
SpinEditDigits: TSpinEdit;
ImageAllDigits: TImage;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure SpinEditDigitsChange(Sender: TObject);
private
AllDigits : TBitmap;
DigitWidth: INTEGER;
public
{ Public declarations }
end;
var
FormDigits: TFormDigits;
implementation
{$R *.DFM}
procedure TFormDigits.FormCreate(Sender: TObject);
begin
AllDigits := TBitmap.Create;
//AllDigits.LoadFromResourceName(hInstance, 'LEDDIGITS');
AllDigits.LoadFromFile('aaa.bmp');
//AllDigits.Transparent := true;
//AllDigits.TransparentMode :=
DigitWidth := AllDigits.Width DIV 10;
ImageAllDigits.Picture.Graphic := AllDigits;
//SPinEditDigitsChange(Sender)
end;
procedure TFormDigits.FormDestroy(Sender: TObject);
begin
AllDigits.Free
end;
procedure TFormDigits.SpinEditDigitsChange(Sender: TObject);
VAR
Bitmap : TBitmap;
i1 : INTEGER;
i2 : INTEGER;
k : INTEGER;
MemoryStream: TMemoryStream;
Number : STRING;
c : INTEGER;
begin
TRY
Number := IntToStr(SpinEditDigits.Value);
EXCEPT
Number := ''
END;
LabelNumber.Caption := Number;
Bitmap := TBitmap.Create;
TRY
Bitmap.Height := AllDigits.Height;
Bitmap.Width := LENGTH(Number) * DigitWidth;
Bitmap.PixelFormat := AllDigits.PixelFormat;
FOR k := 1 TO LENGTH(Number) DO
BEGIN
i1 := (k-1) * DigitWidth ;
i2 := (ORD(Number[k]) - ORD('0')) * DigitWidth;
Bitmap.Canvas.CopyRect(Rect(i1,0, i1+DigitWidth,Bitmap.Height),
AllDigits.Canvas,
Rect(i2,0, i2+DigitWidth,Bitmap.Height));
END;
ImageBMP.Picture.Graphic := Bitmap;
sleep(50);
FINALLY
Bitmap.Free
END
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -