Ignore:
Timestamp:
Nov 29, 2023, 2:35:44 PM (12 months ago)
Author:
chronos
Message:
  • Modified: HighDpi branch updated to trunk version.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/highdpi/Packages/CevoComponents/ScreenTools.pas

    r405 r463  
    88  {$ENDIF}
    99  StringTables, LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, Math,
    10   Forms, Menus, GraphType, fgl, UGraphicSet, LazFileUtils, UTexture;
     10  Forms, Menus, GraphType, GraphicSet, LazFileUtils, Texture;
    1111
    1212type
     
    1717
    1818{$IFDEF WINDOWS}
    19 function ChangeResolution(x, y, bpp, freq: integer): boolean;
     19function ChangeResolution(X, Y, bpp, freq: Integer): Boolean;
    2020{$ENDIF}
    2121procedure RestoreResolution;
    2222procedure EmptyMenu(MenuItems: TDpiMenuItem; Keep: Integer = 0);
    23 function TurnToYear(Turn: integer): integer;
    24 function TurnToString(Turn: integer): string;
    25 function MovementToString(Movement: integer): string;
    26 procedure BtnFrame(ca: TDpiCanvas; p: TRect; T: TTexture);
    27 procedure EditFrame(ca: TDpiCanvas; p: TRect; T: TTexture);
    28 function HexStringToColor(S: string): integer;
     23function TurnToYear(Turn: Integer): Integer;
     24function TurnToString(Turn: Integer): string;
     25function MovementToString(Movement: Integer): string;
     26procedure BtnFrame(Canvas: TDpiCanvas; P: TRect; T: TTexture);
     27procedure EditFrame(Canvas: TDpiCanvas; P: TRect; T: TTexture);
     28function HexStringToColor(S: string): Integer;
    2929function ExtractFileNameWithoutExt(const Filename: string): string;
    30 function LoadGraphicFile(Bmp: TDpiBitmap; FileName: string; Options: TLoadGraphicFileOptions = []): boolean;
    31 function LoadGraphicSet(const Name: string): TGraphicSet;
    32 function LoadGraphicSet2(const Name: string): TGraphicSet;
    33 procedure Dump(dst: TDpiBitmap; HGr: TGraphicSet; xDst, yDst, Width, Height, xGr, yGr: integer);
     30function LoadGraphicFile(Bmp: TDpiBitmap; FileName: string; Options: TLoadGraphicFileOptions = []): Boolean;
     31function LoadGraphicSet(const Name: string; Transparency: Boolean = True): TGraphicSet;
     32procedure Dump(dst: TDpiBitmap; HGr: TGraphicSet; xDst, yDst, Width, Height, xGr, yGr: Integer);
    3433procedure BitmapReplaceColor(Dst: TDpiBitmap; X, Y, Width, Height: Integer; OldColor, NewColor: TColor);
    35 procedure Sprite(Canvas: TDpiCanvas; HGr: TGraphicSet; xDst, yDst, Width, Height, xGr, yGr: integer);
     34procedure Sprite(Canvas: TDpiCanvas; HGr: TGraphicSet; xDst, yDst, Width, Height, xGr, yGr: Integer);
    3635  overload;
    37 procedure Sprite(dst: TDpiBitmap; HGr: TGraphicSet; xDst, yDst, Width, Height, xGr, yGr: integer);
     36procedure Sprite(dst: TDpiBitmap; HGr: TGraphicSet; xDst, yDst, Width, Height, xGr, yGr: Integer);
    3837  overload;
    3938procedure MakeBlue(Dst: TDpiBitmap; X, Y, Width, Height: Integer);
     
    4645procedure ImageOp_CBC(Dst, Src: TDpiBitmap; xDst, yDst, xSrc, ySrc, Width, Height,
    4746  Color0, Color2: Integer);
    48 procedure ImageOp_CCC(bmp: TDpiBitmap; x, y, Width, Height, Color0, Color1, Color2: Integer);
    49 function DpiBitCanvas(DestCanvas: TDpiCanvas; X, Y, Width, Height: Integer;
     47procedure ImageOp_CCC(bmp: TDpiBitmap; X, Y, Width, Height, Color0, Color1, Color2: Integer);
     48function DpiBitBltCanvas(DestCanvas: TDpiCanvas; X, Y, Width, Height: Integer;
    5049  SrcCanvas: TDpiCanvas; XSrc, YSrc: Integer; Rop: DWORD = SRCCOPY): Boolean; overload;
    51 function DpiBitCanvas(Dest: TDpiCanvas; DestRect: TRect;
     50function DpiBitBltCanvas(Dest: TDpiCanvas; DestRect: TRect;
    5251  Src: TDpiCanvas; SrcPos: TPoint; Rop: DWORD = SRCCOPY): Boolean; overload;
    5352function BitBltBitmap(Dest: TDpiBitmap; X, Y, Width, Height: Integer;
     
    5554function BitBltBitmap(Dest: TDpiBitmap; DestRect: TRect;
    5655  Src: TDpiBitmap; SrcPos: TPoint; Rop: DWORD = SRCCOPY): Boolean; overload;
    57 procedure SLine(ca: TDpiCanvas; x0, x1, y: integer; cl: TColor);
    58 procedure DLine(ca: TDpiCanvas; x0, x1, y: integer; cl0, cl1: TColor);
    59 procedure Frame(ca: TDpiCanvas; x0, y0, x1, y1: integer; cl0, cl1: TColor);
    60 procedure RFrame(ca: TDpiCanvas; x0, y0, x1, y1: integer; cl0, cl1: TColor);
    61 procedure CFrame(ca: TDpiCanvas; x0, y0, x1, y1, Corner: integer; cl: TColor);
    62 procedure FrameImage(ca: TDpiCanvas; Src: TDpiBitmap;
    63   x, y, Width, Height, xSrc, ySrc: integer; IsControl: boolean = False);
    64 procedure GlowFrame(Dst: TDpiBitmap; x0, y0, Width, Height: integer; cl: TColor);
     56procedure SLine(Canvas: TDpiCanvas; x0, x1, Y: Integer; cl: TColor);
     57procedure DLine(Canvas: TDpiCanvas; x0, x1, Y: Integer; cl0, cl1: TColor);
     58procedure Frame(Canvas: TDpiCanvas; x0, y0, x1, y1: Integer; cl0, cl1: TColor);
     59procedure RFrame(Canvas: TDpiCanvas; x0, y0, x1, y1: Integer; cl0, cl1: TColor);
     60procedure CFrame(Canvas: TDpiCanvas; x0, y0, x1, y1, Corner: Integer; cl: TColor);
     61procedure FrameImage(Canvas: TDpiCanvas; Src: TDpiBitmap;
     62  X, Y, Width, Height, xSrc, ySrc: Integer; IsControl: Boolean = False);
     63procedure GlowFrame(Dst: TDpiBitmap; x0, y0, Width, Height: Integer; cl: TColor);
    6564procedure InitOrnament;
    66 procedure InitCityMark(T: TTexture);
    67 procedure Fill(ca: TDpiCanvas; Left, Top, Width, Height, xOffset, yOffset: integer); overload;
     65procedure InitCityMark(Texture: TTexture);
     66procedure Fill(Canvas: TDpiCanvas; Left, Top, Width, Height, xOffset, yOffset: Integer); overload;
    6867procedure Fill(Canvas: TDpiCanvas; Rect: TRect; Offset: TPoint); overload;
    69 procedure FillLarge(ca: TDpiCanvas; x0, y0, x1, y1, xm: integer);
    70 procedure FillSeamless(ca: TDpiCanvas; Left, Top, Width, Height, xOffset, yOffset: integer;
     68procedure FillLarge(Canvas: TDpiCanvas; x0, y0, x1, y1, xm: Integer);
     69procedure FillSeamless(Canvas: TDpiCanvas; Left, Top, Width, Height, xOffset, yOffset: Integer;
    7170  const Texture: TDpiBitmap);
    72 procedure FillRectSeamless(ca: TDpiCanvas; x0, y0, x1, y1, xOffset, yOffset: integer;
     71procedure FillRectSeamless(Canvas: TDpiCanvas; x0, y0, x1, y1, xOffset, yOffset: Integer;
    7372  const Texture: TDpiBitmap);
    74 procedure PaintBackground(Form: TDpiForm; Left, Top, Width, Height: integer);
    75 procedure Corner(ca: TDpiCanvas; x, y, Kind: integer; T: TTexture);
    76 procedure BiColorTextOut(ca: TDpiCanvas; clMain, clBack: TColor; x, y: integer; s: string);
    77 procedure LoweredTextOut(ca: TDpiCanvas; cl: TColor; T: TTexture;
    78   x, y: integer; s: string);
    79 function BiColorTextWidth(ca: TDpiCanvas; s: string): integer;
    80 procedure RisedTextOut(ca: TDpiCanvas; x, y: integer; s: string);
    81 procedure LightGradient(ca: TDpiCanvas; x, y, Width, Color: integer);
    82 procedure DarkGradient(ca: TDpiCanvas; x, y, Width, Kind: integer);
    83 procedure VLightGradient(ca: TDpiCanvas; x, y, Height, Color: integer);
    84 procedure VDarkGradient(ca: TDpiCanvas; x, y, Height, Kind: integer);
     73procedure PaintBackground(Form: TDpiForm; Left, Top, Width, Height: Integer);
     74procedure Corner(Canvas: TDpiCanvas; X, Y, Kind: Integer; T: TTexture);
     75procedure BiColorTextOut(Canvas: TDpiCanvas; clMain, clBack: TColor; X, Y: Integer; S: string);
     76procedure LoweredTextOut(Canvas: TDpiCanvas; cl: TColor; T: TTexture;
     77  X, Y: Integer; S: string);
     78function BiColorTextWidth(Canvas: TDpiCanvas; S: string): Integer;
     79procedure RisedTextOut(Canvas: TDpiCanvas; X, Y: Integer; S: string);
     80procedure LightGradient(Canvas: TDpiCanvas; X, Y, Width, Color: Integer);
     81procedure DarkGradient(Canvas: TDpiCanvas; X, Y, Width, Kind: Integer);
     82procedure VLightGradient(Canvas: TDpiCanvas; X, Y, Height, Color: Integer);
     83procedure VDarkGradient(Canvas: TDpiCanvas; X, Y, Height, Kind: Integer);
    8584procedure UnderlinedTitleValue(Canvas: TDpiCanvas; Title, Value: string; X, Y, Width: Integer);
    86 procedure NumberBar(dst: TDpiBitmap; x, y: integer; Cap: string; val: integer;
     85procedure NumberBar(dst: TDpiBitmap; X, Y: Integer; Cap: string; val: Integer;
    8786  T: TTexture);
    88 procedure CountBar(dst: TDpiBitmap; x, y, w: integer; Kind: integer;
    89   Cap: string; val: integer; T: TTexture);
    90 procedure PaintProgressBar(ca: TDpiCanvas; Kind, x, y, pos, Growth, max: integer;
     87procedure CountBar(dst: TDpiBitmap; X, Y, W: Integer; Kind: Integer;
     88  Cap: string; val: Integer; T: TTexture);
     89procedure PaintProgressBar(Canvas: TDpiCanvas; Kind, X, Y, Pos, Growth, Max: Integer;
    9190  T: TTexture);
    92 procedure PaintRelativeProgressBar(ca: TDpiCanvas;
    93   Kind, x, y, size, pos, Growth, max: integer; IndicateComplete: boolean;
     91procedure PaintRelativeProgressBar(Canvas: TDpiCanvas;
     92  Kind, X, Y, size, Pos, Growth, Max: Integer; IndicateComplete: Boolean;
    9493  T: TTexture);
    95 procedure PaintLogo(Canvas: TDpiCanvas; X, Y, LightColor, ShadeColor: integer);
     94procedure PaintLogo(Canvas: TDpiCanvas; X, Y, LightColor, ShadeColor: Integer);
    9695procedure LoadPhrases;
    9796procedure Texturize(Dest, Texture: TDpiBitmap; TransparentColor: Cardinal);
     
    149148  Phrases2: TStringTable;
    150149  GrExt: TGraphicSets;
     150
    151151  HGrSystem: TGraphicSet;
    152   HGrSystem2: TGraphicSet;
    153   ClickFrameColor: Integer;
    154   MainTexture: TTexture;
    155   Templates: TGraphicSet;
    156   Colors: TDpiBitmap;
    157   Paper: TDpiBitmap;
    158   BigImp: TDpiBitmap;
    159   LogoBuffer: TDpiBitmap;
    160   FullScreen: Boolean;
    161   GenerateNames: Boolean;
    162   InitOrnamentDone: Boolean;
    163   Phrases2FallenBackToEnglish: Boolean;
    164 
    165   // Graphic set items
    166152  CityMark1: TGraphicSetItem;
    167153  CityMark2: TGraphicSetItem;
     154
     155  HGrSystem2: TGraphicSet;
    168156  Ornament: TGraphicSetItem;
     157  GBrainNoTerm: TGraphicSetItem;
     158  GBrainSuperVirtual: TGraphicSetItem;
     159  GBrainTerm: TGraphicSetItem;
     160  GBrainRandom: TGraphicSetItem;
     161
     162  Templates: TGraphicSet;
    169163  Logo: TGraphicSetItem;
    170164  BigBook: TGraphicSetItem;
     
    180174  WeightOff: TGraphicSetItem;
    181175
     176  ClickFrameColor: Integer;
     177  MainTexture: TTexture;
     178  Colors: TDpiBitmap;
     179  Paper: TDpiBitmap;
     180  BigImp: TDpiBitmap;
     181  LogoBuffer: TDpiBitmap;
     182  FullScreen: Boolean;
     183  GenerateNames: Boolean;
     184  InitOrnamentDone: Boolean;
     185  Phrases2FallenBackToEnglish: Boolean;
     186
    182187  UniFont: array [TFontType] of TDpiFont;
    183188  Gamma: Integer; // global gamma correction (cent)
     
    192197
    193198uses
    194   Directories, Sound, UPixelPointer;
     199  Directories, Sound, PixelPointer;
    195200
    196201var
    197202  {$IFDEF WINDOWS}
    198203  StartResolution: TDeviceMode;
    199   ResolutionChanged: boolean;
     204  ResolutionChanged: Boolean;
    200205  {$ENDIF}
    201206
     
    203208
    204209{$IFDEF WINDOWS}
    205 function ChangeResolution(x, y, bpp, freq: integer): boolean;
     210function ChangeResolution(X, Y, bpp, freq: Integer): Boolean;
    206211var
    207212  DevMode: TDeviceMode;
     
    210215  DevMode.dmFields := DM_PELSWIDTH or DM_PELSHEIGHT or DM_BITSPERPEL or
    211216    DM_DISPLAYFREQUENCY;
    212   DevMode.dmPelsWidth := x;
    213   DevMode.dmPelsHeight := y;
     217  DevMode.dmPelsWidth := X;
     218  DevMode.dmPelsHeight := Y;
    214219  DevMode.dmBitsPerPel := bpp;
    215220  DevMode.dmDisplayFrequency := freq;
     
    311316end;
    312317
    313 procedure BtnFrame(ca: TDpiCanvas; p: TRect; T: TTexture);
    314 begin
    315   RFrame(ca, p.Left - 1, p.Top - 1, p.Right, p.Bottom, T.ColorBevelShade,
     318procedure BtnFrame(Canvas: TDpiCanvas; P: TRect; T: TTexture);
     319begin
     320  RFrame(Canvas, P.Left - 1, P.Top - 1, P.Right, P.Bottom, T.ColorBevelShade,
    316321    T.ColorBevelLight);
    317322end;
    318323
    319 procedure EditFrame(ca: TDpiCanvas; p: TRect; T: TTexture);
    320 begin
    321   Frame(ca, p.Left - 1, p.Top - 1, p.Right, p.Bottom, $000000, $000000);
    322   Frame(ca, p.Left - 2, p.Top - 2, p.Right + 1, p.Bottom + 1, $000000, $000000);
    323   Frame(ca, p.Left - 3, p.Top - 3, p.Right + 2, p.Bottom + 1, $000000, $000000);
    324   RFrame(ca, p.Left - 4, p.Top - 4, p.Right + 3, p.Bottom + 2, T.ColorBevelShade,
     324procedure EditFrame(Canvas: TDpiCanvas; P: TRect; T: TTexture);
     325begin
     326  Frame(Canvas, P.Left - 1, P.Top - 1, P.Right, P.Bottom, $000000, $000000);
     327  Frame(Canvas, P.Left - 2, P.Top - 2, P.Right + 1, P.Bottom + 1, $000000, $000000);
     328  Frame(Canvas, P.Left - 3, P.Top - 3, P.Right + 2, P.Bottom + 1, $000000, $000000);
     329  RFrame(Canvas, P.Left - 4, P.Top - 4, P.Right + 3, P.Bottom + 2, T.ColorBevelShade,
    325330    T.ColorBevelLight);
    326331end;
     
    328333function HexCharToInt(X: Char): Integer;
    329334begin
    330   case x of
     335  case X of
    331336    '0' .. '9': Result := Ord(X) - Ord('0');
    332337    'A' .. 'F': Result := Ord(X) - Ord('A') + 10;
     
    364369begin
    365370  Bitmap.BeginUpdate;
    366   PixelPtr := PixelPointer(Bitmap);
     371  PixelPtr := TPixelPointer.Create(Bitmap);
    367372  for Y := 0 to ScaleToNative(Bitmap.Height) - 1 do begin
    368373    for X := 0 to ScaleToNative(Bitmap.Width) - 1 do begin
     
    381386begin
    382387  //Dst.SetSize(Src.Width, Src.Height);
    383   SrcPtr := PixelPointer(Src);
    384   DstPtr := PixelPointer(Dst);
     388  SrcPtr := TPixelPointer.Create(Src);
     389  DstPtr := TPixelPointer.Create(Dst);
    385390  for Y := 0 to ScaleToNative(Src.Height - 1) do begin
    386391    for X := 0 to ScaleToNative(Src.Width - 1) do begin
     
    483488end;
    484489
    485 function LoadGraphicSet(const Name: string): TGraphicSet;
    486 var
    487   x: Integer;
    488   y: Integer;
     490function LoadGraphicSet(const Name: string; Transparency: Boolean = True): TGraphicSet;
     491var
     492  X: Integer;
     493  Y: Integer;
    489494  OriginalColor: Integer;
    490495  FileName: string;
     
    508513    Result.ResetPixUsed;
    509514
    510     Result.Mask.SetSize(Result.Data.Width, Result.Data.Height);
    511 
    512     Result.Data.BeginUpdate;
    513     Result.Mask.BeginUpdate;
    514     DataPixel := PixelPointer(Result.Data);
    515     MaskPixel := PixelPointer(Result.Mask);
    516     for y := 0 to ScaleToNative(Result.Data.Height) - 1 do begin
    517       for x := 0 to ScaleToNative(Result.Data.Width) - 1 do begin
    518         OriginalColor := DataPixel.Pixel^.ARGB and $FFFFFF;
    519         if (OriginalColor = TransparentColor1) or (OriginalColor = TransparentColor2) then begin
    520           MaskPixel.Pixel^.R := $FF;
    521           MaskPixel.Pixel^.G := $FF;
    522           MaskPixel.Pixel^.B := $FF;
    523           DataPixel.Pixel^.R := 0;
    524           DataPixel.Pixel^.G := 0;
    525           DataPixel.Pixel^.B := 0;
    526         end else begin
    527           MaskPixel.Pixel^.R := $00;
    528           MaskPixel.Pixel^.G := $00;
    529           MaskPixel.Pixel^.B := $00;
     515    if Transparency then begin
     516      Result.Mask.SetSize(Result.Data.Width, Result.Data.Height);
     517
     518      Result.Data.BeginUpdate;
     519      Result.Mask.BeginUpdate;
     520      DataPixel := TPixelPointer.Create(Result.Data);
     521      MaskPixel := TPixelPointer.Create(Result.Mask);
     522      for Y := 0 to ScaleToNative(Result.Data.Height) - 1 do begin
     523        for X := 0 to ScaleToNative(Result.Data.Width) - 1 do begin
     524          OriginalColor := DataPixel.Pixel^.ARGB and $FFFFFF;
     525          if (OriginalColor = TransparentColor1) or (OriginalColor = TransparentColor2) then begin
     526            MaskPixel.Pixel^.R := $FF;
     527            MaskPixel.Pixel^.G := $FF;
     528            MaskPixel.Pixel^.B := $FF;
     529            DataPixel.Pixel^.R := 0;
     530            DataPixel.Pixel^.G := 0;
     531            DataPixel.Pixel^.B := 0;
     532          end else begin
     533            MaskPixel.Pixel^.R := $00;
     534            MaskPixel.Pixel^.G := $00;
     535            MaskPixel.Pixel^.B := $00;
     536          end;
     537          DataPixel.NextPixel;
     538          MaskPixel.NextPixel;
    530539        end;
    531         DataPixel.NextPixel;
    532         MaskPixel.NextPixel;
     540        DataPixel.NextLine;
     541        MaskPixel.NextLine;
    533542      end;
    534       DataPixel.NextLine;
    535       MaskPixel.NextLine;
    536     end;
    537     Result.Data.EndUpdate;
    538     Result.Mask.EndUpdate;
    539 
    540     if Gamma <> 100 then
    541       ApplyGammaToBitmap(Result.Data);
    542   end;
    543 end;
    544 
    545 function LoadGraphicSet2(const Name: string): TGraphicSet;
    546 var
    547   FileName: string;
    548 begin
    549   Result := GrExt.SearchByName(Name);
    550   if not Assigned(Result) then begin
    551     Result := GrExt.AddNew(Name);
    552     FileName := GetGraphicsDir + DirectorySeparator + Name;
    553     if not LoadGraphicFile(Result.Data, FileName, [gfNoGamma]) then begin
    554       Result := nil;
    555       Exit;
    556     end;
    557 
    558     FileName := ExtractFileNameWithoutExt(FileName) + GraphicSetFileExt;
    559     if FileExists(FileName) then
    560       Result.LoadFromFile(FileName);
    561 
    562     Result.ResetPixUsed;
    563   end;
    564 end;
    565 
    566 procedure Dump(dst: TDpiBitmap; HGr: TGraphicSet; xDst, yDst, Width, Height, xGr, yGr: integer);
    567 begin
    568   DpiBitCanvas(dst.Canvas, xDst, yDst, Width, Height,
     543      Result.Data.EndUpdate;
     544      Result.Mask.EndUpdate;
     545
     546      if Gamma <> 100 then
     547        ApplyGammaToBitmap(Result.Data);
     548    end;
     549  end;
     550end;
     551
     552procedure Dump(dst: TDpiBitmap; HGr: TGraphicSet; xDst, yDst, Width, Height, xGr, yGr: Integer);
     553begin
     554  DpiBitBltCanvas(dst.Canvas, xDst, yDst, Width, Height,
    569555    HGr.Data.Canvas, xGr, yGr);
    570556end;
     
    576562begin
    577563  Dst.BeginUpdate;
    578   PixelPtr := PixelPointer(Dst, ScaleToNative(X), ScaleToNative(Y));
     564  PixelPtr := TPixelPointer.Create(Dst, ScaleToNative(X), ScaleToNative(Y));
    579565  for YY := 0 to ScaleToNative(Height) - 1 do begin
    580566    for XX := 0 to ScaleToNative(Width) - 1 do begin
     
    595581begin
    596582  Dst.BeginUpdate;
    597   PixelPtr := PixelPointer(Dst, ScaleToNative(X), ScaleToNative(Y));
     583  PixelPtr := TPixelPointer.Create(Dst, ScaleToNative(X), ScaleToNative(Y));
    598584  for yy := 0 to ScaleToNative(Height) - 1 do begin
    599585    for xx := 0 to ScaleToNative(Width) - 1 do begin
     
    615601begin
    616602  Dst.BeginUpdate;
    617   PixelPtr := PixelPointer(Dst, ScaleToNative(X), ScaleToNative(Y));
     603  PixelPtr := TPixelPointer.Create(Dst, ScaleToNative(X), ScaleToNative(Y));
    618604  for YY := 0 to ScaleToNative(Height) - 1 do begin
    619605    for XX := 0 to ScaleToNative(Width) - 1 do begin
     
    662648    Height := ScaleToNative(dst.Height) - yDst;
    663649  if (Width < 0) or (Height < 0) then
    664     exit;
     650    Exit;
    665651
    666652  dst.BeginUpdate;
    667653  Src.BeginUpdate;
    668   PixelDst := PixelPointer(Dst, xDst, yDst);
    669   PixelSrc := PixelPointer(Src, xSrc, ySrc);
     654  PixelDst := TPixelPointer.Create(Dst, xDst, yDst);
     655  PixelSrc := TPixelPointer.Create(Src, xSrc, ySrc);
    670656  for Y := 0 to Height - 1 do begin
    671657    for X := 0 to Width - 1 do  begin
    672658      Brightness := PixelSrc.Pixel^.B; // One byte for 8-bit color
    673       test := (PixelDst.Pixel^.R * Brightness) shr 7;
    674       if test >= 256 then
     659      Test := (PixelDst.Pixel^.R * Brightness) shr 7;
     660      if Test >= 256 then
    675661        PixelDst.Pixel^.R := 255
    676662      else
    677         PixelDst.Pixel^.R := test; // Red
    678       test := (PixelDst.Pixel^.G * Brightness) shr 7;
    679       if test >= 256 then
     663        PixelDst.Pixel^.R := Test; // Red
     664      Test := (PixelDst.Pixel^.G * Brightness) shr 7;
     665      if Test >= 256 then
    680666        PixelDst.Pixel^.G := 255
    681667      else
    682         PixelDst.Pixel^.G := test; // Green
    683       test := (PixelDst.Pixel^.B * Brightness) shr 7;
    684       if test >= 256 then
     668        PixelDst.Pixel^.G := Test; // Green
     669      Test := (PixelDst.Pixel^.B * Brightness) shr 7;
     670      if Test >= 256 then
    685671        PixelDst.Pixel^.R := 255
    686672      else
     
    728714    Height := ScaleToNative(dst.Height) - yDst;
    729715  if (Width < 0) or (Height < 0) then
    730     exit;
     716    Exit;
    731717
    732718  Src.BeginUpdate;
    733719  dst.BeginUpdate;
    734   SrcPixel := PixelPointer(Src, xSrc, ySrc);
    735   DstPixel := PixelPointer(Dst, xDst, yDst);
     720  SrcPixel := TPixelPointer.Create(Src, xSrc, ySrc);
     721  DstPixel := TPixelPointer.Create(Dst, xDst, yDst);
    736722  for iy := 0 to Height - 1 do begin
    737723    for ix := 0 to Width - 1 do begin
     
    777763// R channel = Color2 amp
    778764var
    779   ix, iy, amp0, amp1, trans, Value: integer;
     765  ix, iy, amp0, amp1, trans, Value: Integer;
    780766  SrcPixel: TPixelPointer;
    781767  DstPixel: TPixelPointer;
     
    789775  Src.BeginUpdate;
    790776  Dst.BeginUpdate;
    791   SrcPixel := PixelPointer(Src, xSrc, ySrc);
    792   DstPixel := PixelPointer(Dst, xDst, yDst);
     777  SrcPixel := TPixelPointer.Create(Src, xSrc, ySrc);
     778  DstPixel := TPixelPointer.Create(Dst, xDst, yDst);
    793779  for iy := 0 to Height - 1 do begin
    794780    for ix := 0 to Width - 1 do begin
     
    819805end;
    820806
    821 procedure ImageOp_CCC(bmp: TDpiBitmap; x, y, Width, Height, Color0, Color1, Color2: Integer);
     807procedure ImageOp_CCC(bmp: TDpiBitmap; X, Y, Width, Height, Color0, Color1, Color2: Integer);
    822808// Bmp is template
    823809// B channel = Color0 amp, 128=original brightness
     
    825811// R channel = Color2 amp, 128=original brightness
    826812var
    827   i, Red, Green: Integer;
     813  I, Red, Green: Integer;
    828814  PixelPtr: TPixelPointer;
    829815begin
     
    833819  Y := ScaleToNative(Y);
    834820  bmp.BeginUpdate;
    835   assert(bmp.PixelFormat = pf24bit);
    836   Height := y + Height;
    837   PixelPtr := PixelPointer(Bmp, x, y);
    838   while y < Height do begin
    839     for i := 0 to Width - 1 do begin
     821  Assert(bmp.PixelFormat = pf24bit);
     822  Height := Y + Height;
     823  PixelPtr := TPixelPointer.Create(Bmp, X, Y);
     824  while Y < Height do begin
     825    for I := 0 to Width - 1 do begin
    840826      Red := ((PixelPtr.Pixel^.B * (Color0 and $0000FF) + PixelPtr.Pixel^.G *
    841827        (Color1 and $0000FF) + PixelPtr.Pixel^.R * (Color2 and $0000FF)) shr 8) and $ff;
     
    850836      PixelPtr.NextPixel;
    851837    end;
    852     Inc(y);
     838    Inc(Y);
    853839    PixelPtr.NextLine;
    854840  end;
     
    856842end;
    857843
    858 procedure Sprite(Canvas: TDpiCanvas; HGr: TGraphicSet; xDst, yDst, Width, Height, xGr, yGr: integer);
    859 begin
    860   DpiBitCanvas(Canvas, xDst, yDst, Width, Height,
     844procedure Sprite(Canvas: TDpiCanvas; HGr: TGraphicSet; xDst, yDst, Width, Height, xGr, yGr: Integer);
     845begin
     846  DpiBitBltCanvas(Canvas, xDst, yDst, Width, Height,
    861847    HGr.Mask.Canvas, xGr, yGr, SRCAND);
    862   DpiBitCanvas(Canvas, xDst, yDst, Width, Height,
     848  DpiBitBltCanvas(Canvas, xDst, yDst, Width, Height,
    863849    HGr.Data.Canvas, xGr, yGr, SRCPAINT);
    864850end;
    865851
    866 procedure Sprite(dst: TDpiBitmap; HGr: TGraphicSet; xDst, yDst, Width, Height, xGr, yGr: integer);
    867 begin
    868   DpiBitCanvas(dst.Canvas, xDst, yDst, Width, Height,
     852procedure Sprite(dst: TDpiBitmap; HGr: TGraphicSet; xDst, yDst, Width, Height, xGr, yGr: Integer);
     853begin
     854  DpiBitBltCanvas(dst.Canvas, xDst, yDst, Width, Height,
    869855    HGr.Mask.Canvas, xGr, yGr, SRCAND);
    870   DpiBitCanvas(dst.Canvas, xDst, yDst, Width, Height,
     856  DpiBitBltCanvas(dst.Canvas, xDst, yDst, Width, Height,
    871857    HGr.Data.Canvas, xGr, yGr, SRCPAINT);
    872858end;
    873859
    874 function DpiBitCanvas(DestCanvas: TDpiCanvas; X, Y, Width, Height: Integer;
     860function DpiBitBltCanvas(DestCanvas: TDpiCanvas; X, Y, Width, Height: Integer;
    875861  SrcCanvas: TDpiCanvas; XSrc, YSrc: Integer; Rop: DWORD = SRCCOPY): Boolean;
    876862begin
     
    883869end;
    884870
    885 function DpiBitCanvas(Dest: TDpiCanvas; DestRect: TRect; Src: TDpiCanvas;
     871function DpiBitBltCanvas(Dest: TDpiCanvas; DestRect: TRect; Src: TDpiCanvas;
    886872  SrcPos: TPoint; Rop: DWORD): Boolean;
    887873begin
    888   Result := DpiBitCanvas(Dest, DestRect.Left, DestRect.Top, DestRect.Width, DestRect.Height,
     874  Result := DpiBitBltCanvas(Dest, DestRect.Left, DestRect.Top, DestRect.Width, DestRect.Height,
    889875    Src, SrcPos.X, SrcPos.Y, Rop);
    890876end;
     
    893879  Src: TDpiBitmap; XSrc, YSrc: Integer; Rop: DWORD): Boolean;
    894880begin
    895   Result := DpiBitCanvas(Dest.Canvas, X, Y, Width, Height, Src.Canvas, XSrc, YSrc, Rop);
     881  Result := DpiBitBltCanvas(Dest.Canvas, X, Y, Width, Height, Src.Canvas, XSrc, YSrc, Rop);
    896882end;
    897883
     
    899885  SrcPos: TPoint; Rop: DWORD): Boolean;
    900886begin
    901   Result := DpiBitCanvas(Dest.Canvas, DestRect, Src.Canvas, SrcPos, Rop);
    902 end;
    903 
    904 procedure SLine(ca: TDpiCanvas; x0, x1, y: integer; cl: TColor);
    905 begin
    906   with ca do begin
     887  Result := DpiBitBltCanvas(Dest.Canvas, DestRect, Src.Canvas, SrcPos, Rop);
     888end;
     889
     890procedure SLine(Canvas: TDpiCanvas; x0, x1, Y: Integer; cl: TColor);
     891begin
     892  with Canvas do begin
    907893    Pen.Color := cl;
    908     MoveTo(x0, y);
    909     LineTo(x1 + 1, y);
    910   end;
    911 end;
    912 
    913 procedure DLine(ca: TDpiCanvas; x0, x1, y: integer; cl0, cl1: TColor);
    914 begin
    915   with ca do begin
     894    MoveTo(x0, Y);
     895    LineTo(x1 + 1, Y);
     896  end;
     897end;
     898
     899procedure DLine(Canvas: TDpiCanvas; x0, x1, Y: Integer; cl0, cl1: TColor);
     900begin
     901  with Canvas do begin
    916902    Pen.Color := cl0;
    917     MoveTo(x0, y);
    918     LineTo(x1, y);
     903    MoveTo(x0, Y);
     904    LineTo(x1, Y);
    919905    Pen.Color := cl1;
    920     MoveTo(x0 + 1, y + 1);
    921     LineTo(x1 + 1, y + 1);
    922     Pixels[x0, y + 1] := cl0;
    923     Pixels[x1, y] := cl1;
    924   end;
    925 end;
    926 
    927 procedure Frame(ca: TDpiCanvas; x0, y0, x1, y1: integer; cl0, cl1: TColor);
    928 begin
    929   with ca do begin
     906    MoveTo(x0 + 1, Y + 1);
     907    LineTo(x1 + 1, Y + 1);
     908    Pixels[x0, Y + 1] := cl0;
     909    Pixels[x1, Y] := cl1;
     910  end;
     911end;
     912
     913procedure Frame(Canvas: TDpiCanvas; x0, y0, x1, y1: Integer; cl0, cl1: TColor);
     914begin
     915  with Canvas do begin
    930916    MoveTo(x0, y1);
    931917    Pen.Color := cl0;
     
    938924end;
    939925
    940 procedure RFrame(ca: TDpiCanvas; x0, y0, x1, y1: integer; cl0, cl1: TColor);
    941 begin
    942   with ca do begin
     926procedure RFrame(Canvas: TDpiCanvas; x0, y0, x1, y1: Integer; cl0, cl1: TColor);
     927begin
     928  with Canvas do begin
    943929    Pen.Color := cl0;
    944930    MoveTo(x0, y0 + 1);
     
    954940end;
    955941
    956 procedure CFrame(ca: TDpiCanvas; x0, y0, x1, y1, Corner: integer; cl: TColor);
    957 begin
    958   with ca do begin
     942procedure CFrame(Canvas: TDpiCanvas; x0, y0, x1, y1, Corner: Integer; cl: TColor);
     943begin
     944  with Canvas do begin
    959945    Pen.Color := cl;
    960946    MoveTo(x0, y0 + Corner - 1);
     
    973959end;
    974960
    975 procedure FrameImage(ca: TDpiCanvas; Src: TDpiBitmap;
    976   x, y, Width, Height, xSrc, ySrc: integer; IsControl: boolean = False);
     961procedure FrameImage(Canvas: TDpiCanvas; Src: TDpiBitmap;
     962  X, Y, Width, Height, xSrc, ySrc: Integer; IsControl: Boolean = False);
    977963begin
    978964  if IsControl then begin
    979     Frame(ca, x - 1, y - 1, x + Width, y + Height, $B0B0B0, $FFFFFF);
    980     RFrame(ca, x - 2, y - 2, x + Width + 1, y + Height + 1, $FFFFFF, $B0B0B0);
     965    Frame(Canvas, X - 1, Y - 1, X + Width, Y + Height, $B0B0B0, $FFFFFF);
     966    RFrame(Canvas, X - 2, Y - 2, X + Width + 1, Y + Height + 1, $FFFFFF, $B0B0B0);
    981967  end else
    982     Frame(ca, x - 1, y - 1, x + Width, y + Height, $000000, $000000);
    983   DpiBitCanvas(ca, x, y, Width, Height, Src.Canvas, xSrc, ySrc);
     968    Frame(Canvas, X - 1, Y - 1, X + Width, Y + Height, $000000, $000000);
     969  DpiBitBltCanvas(Canvas, X, Y, Width, Height, Src.Canvas, xSrc, ySrc);
    984970end;
    985971
    986972procedure GlowFrame(Dst: TDpiBitmap; x0, y0, Width, Height: Integer; cl: TColor);
    987973var
    988   x, y, ch, r: Integer;
     974  X, Y, ch, R: Integer;
    989975  DstPtr: TPixelPointer;
    990976  DpiGlowRange: Integer;
     
    996982  Height := ScaleToNative(Height);
    997983  Dst.BeginUpdate;
    998   DstPtr := PixelPointer(Dst, x0 - DpiGlowRange + 1, y0 - DpiGlowRange + 1);
    999   for y := -DpiGlowRange + 1 to Height - 1 + DpiGlowRange - 1 do begin
    1000     for x := -DpiGlowRange + 1 to Width - 1 + DpiGlowRange - 1 do begin
    1001       if x < 0 then
    1002         if y < 0 then
    1003           r := round(sqrt(sqr(x) + sqr(y)))
    1004         else if y >= Height then
    1005           r := round(sqrt(sqr(x) + sqr(y - (Height - 1))))
     984  DstPtr := TPixelPointer.Create(Dst, x0 - DpiGlowRange + 1, y0 - DpiGlowRange + 1);
     985  for Y := -DpiGlowRange + 1 to Height - 1 + DpiGlowRange - 1 do begin
     986    for X := -DpiGlowRange + 1 to Width - 1 + DpiGlowRange - 1 do begin
     987      if X < 0 then
     988        if Y < 0 then
     989          R := round(sqrt(sqr(X) + sqr(Y)))
     990        else if Y >= Height then
     991          R := round(sqrt(sqr(X) + sqr(Y - (Height - 1))))
    1006992        else
    1007           r := -x
    1008       else if x >= Width then
    1009         if y < 0 then
    1010           r := round(sqrt(sqr(x - (Width - 1)) + sqr(y)))
    1011         else if y >= Height then
    1012           r := round(sqrt(sqr(x - (Width - 1)) + sqr(y - (Height - 1))))
     993          R := -X
     994      else if X >= Width then
     995        if Y < 0 then
     996          R := round(sqrt(sqr(X - (Width - 1)) + sqr(Y)))
     997        else if Y >= Height then
     998          R := round(sqrt(sqr(X - (Width - 1)) + sqr(Y - (Height - 1))))
    1013999        else
    1014           r := x - (Width - 1)
    1015       else if y < 0 then
    1016         r := -y
    1017       else if y >= Height then
    1018         r := y - (Height - 1)
     1000          R := X - (Width - 1)
     1001      else if Y < 0 then
     1002        R := -Y
     1003      else if Y >= Height then
     1004        R := Y - (Height - 1)
    10191005      else begin
    10201006        DstPtr.NextPixel;
    10211007        continue;
    10221008      end;
    1023       if r = 0 then
    1024         r := 1;
    1025       if r < DpiGlowRange then
     1009      if R = 0 then
     1010        R := 1;
     1011      if R < DpiGlowRange then
    10261012        for ch := 0 to 2 do
    10271013          DstPtr.Pixel^.Planes[2 - ch] :=
    1028             (DstPtr.Pixel^.Planes[2 - ch] * (r - 1) + (cl shr (8 * ch) and $FF) *
    1029             (DpiGlowRange - r)) div (DpiGlowRange - 1);
     1014            (DstPtr.Pixel^.Planes[2 - ch] * (R - 1) + (cl shr (8 * ch) and $FF) *
     1015            (DpiGlowRange - R)) div (DpiGlowRange - 1);
    10301016      DstPtr.NextPixel;
    10311017    end;
     
    10481034    MainTexture.ColorBevelLight and $FCFCFC shr 2);
    10491035  HGrSystem2.Data.BeginUpdate;
    1050   PixelPtr := PixelPointer(HGrSystem2.Data, ScaleToNative(Ornament.Left), ScaleToNative(Ornament.Top));
     1036  PixelPtr := TPixelPointer.Create(HGrSystem2.Data, ScaleToNative(Ornament.Left),
     1037    ScaleToNative(Ornament.Top));
    10511038  if PixelPtr.BytesPerPixel = 3 then begin
    10521039    for Y := 0 to ScaleToNative(Ornament.Height) - 1 do begin
     
    10741061end;
    10751062
    1076 procedure InitCityMark(T: TTexture);
    1077 var
    1078   x: Integer;
    1079   y: Integer;
     1063procedure InitCityMark(Texture: TTexture);
     1064var
     1065  X: Integer;
     1066  Y: Integer;
    10801067  Intensity: Integer;
    10811068begin
    1082   for x := 0 to CityMark1.Width - 1 do begin
    1083     for y := 0 to CityMark1.Height - 1 do begin
    1084       if HGrSystem.Mask.Canvas.Pixels[CityMark1.Left + x, CityMark1.Top + y] = 0 then
     1069  for X := 0 to CityMark1.Width - 1 do begin
     1070    for Y := 0 to CityMark1.Height - 1 do begin
     1071      if HGrSystem.Mask.Canvas.Pixels[CityMark1.Left + X, CityMark1.Top + Y] = 0 then
    10851072      begin
    10861073        Intensity := HGrSystem.Data.Canvas.Pixels[CityMark1.Left +
    1087           x, CityMark1.Top + y] and $FF;
    1088         HGrSystem.Data.Canvas.Pixels[CityMark2.Left + x, CityMark2.Top + y] :=
    1089           T.ColorMark and $FF * Intensity div $FF + T.ColorMark shr 8 and
    1090           $FF * Intensity div $FF shl 8 + T.ColorMark shr 16 and
     1074          X, CityMark1.Top + Y] and $FF;
     1075        HGrSystem.Data.Canvas.Pixels[CityMark2.Left + X, CityMark2.Top + Y] :=
     1076          Texture.ColorMark and $FF * Intensity div $FF + Texture.ColorMark shr 8 and
     1077          $FF * Intensity div $FF shl 8 + Texture.ColorMark shr 16 and
    10911078          $FF * Intensity div $FF shl 16;
    10921079      end;
    10931080    end;
    10941081  end;
    1095   DpiBitCanvas(HGrSystem.Mask.Canvas, CityMark2.Left, CityMark2.Top, CityMark1.Width, CityMark1.Width,
     1082  DpiBitBltCanvas(HGrSystem.Mask.Canvas, CityMark2.Left, CityMark2.Top, CityMark1.Width, CityMark1.Width,
    10961083    HGrSystem.Mask.Canvas, CityMark1.Left, CityMark1.Top);
    10971084end;
    10981085
    1099 procedure Fill(ca: TDpiCanvas; Left, Top, Width, Height, xOffset, yOffset: Integer);
    1100 begin
    1101   Assert((Left + xOffset >= 0) and (Left + xOffset + Width <= MainTexture.Width) and
    1102     (Top + yOffset >= 0) and (Top + yOffset + Height <= MainTexture.Height));
    1103   DpiBitCanvas(ca, Left, Top, Width, Height, MainTexture.Image.Canvas,
     1086procedure Fill(Canvas: TDpiCanvas; Left, Top, Width, Height, xOffset, yOffset: Integer);
     1087begin
     1088  //Assert((Left + xOffset >= 0) and (Left + xOffset + Width <= MainTexture.Width) and
     1089  //  (Top + yOffset >= 0) and (Top + yOffset + Height <= MainTexture.Height));
     1090  DpiBitBltCanvas(Canvas, Left, Top, Width, Height, MainTexture.Image.Canvas,
    11041091    Left + xOffset, Top + yOffset);
    11051092end;
     
    11101097end;
    11111098
    1112 procedure FillLarge(ca: TDpiCanvas; x0, y0, x1, y1, xm: Integer);
     1099procedure FillLarge(Canvas: TDpiCanvas; x0, y0, x1, y1, xm: Integer);
    11131100
    11141101  function Band(I: Integer): Integer;
    11151102  var
    1116     n: integer;
     1103    N: Integer;
    11171104  begin
    1118     n := ((MainTexture.Height div 2) div (y1 - y0)) * 2;
     1105    N := ((MainTexture.Height div 2) div (y1 - y0)) * 2;
    11191106    while MainTexture.Height div 2 + (I + 1) * (y1 - y0) > MainTexture.Height do
    1120       Dec(I, n);
     1107      Dec(I, N);
    11211108    while MainTexture.Height div 2 + I * (y1 - y0) < 0 do
    1122       Inc(I, n);
     1109      Inc(I, N);
    11231110    Result := I;
    11241111  end;
     
    11281115begin
    11291116  for I := 0 to (x1 - xm) div MainTexture.Width - 1 do
    1130     DpiBitCanvas(ca, xm + I * MainTexture.Width, y0, MainTexture.Width, y1 - y0,
     1117    DpiBitBltCanvas(Canvas, xm + I * MainTexture.Width, y0, MainTexture.Width, y1 - y0,
    11311118      MainTexture.Image.Canvas, 0, MainTexture.Height div 2 + Band(I) *
    11321119      (y1 - y0));
    1133   DpiBitCanvas(ca, xm + ((x1 - xm) div MainTexture.Width) * MainTexture.Width, y0,
     1120  DpiBitBltCanvas(Canvas, xm + ((x1 - xm) div MainTexture.Width) * MainTexture.Width, y0,
    11341121    x1 - (xm + ((x1 - xm) div MainTexture.Width) * MainTexture.Width), y1 - y0,
    11351122    MainTexture.Image.Canvas, 0, MainTexture.Height div 2 + Band(
    11361123    (x1 - xm) div MainTexture.Width) * (y1 - y0));
    11371124  for I := 0 to (xm - x0) div MainTexture.Width - 1 do
    1138     DpiBitCanvas(ca, xm - (I + 1) * MainTexture.Width, y0, MainTexture.Width, y1 - y0,
     1125    DpiBitBltCanvas(Canvas, xm - (I + 1) * MainTexture.Width, y0, MainTexture.Width, y1 - y0,
    11391126      MainTexture.Image.Canvas, 0, MainTexture.Height div 2 +
    11401127      Band(-I - 1) * (y1 - y0));
    1141   DpiBitCanvas(ca, x0, y0, xm - ((xm - x0) div MainTexture.Width) *
     1128  DpiBitBltCanvas(Canvas, x0, y0, xm - ((xm - x0) div MainTexture.Width) *
    11421129    MainTexture.Width - x0, y1 - y0, MainTexture.Image.Canvas,
    11431130    ((xm - x0) div MainTexture.Width + 1) * MainTexture.Width - (xm - x0),
     
    11451132end;
    11461133
    1147 procedure FillSeamless(ca: TDpiCanvas; Left, Top, Width, Height, xOffset, yOffset: Integer;
     1134procedure FillSeamless(Canvas: TDpiCanvas; Left, Top, Width, Height, xOffset, yOffset: Integer;
    11481135  const Texture: TDpiBitmap);
    11491136var
    1150   x, y, x0cut, y0cut, x1cut, y1cut: Integer;
     1137  X, Y, x0cut, y0cut, x1cut, y1cut: Integer;
    11511138begin
    11521139  while xOffset < 0 do
     
    11541141  while yOffset < 0 do
    11551142    Inc(yOffset, Texture.Height);
    1156   for y := (Top + yOffset) div Texture.Height to (Top + yOffset + Height - 1) div
     1143  for Y := (Top + yOffset) div Texture.Height to (Top + yOffset + Height - 1) div
    11571144    Texture.Height do
    11581145  begin
    1159     y0cut := Top + yOffset - y * Texture.Height;
     1146    y0cut := Top + yOffset - Y * Texture.Height;
    11601147    if y0cut < 0 then
    11611148      y0cut := 0;
    1162     y1cut := (y + 1) * Texture.Height - (Top + yOffset + Height);
     1149    y1cut := (Y + 1) * Texture.Height - (Top + yOffset + Height);
    11631150    if y1cut < 0 then
    11641151      y1cut := 0;
    1165     for x := (Left + xOffset) div Texture.Width to (Left + xOffset + Width - 1) div
     1152    for X := (Left + xOffset) div Texture.Width to (Left + xOffset + Width - 1) div
    11661153      Texture.Width do
    11671154    begin
    1168       x0cut := Left + xOffset - x * Texture.Width;
     1155      x0cut := Left + xOffset - X * Texture.Width;
    11691156      if x0cut < 0 then
    11701157        x0cut := 0;
    1171       x1cut := (x + 1) * Texture.Width - (Left + xOffset + Width);
     1158      x1cut := (X + 1) * Texture.Width - (Left + xOffset + Width);
    11721159      if x1cut < 0 then
    11731160        x1cut := 0;
    1174       DpiBitCanvas(ca, x * Texture.Width + x0cut - xOffset,
    1175         y * Texture.Height + y0cut - yOffset, Texture.Width - x0cut - x1cut,
     1161      DpiBitBltCanvas(Canvas, X * Texture.Width + x0cut - xOffset,
     1162        Y * Texture.Height + y0cut - yOffset, Texture.Width - x0cut - x1cut,
    11761163        Texture.Height - y0cut - y1cut, Texture.Canvas, x0cut, y0cut);
    11771164    end;
     
    11791166end;
    11801167
    1181 procedure FillRectSeamless(ca: TDpiCanvas; x0, y0, x1, y1, xOffset, yOffset: Integer;
     1168procedure FillRectSeamless(Canvas: TDpiCanvas; x0, y0, x1, y1, xOffset, yOffset: Integer;
    11821169  const Texture: TDpiBitmap);
    11831170begin
    1184   FillSeamless(ca, x0, y0, x1 - x0, y1 - y0, xOffset, yOffset, Texture);
     1171  FillSeamless(Canvas, x0, y0, x1 - x0, y1 - y0, xOffset, yOffset, Texture);
    11851172end;
    11861173
     
    11911178end;
    11921179
    1193 procedure Corner(ca: TDpiCanvas; x, y, Kind: Integer; T: TTexture);
    1194 begin
    1195   { DpiBitCanvas(ca,x,y,8,8,T.HGr.Mask.Canvas,
     1180procedure Corner(Canvas: TDpiCanvas; X, Y, Kind: Integer; T: TTexture);
     1181begin
     1182  { DpiBitBltCanvas(Canvas,x,y,8,8,T.HGr.Mask.Canvas,
    11961183    T.xGr+29+Kind*9,T.yGr+89,SRCAND);
    1197     DpiBitCanvas(ca,x,y,8,8,T.HGr.Data.Canvas,
     1184    DpiBitBltCanvas(Canvas,X,Y,8,8,T.HGr.Data.Canvas,
    11981185    T.xGr+29+Kind*9,T.yGr+89,SRCPAINT); }
    11991186end;
    12001187
    1201 procedure BiColorTextOut(ca: TDpiCanvas; clMain, clBack: TColor; x, y: Integer; s: string);
    1202 
    1203   procedure PaintIcon(x, y, Kind: Integer);
     1188procedure BiColorTextOut(Canvas: TDpiCanvas; clMain, clBack: TColor; X, Y: Integer; S: string);
     1189
     1190  procedure PaintIcon(X, Y, Kind: Integer);
    12041191  begin
    1205     DpiBitCanvas(ca, x, y + 6, 10, 10, HGrSystem.Mask.Canvas,
     1192    DpiBitBltCanvas(Canvas, X, Y + 6, 10, 10, HGrSystem.Mask.Canvas,
    12061193      66 + Kind mod 11 * 11, 115 + Kind div 11 * 11, SRCAND);
    1207     DpiBitCanvas(ca, x, y + 6, 10, 10, HGrSystem.Data.Canvas,
     1194    DpiBitBltCanvas(Canvas, X, Y + 6, 10, 10, HGrSystem.Data.Canvas,
    12081195      66 + Kind mod 11 * 11, 115 + Kind div 11 * 11, SRCPAINT);
    12091196  end;
    12101197
    12111198var
    1212   p, xp: Integer;
     1199  P, xp: Integer;
    12131200  sp: string;
    12141201  shadow: Boolean;
    12151202  Text: string;
    12161203begin
    1217   Inc(x);
    1218   Inc(y);
     1204  Inc(X);
     1205  Inc(Y);
    12191206  for shadow := True downto False do
    1220     with ca do
     1207    with Canvas do
    12211208      if not shadow or (clBack <> $7F007F) then
    12221209      begin
     
    12251212        else
    12261213          Font.Color := clMain;
    1227         sp := s;
    1228         xp := x;
     1214        sp := S;
     1215        xp := X;
    12291216        repeat
    1230           p := pos('%', sp);
    1231           if (p = 0) or (p + 1 > Length(sp)) or not
    1232             (sp[p + 1] in ['c', 'f', 'l', 'm', 'n', 'o', 'p', 'r', 't', 'w']) then
     1217          P := Pos('%', sp);
     1218          if (P = 0) or (P + 1 > Length(sp)) or not
     1219            (sp[P + 1] in ['c', 'f', 'l', 'm', 'n', 'o', 'p', 'r', 't', 'w']) then
    12331220          begin
    1234             ca.Textout(xp, y, sp);
     1221            Canvas.Textout(xp, Y, sp);
    12351222            Break;
    12361223          end
    12371224          else
    12381225          begin
    1239             Text := Copy(sp, 1, p - 1);
    1240             Textout(xp, y, Text);
    1241             Inc(xp, ca.TextWidth(Text));
     1226            Text := Copy(sp, 1, P - 1);
     1227            Textout(xp, Y, Text);
     1228            Inc(xp, Canvas.TextWidth(Text));
    12421229            if not shadow then
    1243               case sp[p + 1] of
    1244                 'c': PaintIcon(xp + 1, y, 6);
    1245                 'f': PaintIcon(xp + 1, y, 0);
    1246                 'l': PaintIcon(xp + 1, y, 8);
    1247                 'm': PaintIcon(xp + 1, y, 17);
    1248                 'n': PaintIcon(xp + 1, y, 7);
    1249                 'o': PaintIcon(xp + 1, y, 16);
    1250                 'p': PaintIcon(xp + 1, y, 2);
    1251                 'r': PaintIcon(xp + 1, y, 12);
    1252                 't': PaintIcon(xp + 1, y, 4);
    1253                 'w': PaintIcon(xp + 1, y, 13);
     1230              case sp[P + 1] of
     1231                'c': PaintIcon(xp + 1, Y, 6);
     1232                'f': PaintIcon(xp + 1, Y, 0);
     1233                'l': PaintIcon(xp + 1, Y, 8);
     1234                'm': PaintIcon(xp + 1, Y, 17);
     1235                'n': PaintIcon(xp + 1, Y, 7);
     1236                'o': PaintIcon(xp + 1, Y, 16);
     1237                'p': PaintIcon(xp + 1, Y, 2);
     1238                'r': PaintIcon(xp + 1, Y, 12);
     1239                't': PaintIcon(xp + 1, Y, 4);
     1240                'w': PaintIcon(xp + 1, Y, 13);
    12541241              end;
    12551242            Inc(xp, 10);
    1256             Delete(sp, 1, p + 1);
     1243            Delete(sp, 1, P + 1);
    12571244          end;
    12581245        until False;
    1259         Dec(x);
    1260         Dec(y);
     1246        Dec(X);
     1247        Dec(Y);
    12611248      end;
    12621249end;
    12631250
    1264 function BiColorTextWidth(ca: TDpiCanvas; s: string): Integer;
     1251function BiColorTextWidth(Canvas: TDpiCanvas; S: string): Integer;
    12651252var
    12661253  P: Integer;
     
    12681255  Result := 1;
    12691256  repeat
    1270     P := Pos('%', s);
    1271     if (P = 0) or (P = Length(s)) then
     1257    P := Pos('%', S);
     1258    if (P = 0) or (P = Length(S)) then
    12721259    begin
    1273       Inc(Result, ca.TextWidth(s));
     1260      Inc(Result, Canvas.TextWidth(S));
    12741261      Break;
    12751262    end
    12761263    else
    12771264    begin
    1278       if not (s[P + 1] in ['c', 'f', 'l', 'm', 'n', 'o', 'p', 'r', 't', 'w'])
     1265      if not (S[P + 1] in ['c', 'f', 'l', 'm', 'n', 'o', 'p', 'r', 't', 'w'])
    12791266      then
    1280         Inc(Result, ca.TextWidth(copy(s, 1, P + 1)))
     1267        Inc(Result, Canvas.TextWidth(Copy(S, 1, P + 1)))
    12811268      else
    1282         Inc(Result, ca.TextWidth(copy(s, 1, P - 1)) + 10);
    1283       Delete(s, 1, P + 1);
     1269        Inc(Result, Canvas.TextWidth(Copy(S, 1, P - 1)) + 10);
     1270      Delete(S, 1, P + 1);
    12841271    end;
    12851272  until False;
    12861273end;
    12871274
    1288 procedure LoweredTextOut(ca: TDpiCanvas; cl: TColor; T: TTexture;
    1289   x, y: Integer; s: string);
     1275procedure LoweredTextOut(Canvas: TDpiCanvas; cl: TColor; T: TTexture;
     1276  X, Y: Integer; S: string);
    12901277begin
    12911278  if cl = -2 then
    1292     BiColorTextOut(ca, (T.ColorBevelShade and $FEFEFE) shr 1,
    1293       T.ColorBevelLight, x, y, s)
     1279    BiColorTextOut(Canvas, (T.ColorBevelShade and $FEFEFE) shr 1,
     1280      T.ColorBevelLight, X, Y, S)
    12941281  else if cl < 0 then
    1295     BiColorTextOut(ca, T.ColorTextShade, T.ColorTextLight, x, y, s)
     1282    BiColorTextOut(Canvas, T.ColorTextShade, T.ColorTextLight, X, Y, S)
    12961283  else
    1297     BiColorTextOut(ca, cl, T.ColorTextLight, x, y, s);
    1298 end;
    1299 
    1300 procedure RisedTextOut(ca: TDpiCanvas; x, y: integer; s: string);
    1301 begin
    1302   BiColorTextOut(ca, $FFFFFF, $000000, x, y, s);
    1303 end;
    1304 
    1305 procedure Gradient(ca: TDpiCanvas; x, y, dx, dy, Width, Height, Color: Integer;
    1306   Brightness: array of integer);
    1307 var
    1308   i, r, g, b: Integer;
    1309 begin
    1310   for i := 0 to Length(Brightness) - 1 do begin // gradient
    1311     r := Color and $FF + Brightness[i];
    1312     if r < 0 then
    1313       r := 0
    1314     else if r >= 256 then
    1315       r := 255;
    1316     g := Color shr 8 and $FF + Brightness[i];
    1317     if g < 0 then
    1318       g := 0
    1319     else if g >= 256 then
    1320       g := 255;
    1321     b := Color shr 16 and $FF + Brightness[i];
    1322     if b < 0 then
    1323       b := 0
    1324     else if b >= 256 then
    1325       b := 255;
    1326     ca.Pen.Color := r + g shl 8 + b shl 16;
    1327     ca.MoveTo(x + dx * i, y + dy * i);
    1328     ca.LineTo(x + dx * i + Width, y + dy * i + Height);
    1329   end;
    1330   ca.Pen.Color := $000000;
    1331   ca.MoveTo(x + 1, y + 16 * dy + Height);
    1332   ca.LineTo(x + 16 * dx + Width, y + 16 * dy + Height);
    1333   ca.LineTo(x + 16 * dx + Width, y);
    1334 end;
    1335 
    1336 procedure LightGradient(ca: TDpiCanvas; x, y, Width, Color: Integer);
     1284    BiColorTextOut(Canvas, cl, T.ColorTextLight, X, Y, S);
     1285end;
     1286
     1287procedure RisedTextOut(Canvas: TDpiCanvas; X, Y: Integer; S: string);
     1288begin
     1289  BiColorTextOut(Canvas, $FFFFFF, $000000, X, Y, S);
     1290end;
     1291
     1292procedure Gradient(Canvas: TDpiCanvas; X, Y, dx, dy, Width, Height, Color: Integer;
     1293  Brightness: array of Integer);
     1294var
     1295  I, R, G, B: Integer;
     1296begin
     1297  for I := 0 to Length(Brightness) - 1 do begin // gradient
     1298    R := Color and $FF + Brightness[I];
     1299    if R < 0 then
     1300      R := 0
     1301    else if R >= 256 then
     1302      R := 255;
     1303    G := Color shr 8 and $FF + Brightness[I];
     1304    if G < 0 then
     1305      G := 0
     1306    else if G >= 256 then
     1307      G := 255;
     1308    B := Color shr 16 and $FF + Brightness[I];
     1309    if B < 0 then
     1310      B := 0
     1311    else if B >= 256 then
     1312      B := 255;
     1313    Canvas.Pen.Color := R + G shl 8 + B shl 16;
     1314    Canvas.MoveTo(X + dx * I, Y + dy * I);
     1315    Canvas.LineTo(X + dx * I + Width, Y + dy * I + Height);
     1316  end;
     1317  Canvas.Pen.Color := $000000;
     1318  Canvas.MoveTo(X + 1, Y + 16 * dy + Height);
     1319  Canvas.LineTo(X + 16 * dx + Width, Y + 16 * dy + Height);
     1320  Canvas.LineTo(X + 16 * dx + Width, Y);
     1321end;
     1322
     1323procedure LightGradient(Canvas: TDpiCanvas; X, Y, Width, Color: Integer);
    13371324const
    1338   Brightness: array [0 .. 15] of integer =
     1325  Brightness: array [0 .. 15] of Integer =
    13391326    (16, 12, 8, 4, 0, -4, -8, -12, -16, -20, -24, -28, -32, -36, -40, -44);
    13401327begin
    1341   Gradient(ca, x, y, 0, 1, Width, 0, Color, Brightness);
    1342 end;
    1343 
    1344 procedure DarkGradient(ca: TDpiCanvas; x, y, Width, Kind: Integer);
     1328  Gradient(Canvas, X, Y, 0, 1, Width, 0, Color, Brightness);
     1329end;
     1330
     1331procedure DarkGradient(Canvas: TDpiCanvas; X, Y, Width, Kind: Integer);
    13451332const
    1346   Brightness: array [0 .. 15] of integer =
     1333  Brightness: array [0 .. 15] of Integer =
    13471334    (16, 12, 8, 4, 0, -4, -8, -12 - 24, -16 + 16, -20, -24, -28, -32, -36, -40, -44);
    13481335begin
    1349   Gradient(ca, x, y, 0, 1, Width, 0, HGrSystem.Data.Canvas.Pixels
     1336  Gradient(Canvas, X, Y, 0, 1, Width, 0, HGrSystem.Data.Canvas.Pixels
    13501337    [187, 137 + Kind], Brightness);
    13511338end;
    13521339
    1353 procedure VLightGradient(ca: TDpiCanvas; x, y, Height, Color: Integer);
     1340procedure VLightGradient(Canvas: TDpiCanvas; X, Y, Height, Color: Integer);
    13541341const
    1355   Brightness: array [0 .. 15] of integer =
     1342  Brightness: array [0 .. 15] of Integer =
    13561343    (16, 12, 8, 4, 0, -4, -8, -12, -16, -20, -24, -28, -32, -36, -40, -44);
    13571344begin
    1358   Gradient(ca, x, y, 1, 0, 0, Height, Color, Brightness);
    1359 end;
    1360 
    1361 procedure VDarkGradient(ca: TDpiCanvas; x, y, Height, Kind: Integer);
     1345  Gradient(Canvas, X, Y, 1, 0, 0, Height, Color, Brightness);
     1346end;
     1347
     1348procedure VDarkGradient(Canvas: TDpiCanvas; X, Y, Height, Kind: Integer);
    13621349const
    1363   Brightness: array [0 .. 15] of integer =
     1350  Brightness: array [0 .. 15] of Integer =
    13641351    (16, 12, 8, 4, 0, -4, -8, -12 - 24, -16 + 16, -20, -24, -28, -32, -36, -40, -44);
    13651352begin
    1366   Gradient(ca, x, y, 1, 0, 0, Height,
     1353  Gradient(Canvas, X, Y, 1, 0, 0, Height,
    13671354    HGrSystem.Data.Canvas.Pixels[187, 137 + Kind], Brightness);
    13681355end;
     
    13751362end;
    13761363
    1377 procedure NumberBar(dst: TDpiBitmap; x, y: integer; Cap: string;
     1364procedure NumberBar(dst: TDpiBitmap; X, Y: Integer; Cap: string;
    13781365  val: Integer; T: TTexture);
    13791366var
    1380   s: string;
     1367  S: string;
    13811368begin
    13821369  if val > 0 then
    13831370  begin
    1384     DLine(dst.Canvas, x - 2, x + 170, y + 16, T.ColorBevelShade,
     1371    DLine(dst.Canvas, X - 2, X + 170, Y + 16, T.ColorBevelShade,
    13851372      T.ColorBevelLight);
    1386     LoweredTextOut(dst.Canvas, -1, T, x - 2, y, Cap);
    1387     s := IntToStr(val);
    1388     RisedTextOut(dst.Canvas, x + 170 - BiColorTextWidth(dst.Canvas,
    1389       s), y, s);
    1390   end;
    1391 end;
    1392 
    1393 procedure CountBar(dst: TDpiBitmap; x, y, w: Integer; Kind: Integer;
     1373    LoweredTextOut(dst.Canvas, -1, T, X - 2, Y, Cap);
     1374    S := IntToStr(val);
     1375    RisedTextOut(dst.Canvas, X + 170 - BiColorTextWidth(dst.Canvas,
     1376      S), Y, S);
     1377  end;
     1378end;
     1379
     1380procedure CountBar(dst: TDpiBitmap; X, Y, W: Integer; Kind: Integer;
    13941381  Cap: string; val: Integer; T: TTexture);
    13951382var
    1396   i, sd, ld, cl, xIcon, yIcon: Integer;
    1397   s: string;
     1383  I, sd, ld, cl, xIcon, yIcon: Integer;
     1384  S: string;
    13981385begin
    13991386  // val:=random(40); //!!!
     
    14071394    // DLine(dst.Canvas,x-2,x+170+32,y+16,T.ColorBevelShade,T.ColorBevelLight);
    14081395
    1409     xIcon := x - 5;
    1410     yIcon := y + 15;
    1411     DLine(dst.Canvas, x - 2, xIcon + w + 2, yIcon + 16, T.ColorBevelShade,
     1396    xIcon := X - 5;
     1397    yIcon := Y + 15;
     1398    DLine(dst.Canvas, X - 2, xIcon + W + 2, yIcon + 16, T.ColorBevelShade,
    14121399      T.ColorBevelLight);
    14131400
    1414     s := IntToStr(val);
     1401    S := IntToStr(val);
    14151402    if val < 0 then
    14161403      cl := $0000FF
    14171404    else
    14181405      cl := -1;
    1419     LoweredTextOut(dst.Canvas, cl, T, x - 2, y, Cap);
     1406    LoweredTextOut(dst.Canvas, cl, T, X - 2, Y, Cap);
    14201407    LoweredTextOut(dst.Canvas, cl, T,
    1421       xIcon + w + 2 - BiColorTextWidth(dst.Canvas, s), yIcon, s);
     1408      xIcon + W + 2 - BiColorTextWidth(dst.Canvas, S), yIcon, S);
    14221409
    14231410    if (Kind = 12) and (val >= 100) then
     
    14271414      if sd = 0 then
    14281415        sd := 1;
    1429       if sd < w - 44 then
     1416      if sd < W - 44 then
    14301417        ld := sd
    14311418      else
    1432         ld := w - 44;
    1433       for i := 0 to val mod 10 - 1 do
     1419        ld := W - 44;
     1420      for I := 0 to val mod 10 - 1 do
    14341421      begin
    1435         DpiBitCanvas(dst.Canvas, xIcon + 4 + i * (14 * ld div sd), yIcon + 2 + 1, 14,
     1422        DpiBitBltCanvas(dst.Canvas, xIcon + 4 + I * (14 * ld div sd), yIcon + 2 + 1, 14,
    14361423          14, HGrSystem.Mask.Canvas, 67 + Kind mod 8 * 15,
    14371424          70 + Kind div 8 * 15, SRCAND);
    1438         Sprite(dst, HGrSystem, xIcon + 3 + i * (14 * ld div sd), yIcon + 2,
     1425        Sprite(dst, HGrSystem, xIcon + 3 + I * (14 * ld div sd), yIcon + 2,
    14391426          14, 14, 67 + Kind mod 8 * 15, 70 + Kind div 8 * 15);
    14401427      end;
    1441       for i := 0 to val div 10 - 1 do
     1428      for I := 0 to val div 10 - 1 do
    14421429      begin
    1443         DpiBitCanvas(dst.Canvas, xIcon + 4 + (val mod 10) *
    1444           (14 * ld div sd) + i * (14 * ld div sd), yIcon + 3, 14, 14,
     1430        DpiBitBltCanvas(dst.Canvas, xIcon + 4 + (val mod 10) *
     1431          (14 * ld div sd) + I * (14 * ld div sd), yIcon + 3, 14, 14,
    14451432          HGrSystem.Mask.Canvas, 67 + 7 mod 8 * 15,
    14461433          70 + 7 div 8 * 15, SRCAND);
    14471434        Sprite(dst, HGrSystem, xIcon + 3 + (val mod 10) *
    1448           (14 * ld div sd) + i * (14 * ld div sd), yIcon + 2, 14,
     1435          (14 * ld div sd) + I * (14 * ld div sd), yIcon + 2, 14,
    14491436          14, 67 + 7 mod 8 * 15,
    14501437          70 + 7 div 8 * 15);
     
    14601447      if sd = 0 then
    14611448        sd := 1;
    1462       if sd < w - 44 then
     1449      if sd < W - 44 then
    14631450        ld := sd
    14641451      else
    1465         ld := w - 44;
    1466       for i := 0 to val div 10 - 1 do
     1452        ld := W - 44;
     1453      for I := 0 to val div 10 - 1 do
    14671454      begin
    1468         DpiBitCanvas(dst.Canvas, xIcon + 4 + i * (14 * ld div sd), yIcon + 3, 14, 14,
     1455        DpiBitBltCanvas(dst.Canvas, xIcon + 4 + I * (14 * ld div sd), yIcon + 3, 14, 14,
    14691456          HGrSystem.Mask.Canvas, 67 + Kind mod 8 * 15,
    14701457          70 + Kind div 8 * 15, SRCAND);
    1471         Sprite(dst, HGrSystem, xIcon + 3 + i * (14 * ld div sd), yIcon + 2,
     1458        Sprite(dst, HGrSystem, xIcon + 3 + I * (14 * ld div sd), yIcon + 2,
    14721459          14, 14, 67 + Kind mod 8 * 15, 70 + Kind div 8 * 15);
    14731460      end;
    1474       for i := 0 to val mod 10 - 1 do
     1461      for I := 0 to val mod 10 - 1 do
    14751462      begin
    1476         DpiBitCanvas(dst.Canvas, xIcon + 4 + (val div 10) *
    1477           (14 * ld div sd) + i * (10 * ld div sd), yIcon + 7, 10, 10,
     1463        DpiBitBltCanvas(dst.Canvas, xIcon + 4 + (val div 10) *
     1464          (14 * ld div sd) + I * (10 * ld div sd), yIcon + 7, 10, 10,
    14781465          HGrSystem.Mask.Canvas, 66 + Kind mod 11 * 11,
    14791466          115 + Kind div 11 * 11, SRCAND);
    14801467        Sprite(dst, HGrSystem, xIcon + 3 + (val div 10) *
    1481           (14 * ld div sd) + i * (10 * ld div sd), yIcon + 6, 10,
     1468          (14 * ld div sd) + I * (10 * ld div sd), yIcon + 6, 10,
    14821469          10, 66 + Kind mod 11 * 11,
    14831470          115 + Kind div 11 * 11);
     
    14871474end;
    14881475
    1489 procedure PaintProgressBar(ca: TDpiCanvas; Kind, x, y, pos, Growth, max: Integer;
     1476procedure PaintProgressBar(Canvas: TDpiCanvas; Kind, X, Y, Pos, Growth, Max: Integer;
    14901477  T: TTexture);
    14911478var
    1492   i: Integer;
    1493 begin
    1494   if pos > max then
    1495     pos := max;
     1479  I: Integer;
     1480begin
     1481  if Pos > Max then
     1482    Pos := Max;
    14961483  if Growth < 0 then
    14971484  begin
    1498     pos := pos + Growth;
    1499     if pos < 0 then
     1485    Pos := Pos + Growth;
     1486    if Pos < 0 then
    15001487    begin
    1501       Growth := Growth - pos;
    1502       pos := 0;
     1488      Growth := Growth - Pos;
     1489      Pos := 0;
    15031490    end;
    15041491  end
    1505   else if pos + Growth > max then
    1506     Growth := max - pos;
    1507   Frame(ca, x - 1, y - 1, x + max, y + 7, $000000, $000000);
    1508   RFrame(ca, x - 2, y - 2, x + max + 1, y + 8, T.ColorBevelShade,
     1492  else if Pos + Growth > Max then
     1493    Growth := Max - Pos;
     1494  Frame(Canvas, X - 1, Y - 1, X + Max, Y + 7, $000000, $000000);
     1495  RFrame(Canvas, X - 2, Y - 2, X + Max + 1, Y + 8, T.ColorBevelShade,
    15091496    T.ColorBevelLight);
    1510   with ca do
     1497  with Canvas do
    15111498  begin
    1512     for i := 0 to pos div 8 - 1 do
    1513       DpiBitCanvas(ca, x + i * 8, y, 8, 7,
     1499    for I := 0 to Pos div 8 - 1 do
     1500      DpiBitBltCanvas(Canvas, X + I * 8, Y, 8, 7,
    15141501        HGrSystem.Data.Canvas, 104, 9 + 8 * Kind);
    1515     DpiBitCanvas(ca, x + 8 * (pos div 8), y, pos - 8 * (pos div 8), 7,
     1502    DpiBitBltCanvas(Canvas, X + 8 * (Pos div 8), Y, Pos - 8 * (Pos div 8), 7,
    15161503      HGrSystem.Data.Canvas, 104, 9 + 8 * Kind);
    15171504    if Growth > 0 then
    15181505    begin
    1519       for i := 0 to Growth div 8 - 1 do
    1520         DpiBitCanvas(ca, x + pos + i * 8, y, 8, 7,
     1506      for I := 0 to Growth div 8 - 1 do
     1507        DpiBitBltCanvas(Canvas, X + Pos + I * 8, Y, 8, 7,
    15211508          HGrSystem.Data.Canvas, 112, 9 + 8 * Kind);
    1522       DpiBitCanvas(ca, x + pos + 8 * (Growth div 8), y,
     1509      DpiBitBltCanvas(Canvas, X + Pos + 8 * (Growth div 8), Y,
    15231510        Growth - 8 * (Growth div 8), 7, HGrSystem.Data.Canvas,
    15241511        112, 9 + 8 * Kind);
     
    15261513    else if Growth < 0 then
    15271514    begin
    1528       for i := 0 to -Growth div 8 - 1 do
    1529         DpiBitCanvas(ca, x + pos + i * 8, y, 8, 7,
     1515      for I := 0 to -Growth div 8 - 1 do
     1516        DpiBitBltCanvas(Canvas, X + Pos + I * 8, Y, 8, 7,
    15301517          HGrSystem.Data.Canvas, 104, 1);
    1531       DpiBitCanvas(ca, x + pos + 8 * (-Growth div 8), y, -Growth -
     1518      DpiBitBltCanvas(Canvas, X + Pos + 8 * (-Growth div 8), Y, -Growth -
    15321519        8 * (-Growth div 8), 7,
    15331520        HGrSystem.Data.Canvas, 104, 1);
    15341521    end;
    15351522    Brush.Color := $000000;
    1536     FillRect(Rect(x + pos + abs(Growth), y, x + max, y + 7));
     1523    FillRect(Rect(X + Pos + abs(Growth), Y, X + Max, Y + 7));
    15371524    Brush.Style := bsClear;
    15381525  end;
     
    15401527
    15411528// pos and growth are relative to max, set size independent
    1542 procedure PaintRelativeProgressBar(ca: TDpiCanvas;
    1543   Kind, x, y, size, pos, Growth, max: Integer; IndicateComplete: Boolean;
     1529procedure PaintRelativeProgressBar(Canvas: TDpiCanvas;
     1530  Kind, X, Y, size, Pos, Growth, Max: Integer; IndicateComplete: Boolean;
    15441531  T: TTexture);
    15451532begin
    15461533  if Growth > 0 then
    1547     PaintProgressBar(ca, Kind, x, y, pos * size div max,
    1548       (Growth * size + max div 2) div max, size, T)
     1534    PaintProgressBar(Canvas, Kind, X, Y, Pos * size div Max,
     1535      (Growth * size + Max div 2) div Max, size, T)
    15491536  else
    1550     PaintProgressBar(ca, Kind, x, y, pos * size div max,
    1551       (Growth * size - max div 2) div max, size, T);
    1552   if IndicateComplete and (pos + Growth >= max) then
    1553     Sprite(ca, HGrSystem, x + size - 10, y - 7, 23, 16, 1, 129);
     1537    PaintProgressBar(Canvas, Kind, X, Y, Pos * size div Max,
     1538      (Growth * size - Max div 2) div Max, size, T);
     1539  if IndicateComplete and (Pos + Growth >= Max) then
     1540    Sprite(Canvas, HGrSystem, X + size - 10, Y - 7, 23, 16, 1, 129);
    15541541end;
    15551542
     
    15571544begin
    15581545  UnshareBitmap(LogoBuffer);
    1559   DpiBitCanvas(LogoBuffer.Canvas, 0, 0, Logo.Width, Logo.Height, Canvas, X, Y);
     1546  DpiBitBltCanvas(LogoBuffer.Canvas, 0, 0, Logo.Width, Logo.Height, Canvas, X, Y);
    15601547  ImageOp_BCC(LogoBuffer, Templates.Data, Point(0, 0), Logo.BoundsRect,
    15611548    LightColor, ShadeColor);
    1562   DpiBitCanvas(Canvas, X, Y, Logo.Width, Logo.Height, LogoBuffer.Canvas, 0, 0);
     1549  DpiBitBltCanvas(Canvas, X, Y, Logo.Width, Logo.Height, LogoBuffer.Canvas, 0, 0);
    15631550end;
    15641551
     
    16021589  TexWidth := Texture.Width;
    16031590  TexHeight := Texture.Height;
    1604   DstPixel := PixelPointer(Dest);
    1605   SrcPixel := PixelPointer(Texture);
     1591  DstPixel := TPixelPointer.Create(Dest);
     1592  SrcPixel := TPixelPointer.Create(Texture);
    16061593  for Y := 0 to ScaleToNative(Dest.Height) - 1 do begin
    16071594    for X := 0 to ScaleToNative(Dest.Width) - 1 do begin
     
    16211608procedure DarkenImage(Bitmap: TDpiBitmap; Change: Integer);
    16221609var
    1623   x, y: integer;
     1610  X, Y: Integer;
    16241611  PicturePixel: TPixelPointer;
    16251612begin
    16261613  Bitmap.BeginUpdate;
    1627   PicturePixel := PixelPointer(Bitmap);
    1628   for y := 0 to ScaleToNative(Bitmap.Height) - 1 do begin
    1629     for x := 0 to ScaleToNative(Bitmap.Width) - 1 do begin
     1614  PicturePixel := TPixelPointer.Create(Bitmap);
     1615  for Y := 0 to ScaleToNative(Bitmap.Height) - 1 do begin
     1616    for X := 0 to ScaleToNative(Bitmap.Width) - 1 do begin
    16301617      PicturePixel.Pixel^.B := Max(PicturePixel.Pixel^.B - Change, 0);
    16311618      PicturePixel.Pixel^.G := Max(PicturePixel.Pixel^.G - Change, 0);
     
    16451632
    16461633procedure Gtk2Fix;
     1634{$IFDEF UNIX}
    16471635var
    16481636  I: Integer;
    1649 begin
    1650   {$IFDEF LINUX}
     1637{$ENDIF}
     1638begin
     1639  {$IFDEF UNIX}
    16511640  // Wait and process messages little bit to avoid crash or force repaint under Gtk2
    16521641  for I := 0 to 10 do begin
     
    16611650  Section: TFontType;
    16621651  FontScript: TextFile;
    1663   Size: integer;
     1652  Size: Integer;
    16641653  S: string;
    1665   I: integer;
    1666   P: integer;
     1654  I: Integer;
     1655  P: Integer;
    16671656begin
    16681657  Section := ftNormal;
     
    16711660    Reset(FontScript);
    16721661    while not Eof(FontScript) do begin
    1673       ReadLn(FontScript, s);
    1674       if s <> '' then
    1675         if s[1] = '#' then begin
    1676           s := TrimRight(s);
    1677           if s = '#SMALL' then Section := ftSmall
    1678           else if s = '#TINY' then Section := ftTiny
    1679           else if s = '#CAPTION' then Section := ftCaption
    1680           else if s = '#BUTTON' then Section := ftButton
     1662      ReadLn(FontScript, S);
     1663      if S <> '' then
     1664        if S[1] = '#' then begin
     1665          S := TrimRight(S);
     1666          if S = '#SMALL' then Section := ftSmall
     1667          else if S = '#TINY' then Section := ftTiny
     1668          else if S = '#CAPTION' then Section := ftCaption
     1669          else if S = '#BUTTON' then Section := ftButton
    16811670          else Section := ftNormal;
    16821671        end else begin
    1683           p := Pos(',', s);
    1684           if p > 0 then begin
    1685             UniFont[section].Name := Trim(Copy(s, 1, p - 1));
     1672          P := Pos(',', S);
     1673          if P > 0 then begin
     1674            UniFont[section].Name := Trim(Copy(S, 1, P - 1));
    16861675            Size := 0;
    1687             for i := p + 1 to Length(s) do
    1688               case s[i] of
     1676            for I := P + 1 to Length(S) do
     1677              case S[I] of
    16891678                '0' .. '9':
    1690                   Size := Size * 10 + Byte(s[i]) - 48;
     1679                  Size := Size * 10 + Byte(S[I]) - 48;
    16911680                'B', 'b':
    16921681                  UniFont[section].Style := UniFont[section].Style + [fsBold];
     
    17311720  LoadPhrases;
    17321721  LoadFonts;
    1733   Templates := LoadGraphicSet2('Templates.png');
     1722  Templates := LoadGraphicSet('Templates.png', False);
    17341723  with Templates do begin
    17351724    Logo := GetItem('Logo');
     
    17701759
    17711760  HGrSystem := LoadGraphicSet('System.png');
    1772   CityMark1 := HGrSystem.GetItem('CityMark1');
    1773   CityMark2 := HGrSystem.GetItem('CityMark2');
     1761  with HGrSystem do begin
     1762    CityMark1 := GetItem('CityMark1');
     1763    CityMark2 := GetItem('CityMark2');
     1764  end;
    17741765
    17751766  HGrSystem2 := LoadGraphicSet('System2.png');
    1776   Ornament := HGrSystem2.GetItem('Ornament');
     1767  with HGrSystem2 do begin
     1768    Ornament := GetItem('Ornament');
     1769    GBrainNoTerm := GetItem('BrainNoTerm');
     1770    GBrainSuperVirtual := GetItem('BrainSuperVirtual');
     1771    GBrainTerm := GetItem('BrainTerm');
     1772    GBrainRandom := GetItem('BrainRandom');
     1773  end;
    17771774
    17781775  Colors := TDpiBitmap.Create;
Note: See TracChangeset for help on using the changeset viewer.