我使用D2007和TcxButton来处理来自Devexpress的字形图像,但是对于任何图像都应该是相同的。这个按钮有两个状态,在第二个状态上,我想在原始图像上画一个覆盖。在这个例子中,我有一个名为Main的Imagelist。主图像存储在索引0上,覆盖存储在索引1上。
procedure TForm6.CheckBox1Click(Sender: TObject);
var
vBm: TBitMap;
vOverlay: TOverLay;
begin
if Main.GetBitmap(0, vBm) then
begin
vOverlay := 1;
if CheckBox1.Checked then
begin
// procedure DrawOverlay(Canvas: TCanvas; X, Y: Integer; ImageIndex: Integer; Overlay: TOverlay; Enabled: Boolean = True); overload;
Main.DrawOverlay(vBm.Canvas, 0, 0, vOverlay, True);
end
else
begin
Main.DrawOverlay(vBm.Canvas, 0, 0, vOverlay, False);
end;
end;
end;所以我假设主图像和叠加必须在同一个图像列表中?现在它甚至不编译,我有
version Unit6.pas(41):E2250没有重载版本的“DrawOverlay”可以用这些参数调用
编辑:
尝试了建议的解决方案。它编译了,但什么也没发生。下面是指向项目https://www.dropbox.com/sh/tk5n7frkbveyxbz/D1O4Ags9fS/Overlay的链接
发布于 2013-05-03 07:22:30
在与GetBitmap一起使用位图之前,您必须创建一个位图。
您必须使用覆盖为列表中的一个图像指定一个覆盖索引。
var
vBm: TBitMap;
vOverlay: TOverLay;
begin
vBm:= TBitMap.Create; // create Bitmap before using GetBitmap
try
if Main.GetBitmap(0, vBm) then // can be done but will be painted over by DrawOverlay
begin
vOverlay := 1; // use eg. 1 of the possible 4 indices (0..3)
Main.Overlay(1,vOverlay); // define second image in List to overlay index 1 to enable it as overlay image
if CheckBox1.Checked then
begin
Main.DrawOverlay(vBm.Canvas, 0, 0, 0 , vOverlay, True);
end
else
begin
Main.DrawOverlay(vBm.Canvas, 0, 0,0, vOverlay, False);
end;
//TheButton.Glyph.Assign(vBm);
end;
finally
vBm.Free;
end;
end;https://stackoverflow.com/questions/16353056
复制相似问题