Ignore:
Timestamp:
May 9, 2020, 4:02:07 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Improved HighDPI branch. Imported new changes from trunk branch.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/highdpi/LocalPlayer/TechTree.pas

    r193 r210  
    55
    66uses
    7   ScreenTools, Messg, LCLIntf, LCLType, Messages, SysUtils, Classes, Graphics,
    8   Controls, Forms, ButtonBase, ButtonB, DrawDlg, UDpiControls;
     7  UDpiControls, ScreenTools, LCLIntf, LCLType, SysUtils, Classes, Graphics,
     8  Controls, Forms, ButtonB, DrawDlg;
    99
    1010type
     
    3030  TechTreeDlg: TTechTreeDlg;
    3131
     32
    3233implementation
    3334
     
    7778  X, w: Integer;
    7879begin
    79   with Canvas do
    80   begin
     80  with Canvas do begin
    8181    // black border
    8282    brush.color := $000000;
     
    107107        -BlackBorder - yOffset, Paper);
    108108  end;
    109   DpiBitBlt(Canvas.Handle, max(BlackBorder, BlackBorder + xOffset),
     109  DpiBitCanvas(Canvas, max(BlackBorder, BlackBorder + xOffset),
    110110    max(BlackBorder, BlackBorder + yOffset),
    111111    min(Image.width, min(Image.width + xOffset,
     
    113113    ), min(Image.height, min(Image.height + yOffset,
    114114    min(ClientHeight - 2 * BlackBorder, ClientHeight - 2 * BlackBorder -
    115     yOffset))), Image.Canvas.Handle, max(0, -xOffset),
    116     max(0, -yOffset), SRCCOPY);
     115    yOffset))), Image.Canvas, max(0, -xOffset),
     116    max(0, -yOffset));
    117117end;
    118118
    119119procedure TTechTreeDlg.FormShow(Sender: TObject);
    120120var
    121   X, Y, ad, TexWidth, TexHeight: Integer;
     121  X, Y, ad: Integer;
    122122  s: string;
    123   SrcPixel, DstPixel: TPixelPointer;
    124 begin
    125   if Image = nil then
    126   begin
     123const
     124  TransparentColor = $7F007F;
     125begin
     126  if Image = nil then begin
    127127    Image := TDpiBitmap.Create;
    128128    Image.PixelFormat := pf24bit;
    129129    LoadGraphicFile(Image, HomeDir + 'Help' + DirectorySeparator + 'AdvTree.png', gfNoGamma);
    130130
    131     with Image.Canvas do
    132     begin
     131    with Image.Canvas do begin
    133132      // write advance names
    134133      Font.Assign(UniFont[ftSmall]);
     
    146145            TextOut(xStart + X * xPitch + 2, yStart + Y * yPitch, s);
    147146            Pixels[xStart + X * xPitch + 10, yStart + Y * yPitch - 1]
    148               := $7F007F;
     147              := TransparentColor;
    149148          end
    150149        end;
     
    161160    end;
    162161
    163     // texturize background
    164     Image.BeginUpdate;
    165     TexWidth := Paper.Width;
    166     TexHeight := Paper.Height;
    167     DstPixel.Init(Image);
    168     SrcPixel.Init(Paper);
    169     for Y := 0 to Image.Height - 1 do begin
    170       for X := 0 to Image.Width - 1 do begin
    171         if (DstPixel.Pixel^.ARGB and $FFFFFF) = $7F007F then begin // transparent
    172           SrcPixel.SetXY(X mod TexWidth, Y mod TexHeight);
    173           DstPixel.Pixel^.B := SrcPixel.Pixel^.B;
    174           DstPixel.Pixel^.G := SrcPixel.Pixel^.G;
    175           DstPixel.Pixel^.R := SrcPixel.Pixel^.R;
    176         end;
    177         DstPixel.NextPixel;
    178       end;
    179       DstPixel.NextLine;
    180     end;
    181     Image.EndUpdate;
     162    Texturize(Image, Paper, TransparentColor);
    182163  end;
    183164
     
    204185    xDown := X;
    205186    yDown := Y;
    206   end
     187  end;
    207188end;
    208189
     
    234215
    235216    SmartInvalidate;
    236   end
     217  end;
    237218end;
    238219
     
    246227procedure TTechTreeDlg.CloseBtnClick(Sender: TObject);
    247228begin
    248   Close();
     229  Close;
    249230end;
    250231
Note: See TracChangeset for help on using the changeset viewer.