リポジトリに置いてあるLMDGraphics.pasのTLMDIconクラスのサンプルプログラム。ドキュメントは書いてないので、使ってみたいという奇特な方はソースを読んでください。
フォームにImage1とButton1を置いて、Unit1.pasの中身は以下の通り。
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, LMDGraphics, StdCtrls, ExtCtrls; type TForm1 = class(TForm) Image1: TImage; Button1: TButton; procedure Button1Click(Sender: TObject); private { Private 宣言 } public { Public 宣言 } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var lmdicon: TLMDIcon; bmpoff: TBitmap; mydir: String; i: Integer; begin mydir := ExtractFilePath(Application.ExeName); lmdicon := TLMDIcon.Create; try { アイコンファイルの読み込み } lmdicon.LoadFromFile(mydir + 'sample_a.ico'); bmpoff := TBitmap.Create; { 背景画像をオフスクリーンバッファに読み込み } bmpoff.LoadFromFile(mydir + 'bg.bmp'); try { アイコンをオフスクリーンに描画 } for i := 0 to lmdicon.Count - 1 do begin DrawBitmap32Blending(lmdicon.ImageBitmap[i], lmdicon.MaskBitmap[i], i * 48, 0, bmpoff.Canvas.Handle); end; Image1.Canvas.Draw(0, 0, bmpoff); finally bmpoff.Free; end; finally lmdicon.Free; end; end; end.
このクラスでは、4/8/32bitのWindowsアイコンファイルに構造体レベルでアクセスが可能となっています。TIconとは互換性がありません。LMDGraphicsには、簡単なブレンド用の関数群が含まれています。WindowsXP以前のOSでも動作します。