mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-09 19:16:12 +02:00
State image drawing:
- implement TRawImage.PerformEffect - use TRawImage.PerformEffect for State drawing of win32 imagelist (except disabled drawing in manifested exe - in this case os method used) - implement state drawing of default imagelist git-svn-id: trunk@12776 -
This commit is contained in:
parent
b5643a370c
commit
eb11482eee
@ -42,6 +42,13 @@ type
|
|||||||
fsBorder // fill this color (it fills only conneted pixels of this color)
|
fsBorder // fill this color (it fills only conneted pixels of this color)
|
||||||
);
|
);
|
||||||
TGraphicsBevelCut = (bvNone, bvLowered, bvRaised, bvSpace);
|
TGraphicsBevelCut = (bvNone, bvLowered, bvRaised, bvSpace);
|
||||||
|
TGraphicsDrawEffect =
|
||||||
|
(
|
||||||
|
gdeNormal, // no effect
|
||||||
|
gdeDisabled, // grayed image
|
||||||
|
gdeHighlighted, // a bit highlighted image
|
||||||
|
gdeShadowed // a bit shadowed image
|
||||||
|
);
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// raw image data
|
// raw image data
|
||||||
@ -173,6 +180,7 @@ type
|
|||||||
procedure ReleaseData;
|
procedure ReleaseData;
|
||||||
procedure ExtractRect(const ARect: TRect; out ADst: TRawImage);
|
procedure ExtractRect(const ARect: TRect; out ADst: TRawImage);
|
||||||
|
|
||||||
|
procedure PerformEffect(const ADrawEffect: TGraphicsDrawEffect; CreateNewData: Boolean = True);
|
||||||
function ReadBits(const APosition: TRawImagePosition; APrec, AShift: Byte): Word;
|
function ReadBits(const APosition: TRawImagePosition; APrec, AShift: Byte): Word;
|
||||||
procedure ReadChannels(const APosition: TRawImagePosition; out ARed, AGreen, ABlue, AAlpha: Word);
|
procedure ReadChannels(const APosition: TRawImagePosition; out ARed, AGreen, ABlue, AAlpha: Word);
|
||||||
procedure ReadMask(const APosition: TRawImagePosition; out AMask: Boolean);
|
procedure ReadMask(const APosition: TRawImagePosition; out AMask: Boolean);
|
||||||
@ -1403,6 +1411,75 @@ begin
|
|||||||
Description.MaskLineEnd, ADst.Mask, ADst.MaskSize);
|
Description.MaskLineEnd, ADst.Mask, ADst.MaskSize);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TRawImage.PerformEffect(const ADrawEffect: TGraphicsDrawEffect;
|
||||||
|
CreateNewData: Boolean);
|
||||||
|
const
|
||||||
|
GlowShadow = 48;
|
||||||
|
ColorMultiplier = (256 - GlowShadow) / 256;
|
||||||
|
var
|
||||||
|
AData: PRGBAQuad;
|
||||||
|
P: Pointer;
|
||||||
|
i, j: integer;
|
||||||
|
begin
|
||||||
|
if CreateNewData then
|
||||||
|
begin
|
||||||
|
GetMem(AData, DataSize);
|
||||||
|
Move(Data^, AData^, DataSize);
|
||||||
|
P := AData;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
P := Data;
|
||||||
|
AData := P;
|
||||||
|
end;
|
||||||
|
case ADrawEffect of
|
||||||
|
gdeNormal: ;
|
||||||
|
gdeDisabled:
|
||||||
|
begin
|
||||||
|
for i := 0 to Description.Height - 1 do
|
||||||
|
for j := 0 to Description.Width - 1 do
|
||||||
|
begin
|
||||||
|
with AData^ do
|
||||||
|
begin
|
||||||
|
Red := (Red + Green + Blue) div 3;
|
||||||
|
Green := Red;
|
||||||
|
Blue := Red;
|
||||||
|
end;
|
||||||
|
inc(AData);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
gdeHighlighted:
|
||||||
|
begin
|
||||||
|
for i := 0 to Description.Height - 1 do
|
||||||
|
for j := 0 to Description.Width - 1 do
|
||||||
|
begin
|
||||||
|
with AData^ do
|
||||||
|
begin
|
||||||
|
Red := Round(GlowShadow + Red * ColorMultiplier);
|
||||||
|
Green := Round(GlowShadow + Green * ColorMultiplier);
|
||||||
|
Blue := Round(GlowShadow + Blue * ColorMultiplier);
|
||||||
|
end;
|
||||||
|
inc(AData);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
gdeShadowed:
|
||||||
|
begin
|
||||||
|
for i := 0 to Description.Height - 1 do
|
||||||
|
for j := 0 to Description.Width - 1 do
|
||||||
|
begin
|
||||||
|
with AData^ do
|
||||||
|
begin
|
||||||
|
Red := Round(Red * ColorMultiplier);
|
||||||
|
Green := Round(Green * ColorMultiplier);
|
||||||
|
Blue := Round(Blue * ColorMultiplier);
|
||||||
|
end;
|
||||||
|
inc(AData);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
Data := P;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TRawImageLineStarts }
|
{ TRawImageLineStarts }
|
||||||
|
|
||||||
function TRawImageLineStarts.GetPosition(x, y: cardinal): TRawImagePosition;
|
function TRawImageLineStarts.GetPosition(x, y: cardinal): TRawImagePosition;
|
||||||
|
@ -110,13 +110,6 @@ type
|
|||||||
|
|
||||||
TDrawingStyle = (dsFocus, dsSelected, dsNormal, dsTransparent);
|
TDrawingStyle = (dsFocus, dsSelected, dsNormal, dsTransparent);
|
||||||
TImageType = (itImage, itMask);
|
TImageType = (itImage, itMask);
|
||||||
TImageListDrawEffect =
|
|
||||||
(
|
|
||||||
ideNormal, // no effect
|
|
||||||
ideDisabled, // grayed image
|
|
||||||
ideHighlighted, // a bit highlighted image
|
|
||||||
ideShadowed // a bit shadowed image
|
|
||||||
);
|
|
||||||
|
|
||||||
TCustomImageList = class(TLCLHandleComponent)
|
TCustomImageList = class(TLCLHandleComponent)
|
||||||
private
|
private
|
||||||
@ -201,9 +194,10 @@ type
|
|||||||
procedure Delete(AIndex: Integer);
|
procedure Delete(AIndex: Integer);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure Draw(ACanvas: TCanvas; AX, AY, AIndex: Integer; AEnabled: Boolean = True); overload;
|
procedure Draw(ACanvas: TCanvas; AX, AY, AIndex: Integer; AEnabled: Boolean = True); overload;
|
||||||
procedure Draw(ACanvas: TCanvas; AX, AY, AIndex: Integer; ADrawEffect: TImageListDrawEffect); overload;
|
procedure Draw(ACanvas: TCanvas; AX, AY, AIndex: Integer; ADrawEffect: TGraphicsDrawEffect); overload;
|
||||||
procedure FillDescription(out ADesc: TRawImageDescription);
|
procedure FillDescription(out ADesc: TRawImageDescription);
|
||||||
procedure GetBitmap(Index: Integer; Image: TBitmap);
|
procedure GetBitmap(Index: Integer; Image: TBitmap);
|
||||||
|
procedure GetRawImage(Index: Integer; out Image: TRawImage);
|
||||||
{$ifdef IMGLIST_KEEP_EXTRA}
|
{$ifdef IMGLIST_KEEP_EXTRA}
|
||||||
procedure GetInternalImage(Index: integer; var Image, Mask: TBitmap;
|
procedure GetInternalImage(Index: integer; var Image, Mask: TBitmap;
|
||||||
var ImageRect: TRect);
|
var ImageRect: TRect);
|
||||||
|
@ -46,7 +46,6 @@ begin
|
|||||||
);
|
);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TCustomImageList }
|
{ TCustomImageList }
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -547,17 +546,17 @@ end;
|
|||||||
procedure TCustomImageList.Draw(ACanvas: TCanvas; AX, AY, AIndex: Integer;
|
procedure TCustomImageList.Draw(ACanvas: TCanvas; AX, AY, AIndex: Integer;
|
||||||
AEnabled: Boolean);
|
AEnabled: Boolean);
|
||||||
const
|
const
|
||||||
EffectMap: array[Boolean] of TImageListDrawEffect =
|
EffectMap: array[Boolean] of TGraphicsDrawEffect =
|
||||||
(
|
(
|
||||||
ideDisabled,
|
gdeDisabled,
|
||||||
ideNormal
|
gdeNormal
|
||||||
);
|
);
|
||||||
begin
|
begin
|
||||||
Draw(ACanvas, AX, AY, AIndex, EffectMap[AEnabled]);
|
Draw(ACanvas, AX, AY, AIndex, EffectMap[AEnabled]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomImageList.Draw(ACanvas: TCanvas; AX, AY, AIndex: Integer;
|
procedure TCustomImageList.Draw(ACanvas: TCanvas; AX, AY, AIndex: Integer;
|
||||||
ADrawEffect: TImageListDrawEffect);
|
ADrawEffect: TGraphicsDrawEffect);
|
||||||
{$ifdef IMGLIST_OLDSTYLE}
|
{$ifdef IMGLIST_OLDSTYLE}
|
||||||
var
|
var
|
||||||
aBitmap: TBitmap;
|
aBitmap: TBitmap;
|
||||||
@ -642,11 +641,7 @@ begin
|
|||||||
{$ifdef IMGLIST_OLDSTYLE}
|
{$ifdef IMGLIST_OLDSTYLE}
|
||||||
Image.Assign(TBitMap(FImageList.Items[Index]));
|
Image.Assign(TBitMap(FImageList.Items[Index]));
|
||||||
{$else}
|
{$else}
|
||||||
CheckIndex(Index);
|
GetRawImage(Index, RawImg);
|
||||||
RawImg.Init;
|
|
||||||
FillDescription(RawImg.Description);
|
|
||||||
RawImg.DataSize := FWidth * FHeight * SizeOF(FData[0]);
|
|
||||||
RawImg.Data := @FData[Index * FWidth * FHeight];
|
|
||||||
|
|
||||||
if not RawImage_CreateBitmaps(RawImg, ImgHandle, MskHandle, True)
|
if not RawImage_CreateBitmaps(RawImg, ImgHandle, MskHandle, True)
|
||||||
then begin
|
then begin
|
||||||
@ -665,6 +660,16 @@ begin
|
|||||||
{$endif}
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomImageList.GetRawImage(Index: Integer; out Image: TRawImage);
|
||||||
|
begin
|
||||||
|
if (FCount = 0) then Exit;
|
||||||
|
CheckIndex(Index);
|
||||||
|
Image.Init;
|
||||||
|
FillDescription(Image.Description);
|
||||||
|
Image.DataSize := FWidth * FHeight * SizeOF(FData[0]);
|
||||||
|
Image.Data := @FData[Index * FWidth * FHeight];
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
procedure TCustomImageList.GetInternalImage(Index: integer; var Image,
|
procedure TCustomImageList.GetInternalImage(Index: integer; var Image,
|
||||||
Mask: TBitmap);
|
Mask: TBitmap);
|
||||||
|
@ -53,7 +53,7 @@ type
|
|||||||
class procedure Delete(AList: TCustomImageList; AIndex: Integer); override;
|
class procedure Delete(AList: TCustomImageList; AIndex: Integer); override;
|
||||||
class procedure DestroyHandle(AComponent: TComponent); override;
|
class procedure DestroyHandle(AComponent: TComponent); override;
|
||||||
class procedure Draw(AList: TCustomImageList; AIndex: Integer; ACanvas: TCanvas;
|
class procedure Draw(AList: TCustomImageList; AIndex: Integer; ACanvas: TCanvas;
|
||||||
ABounds: TRect; ABkColor, ABlendColor: TColor; ADrawEffect: TImageListDrawEffect; AStyle: TDrawingStyle; AImageType: TImageType); override;
|
ABounds: TRect; ABkColor, ABlendColor: TColor; ADrawEffect: TGraphicsDrawEffect; AStyle: TDrawingStyle; AImageType: TImageType); override;
|
||||||
class procedure Insert(AList: TCustomImageList; AIndex: Integer; AData: PRGBAQuad); override;
|
class procedure Insert(AList: TCustomImageList; AIndex: Integer; AData: PRGBAQuad); override;
|
||||||
class procedure Move(AList: TCustomImageList; ACurIndex, ANewIndex: Integer); override;
|
class procedure Move(AList: TCustomImageList; ACurIndex, ANewIndex: Integer); override;
|
||||||
class procedure Replace(AList: TCustomImageList; AIndex: Integer; AData: PRGBAQuad); override;
|
class procedure Replace(AList: TCustomImageList; AIndex: Integer; AData: PRGBAQuad); override;
|
||||||
@ -77,8 +77,6 @@ const
|
|||||||
{ itImage } ILD_NORMAL,
|
{ itImage } ILD_NORMAL,
|
||||||
{ itMask } ILD_MASK
|
{ itMask } ILD_MASK
|
||||||
);
|
);
|
||||||
var
|
|
||||||
GreyColorMap: array[0..255] of Cardinal;
|
|
||||||
|
|
||||||
function ColorToImagelistColor(AColor: TColor): DWord;
|
function ColorToImagelistColor(AColor: TColor): DWord;
|
||||||
begin
|
begin
|
||||||
@ -266,90 +264,65 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TWin32WSCustomImageList.Draw(AList: TCustomImageList; AIndex: Integer;
|
class procedure TWin32WSCustomImageList.Draw(AList: TCustomImageList; AIndex: Integer;
|
||||||
ACanvas: TCanvas; ABounds: TRect; ABkColor, ABlendColor: TColor; ADrawEffect: TImageListDrawEffect; AStyle: TDrawingStyle; AImageType: TImageType);
|
ACanvas: TCanvas; ABounds: TRect; ABkColor, ABlendColor: TColor; ADrawEffect: TGraphicsDrawEffect; AStyle: TDrawingStyle; AImageType: TImageType);
|
||||||
var
|
var
|
||||||
hdcGrey, hdcBW: HDC;
|
|
||||||
hbmOld1, hbmGrey, hbmOld2, hbmBW: HBitmap;
|
|
||||||
|
|
||||||
InfoGrey: record
|
|
||||||
Header: TBitmapInfoHeader;
|
|
||||||
Colors: array[0..255] of Cardinal;
|
|
||||||
end;
|
|
||||||
|
|
||||||
BitsGrey: PChar;
|
|
||||||
DrawParams: TImageListDrawParams;
|
DrawParams: TImageListDrawParams;
|
||||||
|
RawImg: TRawImage;
|
||||||
|
ListImg, DeviceImg: TLazIntfImage;
|
||||||
|
ImgHandle, MskHandle: HBitmap;
|
||||||
|
ABitmap: TBitmap;
|
||||||
begin
|
begin
|
||||||
if not WSCheckHandleAllocated(AList, 'Draw')
|
if not WSCheckHandleAllocated(AList, 'Draw')
|
||||||
then Exit;
|
then Exit;
|
||||||
|
|
||||||
if ADrawEffect <> ideDisabled then
|
if ADrawEffect = gdeNormal then
|
||||||
begin
|
begin
|
||||||
ImageList_DrawEx(HImageList(AList.Handle), AIndex, ACanvas.Handle, ABounds.Left,
|
ImageList_DrawEx(HImageList(AList.Handle), AIndex, ACanvas.Handle, ABounds.Left,
|
||||||
ABounds.Top, ABounds.Right, ABounds.Bottom, ColorToImagelistColor(ABkColor),
|
ABounds.Top, ABounds.Right, ABounds.Bottom, ColorToImagelistColor(ABkColor),
|
||||||
ColorToImagelistColor(ABlendColor), DRAWINGSTYLEMAP[AStyle] or IMAGETPYEMAP[AImageType])
|
ColorToImagelistColor(ABlendColor), DRAWINGSTYLEMAP[AStyle] or IMAGETPYEMAP[AImageType]);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if (ADrawEffect = gdeDisabled) and (Win32WidgetSet.CommonControlsVersion >= ComCtlVersionIE6) then
|
||||||
|
begin
|
||||||
|
// if it is manifested exe then use winXP algoriphm of gray painting
|
||||||
|
FillChar(DrawParams, SizeOf(DrawParams), 0);
|
||||||
|
DrawParams.cbSize := SizeOf(DrawParams);
|
||||||
|
DrawParams.himlL := HImageList(AList.Handle);
|
||||||
|
DrawParams.i := AIndex;
|
||||||
|
DrawParams.hdcDst := ACanvas.Handle;
|
||||||
|
DrawParams.x := ABounds.Left;
|
||||||
|
DrawParams.y := ABounds.Top;
|
||||||
|
DrawParams.cx := ABounds.Right;
|
||||||
|
DrawParams.cy := ABounds.Bottom;
|
||||||
|
DrawParams.rgbBk := ColorToImagelistColor(ABkColor);
|
||||||
|
DrawParams.rgbFg := ColorToImagelistColor(ABlendColor);
|
||||||
|
DrawParams.fStyle := DRAWINGSTYLEMAP[AStyle] or IMAGETPYEMAP[AImageType];
|
||||||
|
DrawParams.fState := ILS_SATURATE; // draw greyed
|
||||||
|
ImageList_DrawIndirect(@DrawParams);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
// at moment only Disabled state is implemented
|
// use RawImage_PerformEffect to perform drawing effect
|
||||||
if (Win32WidgetSet.CommonControlsVersion >= ComCtlVersionIE6) then
|
AList.GetRawImage(AIndex, RawImg);
|
||||||
begin
|
RawImg.PerformEffect(ADrawEffect, True);
|
||||||
FillChar(DrawParams, SizeOf(DrawParams), 0);
|
|
||||||
DrawParams.cbSize := SizeOf(DrawParams);
|
ABitmap := TBitmap.Create;
|
||||||
DrawParams.himlL := HImageList(AList.Handle);
|
if not Widgetset.RawImage_CreateBitmaps(RawImg, ImgHandle, MskHandle, True)
|
||||||
DrawParams.i := AIndex;
|
then begin
|
||||||
DrawParams.hdcDst := ACanvas.Handle;
|
// bummer, the widgetset doesn't support our 32bit format, try device
|
||||||
DrawParams.x := ABounds.Left;
|
ListImg := TLazIntfImage.Create(RawImg, False);
|
||||||
DrawParams.y := ABounds.Top;
|
DeviceImg := TLazIntfImage.Create(0, 0);
|
||||||
DrawParams.cx := ABounds.Right;
|
DeviceImg.DataDescription := GetDescriptionFromDevice(0, AList.Width, AList.Height);
|
||||||
DrawParams.cy := ABounds.Bottom;
|
DeviceImg.CopyPixels(ListImg);
|
||||||
DrawParams.rgbBk := ColorToImagelistColor(ABkColor);
|
DeviceImg.GetRawImage(RawImg);
|
||||||
DrawParams.rgbFg := ColorToImagelistColor(ABlendColor);
|
Widgetset.RawImage_CreateBitmaps(RawImg, ImgHandle, MskHandle);
|
||||||
DrawParams.fStyle := DRAWINGSTYLEMAP[AStyle] or IMAGETPYEMAP[AImageType];
|
DeviceImg.Free;
|
||||||
DrawParams.fState := ILS_SATURATE; // draw greyed
|
ListImg.Free;
|
||||||
ImageList_DrawIndirect(@DrawParams);
|
|
||||||
end else
|
|
||||||
begin
|
|
||||||
hdcGrey := CreateCompatibleDC(ACanvas.Handle);
|
|
||||||
hdcBW := CreateCompatibleDC(ACanvas.Handle);
|
|
||||||
|
|
||||||
// create grey bitmap
|
|
||||||
FillChar(InfoGrey, sizeof(InfoGrey), 0);
|
|
||||||
InfoGrey.Header.biSize := sizeof(InfoGrey.Header);
|
|
||||||
InfoGrey.Header.biWidth := AList.Width;
|
|
||||||
InfoGrey.Header.biHeight := AList.Height;
|
|
||||||
InfoGrey.Header.biPlanes := 1;
|
|
||||||
InfoGrey.Header.biBitCount := 8;
|
|
||||||
InfoGrey.Header.biCompression := BI_RGB;
|
|
||||||
// fill color table
|
|
||||||
System.Move(GreyColorMap, InfoGrey.Colors, 256 * SizeOf(Cardinal));
|
|
||||||
hbmGrey := CreateDIBSection(hdcGrey, Windows.PBitmapInfo(@InfoGrey)^, DIB_RGB_COLORS, BitsGrey, 0, 0);
|
|
||||||
|
|
||||||
hbmBW := CreateBitmap(AList.Width, AList.Height, 1, 0, nil);
|
|
||||||
|
|
||||||
hbmOld1 := SelectObject(hdcGrey, hbmGrey);
|
|
||||||
hbmOld2 := SelectObject(hdcBW, hbmBW);
|
|
||||||
|
|
||||||
// draw to greyDC
|
|
||||||
ImageList_DrawEx(HImageList(AList.Handle), AIndex, hdcGrey, 0,
|
|
||||||
0, ABounds.Right, ABounds.Bottom, ColorToImagelistColor(ABkColor),
|
|
||||||
ColorToImagelistColor(ABlendColor), ILD_NORMAL);
|
|
||||||
// draw to bwDC
|
|
||||||
ImageList_DrawEx(HImageList(AList.Handle), AIndex, hdcBW, 0,
|
|
||||||
0, ABounds.Right, ABounds.Bottom, clBlack,
|
|
||||||
clWhite, ILD_MASK);
|
|
||||||
|
|
||||||
// draw grey
|
|
||||||
BitBlt(ACanvas.Handle, ABounds.Left, ABounds.Top, ABounds.Right,
|
|
||||||
ABounds.Bottom, hdcGrey, 0, 0, SRCCOPY);
|
|
||||||
// mask
|
|
||||||
BitBlt(ACanvas.Handle, ABounds.Left, ABounds.Top, ABounds.Right,
|
|
||||||
ABounds.Bottom, hdcBW, 0, 0, SRCINVERT);
|
|
||||||
|
|
||||||
DeleteObject(SelectObject(hdcBW, hbmOld2));
|
|
||||||
DeleteDC(hdcBW);
|
|
||||||
DeleteObject(SelectObject(hdcGrey, hbmOld1));
|
|
||||||
DeleteDC(hdcGrey);
|
|
||||||
end;
|
end;
|
||||||
|
ABitmap.SetHandles(ImgHandle, MskHandle);
|
||||||
|
ACanvas.Draw(ABounds.Left, ABounds.Top, ABitmap);
|
||||||
|
ABitmap.Free;
|
||||||
|
FreeMem(RawImg.Data);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -413,16 +386,7 @@ begin
|
|||||||
then AddData(ImageList, 1, AIndex, AList.Width, AList.Height, AData);
|
then AddData(ImageList, 1, AIndex, AList.Width, AList.Height, AData);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure InitGreyColormap;
|
|
||||||
var
|
|
||||||
i: Cardinal;
|
|
||||||
begin
|
|
||||||
for i := 0 to 255 do
|
|
||||||
GreyColorMap[i] := $FF000000 or (i shl 16) or (i shl 8) or i;
|
|
||||||
end;
|
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
InitGreyColormap;
|
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
// I M P O R T A N T
|
// I M P O R T A N T
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
|
@ -40,7 +40,7 @@ interface
|
|||||||
// the uses clause of the XXXintf.pp
|
// the uses clause of the XXXintf.pp
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
uses
|
uses
|
||||||
Classes, Contnrs, GraphType, Graphics, ImgList, LCLType, LCLIntf,
|
Classes, Contnrs, GraphType, Graphics, IntfGraphics, ImgList, LCLType, LCLIntf,
|
||||||
WSLCLClasses, WSProc;
|
WSLCLClasses, WSProc;
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -54,7 +54,7 @@ type
|
|||||||
class procedure Delete(AList: TCustomImageList; AIndex: Integer); virtual;
|
class procedure Delete(AList: TCustomImageList; AIndex: Integer); virtual;
|
||||||
class procedure DestroyHandle(AComponent: TComponent); override;
|
class procedure DestroyHandle(AComponent: TComponent); override;
|
||||||
class procedure Draw(AList: TCustomImageList; AIndex: Integer; ACanvas: TCanvas;
|
class procedure Draw(AList: TCustomImageList; AIndex: Integer; ACanvas: TCanvas;
|
||||||
ABounds: TRect; ABkColor, ABlendColor: TColor; ADrawEffect: TImageListDrawEffect; AStyle: TDrawingStyle; AImageType: TImageType); virtual;
|
ABounds: TRect; ABkColor, ABlendColor: TColor; ADrawEffect: TGraphicsDrawEffect; AStyle: TDrawingStyle; AImageType: TImageType); virtual;
|
||||||
|
|
||||||
class procedure Insert(AList: TCustomImageList; AIndex: Integer; AData: PRGBAQuad); virtual;
|
class procedure Insert(AList: TCustomImageList; AIndex: Integer; AData: PRGBAQuad); virtual;
|
||||||
|
|
||||||
@ -74,27 +74,56 @@ type
|
|||||||
private
|
private
|
||||||
FWidth: Integer;
|
FWidth: Integer;
|
||||||
FHeight: Integer;
|
FHeight: Integer;
|
||||||
|
FList: TCustomImageList;
|
||||||
public
|
public
|
||||||
constructor Create(AWidth, AHeight: Integer); reintroduce;
|
constructor Create(AList: TCustomImageList); reintroduce;
|
||||||
procedure Draw(AIndex: Integer; ACanvas: TCanvas; ABounds: TRect; ADrawEffect: TImageListDrawEffect; AStyle: TDrawingStyle);
|
procedure Draw(AIndex: Integer; ACanvas: TCanvas; ABounds: TRect; ADrawEffect: TGraphicsDrawEffect; AStyle: TDrawingStyle);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TDefaultImageListImplementor }
|
{ TDefaultImageListImplementor }
|
||||||
|
|
||||||
constructor TDefaultImageListImplementor.Create(AWidth, AHeight: Integer);
|
constructor TDefaultImageListImplementor.Create(AList: TCustomImageList);
|
||||||
begin
|
begin
|
||||||
inherited Create(True);
|
inherited Create(True);
|
||||||
FWidth := AWidth;
|
FList := AList;
|
||||||
FHeight := AHeight;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDefaultImageListImplementor.Draw(AIndex: Integer; ACanvas: TCanvas;
|
procedure TDefaultImageListImplementor.Draw(AIndex: Integer; ACanvas: TCanvas;
|
||||||
ABounds: TRect; ADrawEffect: TImageListDrawEffect; AStyle: TDrawingStyle);
|
ABounds: TRect; ADrawEffect: TGraphicsDrawEffect; AStyle: TDrawingStyle);
|
||||||
var
|
var
|
||||||
Bitmap: TBitmap;
|
ABitmap: TBitmap;
|
||||||
|
RawImg: TRawImage;
|
||||||
|
ListImg, DeviceImg: TLazIntfImage;
|
||||||
|
ImgHandle, MskHandle: HBitmap;
|
||||||
begin
|
begin
|
||||||
Bitmap := TBitmap(Items[AIndex]);
|
if ADrawEffect = gdeNormal then
|
||||||
ACanvas.Draw(ABounds.Left, ABounds.Top, Bitmap);
|
begin
|
||||||
|
ABitmap := TBitmap(Items[AIndex]);
|
||||||
|
ACanvas.Draw(ABounds.Left, ABounds.Top, ABitmap);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
FList.GetRawImage(AIndex, RawImg);
|
||||||
|
RawImg.PerformEffect(ADrawEffect, True);
|
||||||
|
|
||||||
|
ABitmap := TBitmap.Create;
|
||||||
|
if not RawImage_CreateBitmaps(RawImg, ImgHandle, MskHandle, True)
|
||||||
|
then begin
|
||||||
|
// bummer, the widgetset doesn't support our 32bit format, try device
|
||||||
|
ListImg := TLazIntfImage.Create(RawImg, False);
|
||||||
|
DeviceImg := TLazIntfImage.Create(0, 0);
|
||||||
|
DeviceImg.DataDescription := GetDescriptionFromDevice(0, FList.Width, FList.Height);
|
||||||
|
DeviceImg.CopyPixels(ListImg);
|
||||||
|
DeviceImg.GetRawImage(RawImg);
|
||||||
|
RawImage_CreateBitmaps(RawImg, ImgHandle, MskHandle);
|
||||||
|
DeviceImg.Free;
|
||||||
|
ListImg.Free;
|
||||||
|
end;
|
||||||
|
ABitmap.SetHandles(ImgHandle, MskHandle);
|
||||||
|
ACanvas.Draw(ABounds.Left, ABounds.Top, ABitmap);
|
||||||
|
ABitmap.Free;
|
||||||
|
FreeMem(RawImg.Data);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function InternalCreateBitmap(AList: TCustomImageList; AWidth, AHeight: Integer; AData: PRGBAQuad): TBitmap;
|
function InternalCreateBitmap(AList: TCustomImageList; AWidth, AHeight: Integer; AData: PRGBAQuad): TBitmap;
|
||||||
@ -129,7 +158,7 @@ var
|
|||||||
ABitmap: TBitmap;
|
ABitmap: TBitmap;
|
||||||
i: integer;
|
i: integer;
|
||||||
begin
|
begin
|
||||||
Result := TLCLIntfHandle(TDefaultImageListImplementor.Create(AWidth, AHeight));
|
Result := TLCLIntfHandle(TDefaultImageListImplementor.Create(AList));
|
||||||
|
|
||||||
if AData <> nil then
|
if AData <> nil then
|
||||||
begin
|
begin
|
||||||
@ -158,7 +187,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TWSCustomImageList.Draw(AList: TCustomImageList; AIndex: Integer;
|
class procedure TWSCustomImageList.Draw(AList: TCustomImageList; AIndex: Integer;
|
||||||
ACanvas: TCanvas; ABounds: TRect; ABkColor, ABlendColor: TColor; ADrawEffect: TImageListDrawEffect; AStyle: TDrawingStyle; AImageType: TImageType);
|
ACanvas: TCanvas; ABounds: TRect; ABkColor, ABlendColor: TColor; ADrawEffect: TGraphicsDrawEffect; AStyle: TDrawingStyle; AImageType: TImageType);
|
||||||
begin
|
begin
|
||||||
if not WSCheckHandleAllocated(AList, 'Draw')
|
if not WSCheckHandleAllocated(AList, 'Draw')
|
||||||
then Exit;
|
then Exit;
|
||||||
|
Loading…
Reference in New Issue
Block a user