Subversion Repositories userdetect2

Compare Revisions

No changes between revisions

Regard whitespace Rev 93 → Rev 96

/trunk/vcl/VTSCompat.pas
9,10 → 9,12
uses
Dialogs, Windows, Controls, Graphics, SysUtils, CommDlg, Classes;
 
function AddTransparentIconToImageList(ImageList: TImageList; Icon: TIcon): integer;
function AddTransparentIconToImageList(ImageList: TImageList; Icon: TIcon; DoGreyscale: boolean=False): integer;
function CompatOpenDialogExecute(OpenDialog: TOpenDialog): boolean;
function CompatSaveDialogExecute(SaveDialog: TSaveDialog): boolean;
 
function ToGray(PixelColor: Longint): Longint;
 
implementation
 
uses
153,11 → 155,23
end;
end;
 
function AddTransparentIconToImageList(ImageList: TImageList; Icon: TIcon): integer;
function ToGray(PixelColor: Longint): Longint;
var
Red, Green, Blue, Gray: Byte;
begin
Red := PixelColor;
Green := PixelColor shr 8;
Blue := PixelColor shr 16;
Gray := Round(0.299 * Red + 0.587 * Green + 0.114 * Blue);
result := Gray + Gray shl 8 + Gray shl 16;
end;
 
function AddTransparentIconToImageList(ImageList: TImageList; Icon: TIcon; DoGreyscale: boolean=False): integer;
// http://www.delphipages.com/forum/showthread.php?t=183999
var
buffer, mask: TBitmap;
p: TPoint;
x, y: integer;
begin
// result := ImageList.AddIcon(ico);
// --> In Delphi 6, Icons with half-transparency have a black border (e.g. in ListView)
176,7 → 190,7
buffer.Transparent := true;
buffer.TransparentColor := buffer.Canvas.Pixels[0,0];
 
if (ImageList.Width <> p.X) or (ImageLIst.Height <> p.Y) then
if (ImageList.Width <> p.X) or (ImageList.Height <> p.Y) then
begin
ImageList.Width := p.X;
ImageList.Height := p.Y;
187,6 → 201,17
mask.Canvas.Brush.Color := buffer.Canvas.Pixels[0, buffer.Height -1];
mask.Monochrome := true;
 
if DoGreyscale then
begin
for x := 0 to buffer.Width - 1 do
begin
for y := 0 to buffer.Height - 1 do
begin
buffer.Canvas.Pixels[x, y] := ToGray(buffer.Canvas.Pixels[x, y]);
end;
end;
end;
 
result := ImageList.Add(buffer, mask);
finally
mask.Free;
/trunk/vcl/.
Property changes:
Modified: svn:ignore
*.local
*.identcache
*.stat
+__recovery