Skip to content

Commit

Permalink
Merge branch 'HtmlViewer-11.6-to-11.7' of [email protected]:BerndGabriel…
Browse files Browse the repository at this point in the history
…/HtmlViewer.git into HtmlViewer-11.6-to-11.7
  • Loading branch information
BerndGabriel committed Sep 19, 2016
2 parents 6cb30aa + 2dcbd8b commit a794197
Showing 1 changed file with 65 additions and 32 deletions.
97 changes: 65 additions & 32 deletions source/HtmlGlobals.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ function StartProcess(const ApplicationName, Params: string; ShowWindow: Word):
{$endif}
end;

{----------------ThtBitmap.GetMask:}
{ ThtBitmap }

function ThtBitmap.GetMask: TBitmap;
{This returns mask for frame 1. Content is black, background is white}
Expand All @@ -1240,7 +1240,11 @@ procedure ThtBitmap.SetTransparentMask(AValue: Boolean);
if not FTransparent then
FreeAndNil(FMask)
else if FMask = nil then
begin
FMask := ThtBitmap.Create;
FMask.TransparentMode := tmFixed;
FMask.TransparentColor := clNone;
end;
end;
end;

Expand All @@ -1250,8 +1254,6 @@ constructor ThtBitmap.Create(WithTransparentMask: Boolean);
SetTransparentMask( WithTransparentMask );
end;

{ ThtBitmap }

procedure ThtBitmap.Assign(Source: TPersistent);
var
htSource: ThtBitmap absolute Source;
Expand All @@ -1265,18 +1267,7 @@ procedure ThtBitmap.Assign(Source: TPersistent);
if Source is ThtBitmap then
begin
FTransparent := htSource.FTransparent;
if htSource.FMask = nil then
FreeAndNil(FMask)
else
begin
if FMask = nil then
begin
FMask := ThtBitmap.Create;
FMask.TransparentMode := tmFixed;
FMask.TransparentColor := clNone;
end;
FMask.Assign(htSource.FMask);
end
SetMask(htSource.FMask);
end;
end;

Expand All @@ -1286,11 +1277,11 @@ destructor ThtBitmap.Destroy;
inherited;
end;

{----------------ThtBitmap.Draw}

procedure ThtBitmap.SetMask(AValue: TBitmap);
begin
if FMask <> AValue then
if AValue = nil then
FreeAndNil(FMask)
else
begin
if FMask = nil then
begin
Expand All @@ -1303,6 +1294,33 @@ procedure ThtBitmap.SetMask(AValue: TBitmap);
end;

procedure ThtBitmap.Draw(ACanvas: TCanvas; const Rect: TRect);
{$ifdef LCL}
var
UseMaskHandle: HBitmap;
SrcDC: hDC;
DestDC: hDC;
begin
if (Width=0) or (Height=0)
then Exit;

BitmapHandleNeeded;
if not BitmapHandleAllocated then Exit;

if WithTransparentMask then
UseMaskHandle := FMask.Handle
else
UseMaskHandle := 0;

SrcDC := Canvas.GetUpdatedHandle([csHandleValid]);
ACanvas.Changing;
DestDC := ACanvas.GetUpdatedHandle([csHandleValid]);
StretchMaskBlt(
DestDC, Rect.Left, Rect.Top, Rect.Right - Rect.Left, Rect.Bottom - Rect.Top,
SrcDC, 0, 0, Width, Height,
UseMaskHandle, 0, 0, ACanvas.CopyMode);
ACanvas.Changed;
end;
{$else LCL}
var
OldPalette: HPalette;
RestorePalette: Boolean;
Expand Down Expand Up @@ -1334,7 +1352,6 @@ procedure ThtBitmap.Draw(ACanvas: TCanvas; const Rect: TRect);
else if not Monochrome then
SetStretchBltMode(ACanvas.Handle, STRETCH_DELETESCANS);
try
{$ifdef MSWindows}
if FTransparent then
TransparentStretchBlt(
ACanvas.Handle, Left, Top, Right - Left, Bottom - Top,
Expand All @@ -1345,21 +1362,43 @@ procedure ThtBitmap.Draw(ACanvas: TCanvas; const Rect: TRect);
ACanvas.Handle, Left, Top, Right - Left, Bottom - Top,
Canvas.Handle, 0, 0, Width, Height,
ACanvas.CopyMode);
{$else}
StretchBlt(
ACanvas.Handle, Left, Top, Right - Left, Bottom - Top,
Canvas.Handle, 0, 0, Width, Height,
ACanvas.CopyMode);
{$endif}
finally
if RestorePalette then
SelectPalette(ACanvas.Handle, OldPalette, True);
end;
end;
end;
{$endif LCL}

procedure ThtBitmap.StretchDraw(ACanvas: TCanvas; const DestRect, SrcRect: TRect);
{Draw parts of this bitmap on ACanvas}
{$ifdef LCL}
var
UseMaskHandle: HBitmap;
SrcDC: hDC;
DestDC: hDC;
begin
if (Width=0) or (Height=0)
then Exit;

BitmapHandleNeeded;
if not BitmapHandleAllocated then Exit;

if WithTransparentMask then
UseMaskHandle := FMask.Handle
else
UseMaskHandle := 0;

SrcDC := Canvas.GetUpdatedHandle([csHandleValid]);
ACanvas.Changing;
DestDC := ACanvas.GetUpdatedHandle([csHandleValid]);
StretchMaskBlt(
DestDC, DestRect.Left, DestRect.Top, DestRect.Right - DestRect.Left, DestRect.Bottom - DestRect.Top,
SrcDC, SrcRect.Left, SrcRect.Top, SrcRect.Right - SrcRect.Left, SrcRect.Bottom - SrcRect.Top,
UseMaskHandle, SrcRect.Left, SrcRect.Top, ACanvas.CopyMode);
ACanvas.Changed;
end;
{$else LCL}
var
OldPalette: HPalette;
RestorePalette: Boolean;
Expand Down Expand Up @@ -1391,7 +1430,6 @@ procedure ThtBitmap.StretchDraw(ACanvas: TCanvas; const DestRect, SrcRect: TRect
else if not Monochrome then
SetStretchBltMode(ACanvas.Handle, STRETCH_DELETESCANS);
try
{$ifdef MSWindows}
if FTransparent then
TransparentStretchBlt(
ACanvas.Handle, Left, Top, Right - Left, Bottom - Top,
Expand All @@ -1402,18 +1440,13 @@ procedure ThtBitmap.StretchDraw(ACanvas: TCanvas; const DestRect, SrcRect: TRect
ACanvas.Handle, Left, Top, Right - Left, Bottom - Top,
Canvas.Handle, SrcRect.Left, SrcRect.Top, SrcRect.Right - SrcRect.Left, SrcRect.Bottom - SrcRect.Top,
ACanvas.CopyMode);
{$else}
StretchBlt(
ACanvas.Handle, Left, Top, Right - Left, Bottom - Top,
Canvas.Handle, SrcRect.Left, SrcRect.Top, SrcRect.Right - SrcRect.Left, SrcRect.Bottom - SrcRect.Top,
ACanvas.CopyMode);
{$endif}
finally
if RestorePalette then
SelectPalette(ACanvas.Handle, OldPalette, True);
end;
end;
end;
{$endif LCL}

{ initialization }

Expand Down

0 comments on commit a794197

Please sign in to comment.