mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-29 10:52:22 +02:00
lcl:
- MaskHandleNeeded create default mask now if TransparentMode = tmAuto and mask by color in case of TransparentMode = tmFixed - BitmapHandleNeeded does not create mask if TransparentMode = tmFixed or MaskHandle is already present This fixes some issues with changing of TransparentColor. git-svn-id: trunk@16250 -
This commit is contained in:
parent
1d49dbafe7
commit
397d98136b
@ -152,6 +152,8 @@ type
|
||||
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
constructor CreateSize(AWidth, AHeight: Integer);
|
||||
destructor Destroy; override;
|
||||
|
||||
procedure AssignTo(Dest: TPersistent); override;
|
||||
procedure Assign(Source: TPersistent); override;
|
||||
@ -167,11 +169,7 @@ type
|
||||
function AddLazarusResource(const ResourceName: string; MaskColor: TColor = clNone): integer;
|
||||
procedure Change;
|
||||
procedure Clear;
|
||||
{.$ifdef IMGLIST_KEEP_EXTRA}
|
||||
constructor CreateSize(AWidth, AHeight: Integer);
|
||||
{.$endif}
|
||||
procedure Delete(AIndex: Integer);
|
||||
destructor Destroy; override;
|
||||
procedure Draw(ACanvas: TCanvas; AX, AY, AIndex: Integer; AEnabled: Boolean = True); overload;
|
||||
procedure Draw(ACanvas: TCanvas; AX, AY, AIndex: Integer; ADrawEffect: TGraphicsDrawEffect); overload;
|
||||
procedure FillDescription(out ADesc: TRawImageDescription);
|
||||
|
@ -114,35 +114,38 @@ begin
|
||||
if FMaskHandle <> 0 then Exit;
|
||||
if not Masked then Exit;
|
||||
|
||||
if not BitmapHandleAllocated
|
||||
then BitmapHandleNeeded; // create together with bitmaphandle
|
||||
if FMaskHandle <> 0 then Exit;
|
||||
if TransparentMode = tmAuto then
|
||||
begin
|
||||
if not BitmapHandleAllocated
|
||||
then BitmapHandleNeeded; // create together with bitmaphandle
|
||||
|
||||
ImagePtr := GetRawImagePtr;
|
||||
if ImagePtr^.Description.Format = ricfNone then Exit;
|
||||
if FMaskHandle <> 0 then Exit;
|
||||
ImagePtr := GetRawImagePtr;
|
||||
if ImagePtr^.Description.Format = ricfNone then Exit;
|
||||
|
||||
// check if we have mask data
|
||||
if (ImagePtr^.Description.MaskBitsPerPixel <> 0)
|
||||
and (ImagePtr^.Mask <> nil)
|
||||
and (ImagePtr^.MaskSize <> 0)
|
||||
then begin
|
||||
// move mask to image data, so we only have to create one handle
|
||||
// (and don't have to think about imahehandle format)
|
||||
|
||||
MaskImage.Description := ImagePtr^.Description.GetDescriptionFromMask;
|
||||
MaskImage.DataSize := ImagePtr^.MaskSize;
|
||||
MaskImage.Data := ImagePtr^.Mask;
|
||||
|
||||
if RawImage_CreateBitmaps(MaskImage, msk, dummy, False)
|
||||
// check if we have mask data
|
||||
if (ImagePtr^.Description.MaskBitsPerPixel <> 0)
|
||||
and (ImagePtr^.Mask <> nil)
|
||||
and (ImagePtr^.MaskSize <> 0)
|
||||
then begin
|
||||
if BitmapHandleAllocated
|
||||
then UpdateHandles(BitmapHandle, msk)
|
||||
else UpdateHandles(0, msk);
|
||||
Exit;
|
||||
// move mask to image data, so we only have to create one handle
|
||||
// (and don't have to think about imahehandle format)
|
||||
|
||||
MaskImage.Description := ImagePtr^.Description.GetDescriptionFromMask;
|
||||
MaskImage.DataSize := ImagePtr^.MaskSize;
|
||||
MaskImage.Data := ImagePtr^.Mask;
|
||||
|
||||
if RawImage_CreateBitmaps(MaskImage, msk, dummy, False)
|
||||
then begin
|
||||
if BitmapHandleAllocated
|
||||
then UpdateHandles(BitmapHandle, msk)
|
||||
else UpdateHandles(0, msk);
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
// no data, create ourselves
|
||||
// no data or transparent color is set - create ourselves
|
||||
CreateMask;
|
||||
end;
|
||||
|
||||
|
@ -175,6 +175,7 @@ var
|
||||
SrcImage, DstImage: TLazIntfImage;
|
||||
QueryFlags: TRawImageQueryFlags;
|
||||
W, H: Integer;
|
||||
SkipMask: Boolean;
|
||||
begin
|
||||
if BitmapHandleAllocated then exit;
|
||||
|
||||
@ -224,13 +225,29 @@ begin
|
||||
end;
|
||||
|
||||
try
|
||||
if not RawImage_CreateBitmaps(ImagePtr^, ImgHandle, ImgMaskHandle, DevDesc.MaskBitsPerPixel = 0)
|
||||
// we must skip mask creation if
|
||||
// a) we already have mask
|
||||
// b) mask needs to be created another way - using TransparentColor
|
||||
// c) we dont have mask in the description
|
||||
SkipMask := MaskHandleAllocated or
|
||||
(TransparentMode = tmFixed) or
|
||||
(DevDesc.MaskBitsPerPixel = 0);
|
||||
if not RawImage_CreateBitmaps(ImagePtr^, ImgHandle, ImgMaskHandle, SkipMask)
|
||||
then begin
|
||||
DebugLn('TRasterImage.BitmapHandleNeeded: Unable to create handles, using default');
|
||||
// create a default handle
|
||||
ImgHandle := CreateDefaultBitmapHandle(DevDesc);
|
||||
end;
|
||||
UpdateHandles(ImgHandle, ImgMaskHandle);
|
||||
|
||||
if SkipMask
|
||||
then begin
|
||||
// if we dont have new mask then either use old one or use none
|
||||
if MaskHandleAllocated
|
||||
then UpdateHandles(ImgHandle, MaskHandle)
|
||||
else UpdateHandles(ImgHandle, 0);
|
||||
end
|
||||
else UpdateHandles(ImgHandle, ImgMaskHandle);
|
||||
|
||||
finally
|
||||
DstImage.Free;
|
||||
end;
|
||||
|
@ -698,7 +698,7 @@ begin
|
||||
then Exit(False);
|
||||
|
||||
//DbgDumpBitmap(ABitmap, 'FromBitmap - Image');
|
||||
//DbgDumpBitmap(AMask, 'FromBitmap - Mask');
|
||||
//DbgDumpBitmap(AMask, 'FromMask - Mask');
|
||||
|
||||
FillRawImageDescription(WinBmp, ARawImage.Description);
|
||||
// if it is not DIB then alpha in bitmaps is not supported => use 0 alpha prec
|
||||
|
Loading…
Reference in New Issue
Block a user