Changeset 213 for branches


Ignore:
Timestamp:
May 9, 2020, 11:21:54 PM (5 years ago)
Author:
chronos
Message:
  • Fixed: Scale help watermark.
Location:
branches/highdpi
Files:
2 edited

Legend:

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

    r212 r213  
    441441const
    442442  nHeaven = 28;
    443   maxsum = 9 * 9 * 255 * 75 div 100;
     443  MaxSum = 9 * 9 * 255 * 75 div 100;
    444444var
    445   x, y, dx, dy, xSrc, ySrc, sum, xx: integer;
     445  x, y, dx, dy, xSrc, ySrc, Sum, xx: integer;
    446446  Heaven: array [0..nHeaven] of integer;
    447447  PaintPtr: TPixelPointer;
     
    458458  xSrc := iix mod 7 * xSizeBig;
    459459  ySrc := (iix div 7 + 1) * ySizeBig;
    460   for y := 0 to ySizeBig * 2 - 1 do
    461     if ((y0 + y) >= 0) and ((y0 + y) < InnerHeight) then begin
    462       PaintPtr := PixelPointer(OffScreen, 0, y0 + y);
    463       CoalPtr := PixelPointer(Templates, 0, yCoal + y);
     460  for y := 0 to ScaleToVcl(ySizeBig * 2) - 1 do
     461    if ((ScaleToVcl(y0) + y) >= 0) and ((ScaleToVcl(y0) + y) < ScaleToVcl(InnerHeight)) then begin
     462      PaintPtr := PixelPointer(OffScreen, 0, ScaleToVcl(y0) + y);
     463      CoalPtr := PixelPointer(Templates, 0, ScaleToVcl(yCoal) + y);
    464464      for dy := -1 to 1 do
    465         if ((Max(y + dy, 0) shr 1) >= 0) and ((Max(y + dy, 0) shr 1) < ySizeBig) then
    466           ImpPtr[dy] := PixelPointer(BigImp, 0, ySrc + (Max(y + dy, 0) shr 1));
    467       for x := 0 to xSizeBig * 2 - 1 do begin
    468         sum := 0;
     465        if ((Max(y + ScaleToVcl(dy), 0) shr 1) >= 0) and ((Max(y + ScaleToVcl(dy), 0) shr 1) < ScaleToVcl(ySizeBig)) then
     466          ImpPtr[dy] := PixelPointer(BigImp, 0, ScaleToVcl(ySrc) + (Max(y + ScaleToVcl(dy), 0) shr 1));
     467      for x := 0 to ScaleToVcl(xSizeBig * 2) - 1 do begin
     468        Sum := 0;
    469469        for dx := -1 to 1 do begin
    470           xx := xSrc + Max((x + dx), 0) shr 1;
     470          xx := ScaleToVcl(xSrc) + Max((x + ScaleToVcl(dx)), 0) shr 1;
    471471          for dy := -1 to 1 do begin
    472472            ImpPtr[dy].SetX(xx);
    473             if ((y + dy) shr 1 < 0) or ((y + dy) shr 1 >= ySizeBig) or
    474               ((x + dx) shr 1 < 0) or ((x + dx) shr 1 >= xSizeBig) or
    475               ((y + dy) shr 1 < nHeaven) and
     473            if ((y + ScaleToVcl(dy)) shr 1 < 0) or ((y + ScaleToVcl(dy)) shr 1 >= ScaleToVcl(ySizeBig)) or
     474              ((x + ScaleToVcl(dx)) shr 1 < 0) or ((x + ScaleToVcl(dx)) shr 1 >= ScaleToVcl(xSizeBig)) or
     475              ((y + ScaleToVcl(dy)) shr 1 < ScaleToVcl(nHeaven)) and
    476476              (ImpPtr[dy].Pixel^.B shl 16 + ImpPtr[dy].Pixel^.G shl 8 +
    477               ImpPtr[dy].Pixel^.R = Heaven[(y + dy) shr 1]) then
    478               sum := sum + 9 * 255
     477              ImpPtr[dy].Pixel^.R = Heaven[(ScaleFromVcl(y) + dy) shr 1]) then
     478              Sum := Sum + 9 * 255
    479479            else
    480               sum := sum + ImpPtr[dy].Pixel^.B + 5 * ImpPtr[dy].Pixel^.G + 3 *
     480              Sum := Sum + ImpPtr[dy].Pixel^.B + 5 * ImpPtr[dy].Pixel^.G + 3 *
    481481                ImpPtr[dy].Pixel^.R;
    482482          end;
    483483        end;
    484         if sum < maxsum then begin // no saturation
    485           CoalPtr.SetX(xCoal + x);
    486           sum := 1 shl 22 - (maxsum - sum) * (256 - CoalPtr.Pixel^.B * 2);
     484        if Sum < MaxSum then begin // no saturation
     485          CoalPtr.SetX(ScaleToVcl(xCoal) + x);
     486          Sum := 1 shl 22 - (MaxSum - Sum) * (256 - CoalPtr.Pixel^.B * 2);
    487487          PaintPtr.SetX(x0 + x);
    488           PaintPtr.Pixel^.B := PaintPtr.Pixel^.B * sum shr 22;
    489           PaintPtr.Pixel^.G := PaintPtr.Pixel^.G * sum shr 22;
    490           PaintPtr.Pixel^.R := PaintPtr.Pixel^.R * sum shr 22;
     488          PaintPtr.Pixel^.B := PaintPtr.Pixel^.B * Sum shr 22;
     489          PaintPtr.Pixel^.G := PaintPtr.Pixel^.G * Sum shr 22;
     490          PaintPtr.Pixel^.R := PaintPtr.Pixel^.R * Sum shr 22;
    491491        end;
    492492      end;
  • branches/highdpi/Packages/DpiControls/UDpiControls.pas

    r212 r213  
    710710    constructor Create;
    711711    destructor Destroy; override;
     712    procedure UpdateScreen;
    712713    property FormCount: Integer read GetFormCount;
    713714    property Forms[Index: Integer]: TDpiForm read GetForms;
     
    10421043begin
    10431044  GetVclApplication.Initialize;
     1045  DpiScreen.UpdateScreen;
    10441046end;
    10451047
     
    21722174  FForms := TDpiForms.Create;
    21732175  FForms.FreeObjects := False;
    2174   Dpi := Round(96 * 2); //Screen.PixelsPerInch;
     2176  // Screen.PixelsPerInch is not initialized at this point
     2177  Dpi := 96;
    21752178end;
    21762179
     
    21792182  FreeAndNil(FForms);
    21802183  inherited Destroy;
     2184end;
     2185
     2186procedure TDpiScreen.UpdateScreen;
     2187begin
     2188  Dpi := Screen.PixelsPerInch;
    21812189end;
    21822190
Note: See TracChangeset for help on using the changeset viewer.