图标的颜色经两次异或后,为什么不会返回到原先的色彩?<我要实现当鼠标移动到图标时,图标有所变化>(100分)

  • 主题发起人 主题发起人 youou
  • 开始时间 开始时间
Y

youou

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TfrmDeskTop.ReDrawDeskIcon(var Icon: TIcon);
var
Bitmap, Mask: TBitmap;
x, y: integer;
Color: Longint;
R, G, B, Gr: byte;
ImageList: TImageList;
begin
Bitmap := TBitmap.Create;
Mask := TBitmap.Create;

ImageList := TImageList.CreateSize(32, 32);
ImageList.AddIcon(Icon);
ImageList.GetBitmap(0, Bitmap);//以上三行实现Ico到Bitmap的转换

with Bitmap.Canvas do
for x := Cliprect.Left to Cliprect.Right do
for y := Cliprect.Top to Cliprect.Bottom do
begin
Color := ColorToRGB(Pixels[x, y]);
B := (Color and $FF0000) shr 16;
G := (Color and $FF00) shr 8;
R := (Color and $FF);

B := B xor $FF;
G := G xor $FF;
R := R xor $FF;

Pixels[x, y] := (B shl 16 ) or ( G shl 8) or R;
end;
Mask.Assign(Bitmap);
ImageList.Height := Bitmap.Height;
ImageList.Width := Bitmap.Width;
ImageList.Clear;
ImageList.Add(Bitmap, Mask);
ImageList.GetIcon(0, Icon);//以上实现Bitmap到Ico的转换

ImageList.Free;
Bitmap.Free;
Mask.Free;
end;
=====================
调用这个过程后图标失真...........
大伙教教我该如何改...................谢谢..
 
晕...........如此冷清..?
 
procedure TfrmDeskTop.ReDrawDeskIconEx(Bmp: TBitmap);
var
x, y: integer;
Color: Longint;
R, G, B, Gr: byte;
ImageList: TImageList;
begin
with Bitmap.Canvas do
for x := Cliprect.Left to Cliprect.Right do
for y := Cliprect.Top to Cliprect.Bottom do
begin
Color := ColorToRGB(Pixels[x, y]);
B := (Color and $FF0000) shr 16;
G := (Color and $FF00) shr 8;
R := (Color and $FF);

B := B xor $FF;
G := G xor $FF;
R := R xor $FF;
Pixels[x, y] := (B shl 16 ) or ( G shl 8) or R;
end;//
end;
我传了Bitmap进去..MOUSE一一经过IMAGE图像就没了..:(
为什么/
 
后退
顶部