LazMapViewer: Improved text rendering by IntfGraphicsDrawingEngine
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9309 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
2f00c05ab1
commit
fb42932f2e
@ -448,13 +448,14 @@ object MainForm: TMainForm
|
|||||||
AnchorSideRight.Control = GbSearch
|
AnchorSideRight.Control = GbSearch
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 4
|
Left = 4
|
||||||
Height = 70
|
Height = 92
|
||||||
Top = 364
|
Top = 364
|
||||||
Width = 259
|
Width = 259
|
||||||
Anchors = [akTop, akLeft, akRight]
|
Anchors = [akTop, akLeft, akRight]
|
||||||
|
AutoSize = True
|
||||||
BorderSpacing.Top = 6
|
BorderSpacing.Top = 6
|
||||||
Caption = 'GPS points'
|
Caption = 'GPS points'
|
||||||
ClientHeight = 50
|
ClientHeight = 72
|
||||||
ClientWidth = 255
|
ClientWidth = 255
|
||||||
TabOrder = 6
|
TabOrder = 6
|
||||||
object BtnGPSPoints: TButton
|
object BtnGPSPoints: TButton
|
||||||
@ -498,7 +499,7 @@ object MainForm: TMainForm
|
|||||||
AnchorSideBottom.Control = GbGPS
|
AnchorSideBottom.Control = GbGPS
|
||||||
AnchorSideBottom.Side = asrBottom
|
AnchorSideBottom.Side = asrBottom
|
||||||
Left = 6
|
Left = 6
|
||||||
Height = 0
|
Height = 15
|
||||||
Top = 57
|
Top = 57
|
||||||
Width = 245
|
Width = 245
|
||||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||||
@ -516,7 +517,7 @@ object MainForm: TMainForm
|
|||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
Left = 4
|
Left = 4
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 440
|
Top = 462
|
||||||
Width = 110
|
Width = 110
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
BorderSpacing.Top = 6
|
BorderSpacing.Top = 6
|
||||||
@ -530,7 +531,7 @@ object MainForm: TMainForm
|
|||||||
AnchorSideTop.Control = BtnSaveToFile
|
AnchorSideTop.Control = BtnSaveToFile
|
||||||
Left = 120
|
Left = 120
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 440
|
Top = 462
|
||||||
Width = 105
|
Width = 105
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
BorderSpacing.Left = 6
|
BorderSpacing.Left = 6
|
||||||
@ -546,7 +547,7 @@ object MainForm: TMainForm
|
|||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 4
|
Left = 4
|
||||||
Height = 26
|
Height = 26
|
||||||
Top = 471
|
Top = 493
|
||||||
Width = 110
|
Width = 110
|
||||||
Anchors = [akTop, akLeft, akRight]
|
Anchors = [akTop, akLeft, akRight]
|
||||||
BorderSpacing.Top = 6
|
BorderSpacing.Top = 6
|
||||||
|
@ -364,7 +364,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.cbCyclicViewChange(Sender: TObject);
|
procedure TMainForm.cbCyclicViewChange(Sender: TObject);
|
||||||
|
@ -279,15 +279,6 @@ begin
|
|||||||
cimg := intfImg.Colors[i, j];
|
cimg := intfImg.Colors[i, j];
|
||||||
cbuf := FBuffer.Colors[iX, jY];
|
cbuf := FBuffer.Colors[iX, jY];
|
||||||
FBuffer.Colors[iX, jY] := AlphaBlend(cbuf, cimg);
|
FBuffer.Colors[iX, jY] := AlphaBlend(cbuf, cimg);
|
||||||
{
|
|
||||||
alpha := cimg.Alpha / word($FFFF);
|
|
||||||
if InRange(i + X, 0, FBuffer.Width-1) then begin
|
|
||||||
cbuf := FBuffer.Colors[i + X, j + Y];
|
|
||||||
cbuf.Red := Round(alpha * cimg.Red + (1 - alpha) * cbuf.Red);
|
|
||||||
cbuf.Green := Round(alpha * cimg.Green + (1 - alpha) * cbuf.Green);
|
|
||||||
cbuf.Blue := Round(alpha * cimg.Blue + (1 - alpha) * cbuf.Blue);
|
|
||||||
FBuffer.Colors[i + X, j + Y] := cbuf;
|
|
||||||
}
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -328,7 +319,6 @@ begin
|
|||||||
|
|
||||||
img := ABitmap.CreateIntfImage;
|
img := ABitmap.CreateIntfImage;
|
||||||
try
|
try
|
||||||
img.SetSize(ABitmap.Width, ABitmap.Height);
|
|
||||||
for j := 0 to img.Height - 1 do
|
for j := 0 to img.Height - 1 do
|
||||||
begin
|
begin
|
||||||
jY := j + Y;
|
jY := j + Y;
|
||||||
@ -339,15 +329,15 @@ begin
|
|||||||
if InRange(iX, 0, FBuffer.Width-1) then
|
if InRange(iX, 0, FBuffer.Width-1) then
|
||||||
begin
|
begin
|
||||||
col := img.Colors[i, j];
|
col := img.Colors[i, j];
|
||||||
col.Alpha := 0;
|
|
||||||
if SameColor(col, trCol) then
|
if SameColor(col, trCol) then
|
||||||
col.Alpha := alphaTransparent
|
col.Alpha := AlphaTransparent
|
||||||
else
|
else
|
||||||
if SameColor(col, opCol) then
|
if SameColor(col, opCol) then
|
||||||
col.Alpha := alphaOpaque
|
col.Alpha := AlphaOpaque
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
gray := CalculateGray(col);
|
gray := CalculateGray(col);
|
||||||
|
col := opCol;
|
||||||
col.Alpha := $FFFF - gray;
|
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);
|
||||||
@ -683,13 +673,6 @@ procedure TMvIntfGraphicsDrawingEngine.TextOut(X, Y: Integer; const AText: Strin
|
|||||||
var
|
var
|
||||||
bmp: TBitmap;
|
bmp: TBitmap;
|
||||||
ex: TSize;
|
ex: TSize;
|
||||||
img: TLazIntfImage;
|
|
||||||
i, j: Integer;
|
|
||||||
hb, hm: HBitmap;
|
|
||||||
c: TColor;
|
|
||||||
fc, tc: TFPColor;
|
|
||||||
intens, intens0: Int64;
|
|
||||||
alpha: Double;
|
|
||||||
R: TRect;
|
R: TRect;
|
||||||
txtFlags: Integer = DT_CENTER + DT_WORDBREAK;
|
txtFlags: Integer = DT_CENTER + DT_WORDBREAK;
|
||||||
begin
|
begin
|
||||||
@ -720,37 +703,6 @@ begin
|
|||||||
bmp.Canvas.FillRect(R);
|
bmp.Canvas.FillRect(R);
|
||||||
DrawText(bmp.Canvas.Handle, PChar(AText), Length(AText), R, txtFlags);
|
DrawText(bmp.Canvas.Handle, PChar(AText), Length(AText), R, txtFlags);
|
||||||
DrawBitmapOT(X, Y, bmp, FFontColor, bmp.Canvas.Brush.Color);
|
DrawBitmapOT(X, Y, bmp, FFontColor, bmp.Canvas.Brush.Color);
|
||||||
{
|
|
||||||
img := bmp.CreateIntfImage;
|
|
||||||
try
|
|
||||||
fc := TColorToFPColor(bmp.Canvas.Font.Color);
|
|
||||||
intens0 := Int64(fc.Red) + fc.Green + fc.Blue;
|
|
||||||
for j := 0 to img.Height - 1 do
|
|
||||||
for i := 0 to img.Width - 1 do begin
|
|
||||||
c := bmp.Canvas.Pixels[i, j];
|
|
||||||
tc := TColorToFPColor(c);
|
|
||||||
if c = bmp.Canvas.Brush.Color then
|
|
||||||
tc.Alpha := alphaTransparent
|
|
||||||
else if c = FFontColor then
|
|
||||||
tc.Alpha := alphaOpaque
|
|
||||||
else begin
|
|
||||||
intens := Int64(tc.Red) + tc.Green + tc.Blue;
|
|
||||||
if intens0 = 0 then
|
|
||||||
alpha := (3 * alphaopaque - intens) / (3 * alphaOpaque - intens0)
|
|
||||||
else
|
|
||||||
alpha := intens / intens0;
|
|
||||||
tc.Alpha := round(alphaOpaque * alpha);
|
|
||||||
end;
|
|
||||||
img.Colors[i, j] := tc;
|
|
||||||
end;
|
|
||||||
img.CreateBitmaps(hb, hm);
|
|
||||||
bmp.Handle := hb;
|
|
||||||
bmp.MaskHandle := hm;
|
|
||||||
DrawBitmap(X, Y, bmp, true);
|
|
||||||
finally
|
|
||||||
img.Free;
|
|
||||||
end;
|
|
||||||
}
|
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
bmp.Free;
|
bmp.Free;
|
||||||
|
Loading…
Reference in New Issue
Block a user