LazMapViewer: Improved text rendering by IntfGraphicsDrawingEngine when text color is white

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9310 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz 2024-04-02 20:36:17 +00:00
parent fb42932f2e
commit 9fcf346d74
3 changed files with 14 additions and 9 deletions

View File

@ -38,9 +38,9 @@ object MainForm: TMainForm
Height = 662 Height = 662
Top = 0 Top = 0
Width = 275 Width = 275
ActivePage = PgData ActivePage = PgConfig
Align = alRight Align = alRight
TabIndex = 0 TabIndex = 2
TabOrder = 1 TabOrder = 1
object PgData: TTabSheet object PgData: TTabSheet
Caption = 'Data' Caption = 'Data'
@ -926,7 +926,7 @@ object MainForm: TMainForm
object BtnPOITextFont: TButton object BtnPOITextFont: TButton
AnchorSideTop.Control = CbShowPOIImage AnchorSideTop.Control = CbShowPOIImage
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 6 Left = 8
Height = 25 Height = 25
Top = 508 Top = 508
Width = 93 Width = 93
@ -943,10 +943,10 @@ object MainForm: TMainForm
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = CbDrawingEngine AnchorSideRight.Control = CbDrawingEngine
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 154 Left = 156
Height = 22 Height = 22
Top = 509 Top = 509
Width = 107 Width = 105
NoneColorColor = clWhite NoneColorColor = clWhite
Style = [cbStandardColors, cbExtendedColors, cbIncludeNone, cbCustomColor, cbPrettyNames, cbCustomColors] Style = [cbStandardColors, cbExtendedColors, cbIncludeNone, cbCustomColor, cbPrettyNames, cbCustomColors]
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
@ -960,7 +960,7 @@ object MainForm: TMainForm
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = BtnPOITextFont AnchorSideTop.Control = BtnPOITextFont
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 107 Left = 109
Height = 15 Height = 15
Top = 513 Top = 513
Width = 39 Width = 39

View File

@ -342,7 +342,10 @@ procedure TMainForm.BtnPOITextFontClick(Sender: TObject);
begin begin
FontDialog.Font.Assign(MapView.Font); FontDialog.Font.Assign(MapView.Font);
if FontDialog.Execute then if FontDialog.Execute then
begin
MapView.Font.Assign(FontDialog.Font); MapView.Font.Assign(FontDialog.Font);
MapView.Invalidate;
end;
end; end;
procedure TMainForm.CbDebugTilesChange(Sender: TObject); procedure TMainForm.CbDebugTilesChange(Sender: TObject);

View File

@ -239,7 +239,7 @@ begin
rawImg.Description.Init_BPP32_A8R8G8B8_BIO_TTB(AWidth, AHeight); rawImg.Description.Init_BPP32_A8R8G8B8_BIO_TTB(AWidth, AHeight);
{$ELSE} {$ELSE}
rawImg.Description.Init_BPP32_B8G8R8_BIO_TTB(AWidth, AHeight); rawImg.Description.Init_BPP32_B8G8R8_BIO_TTB(AWidth, AHeight);
// rawImg.Description.Init_BPP32_B8G8R8A8_BIO_TTB(AWidth, AHeight); // No alpha-channel for buffer image since it will be drawn on the MapView canvas.
{$ENDIF} {$ENDIF}
rawImg.CreateData(True); rawImg.CreateData(True);
ABuffer := TLazIntfImage.Create(rawImg, true); ABuffer := TLazIntfImage.Create(rawImg, true);
@ -261,7 +261,6 @@ var
intfImg: TLazIntfImage; intfImg: TLazIntfImage;
i, j, iX, jY: Integer; i, j, iX, jY: Integer;
cimg, cbuf: TFPColor; cimg, cbuf: TFPColor;
alpha: Double;
begin begin
intfImg := ABitmap.CreateIntfImage; intfImg := ABitmap.CreateIntfImage;
try try
@ -338,7 +337,10 @@ begin
begin begin
gray := CalculateGray(col); gray := CalculateGray(col);
col := opCol; col := opCol;
col.Alpha := $FFFF - gray; if SameColor(opCol, colWhite) then
col.Alpha := gray
else
col.Alpha := $FFFF - gray;
end; end;
FBuffer.Colors[iX, jY] := AlphaBlend(FBuffer.Colors[iX, jY], col); FBuffer.Colors[iX, jY] := AlphaBlend(FBuffer.Colors[iX, jY], col);
end; end;