Changeset 247 for branches


Ignore:
Timestamp:
May 21, 2020, 10:30:59 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Enabled scaling under Windows.
  • Fixed: Use correct scaled Windows BitBlt.
  • Modified: Fixed and optimized help watermark method.
Location:
branches/highdpi
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/highdpi/Integrated.lpi

    r246 r247  
    1616      <ResourceType Value="res"/>
    1717      <UseXPManifest Value="True"/>
     18      <XPManifest>
     19        <DpiAware Value="True"/>
     20      </XPManifest>
    1821      <Icon Value="0"/>
    1922      <Resources Count="2">
  • branches/highdpi/LocalPlayer/Help.pas

    r246 r247  
    443443  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;
    447   PaintPtr, CoalPtr: TPixelPointer;
     447  PaintPtr: TPixelPointer;
     448  CoalPtr: TPixelPointer;
    448449  ImpPtr: array [-1..1] of TPixelPointer;
    449450begin
     
    457458  xSrc := iix mod 7 * xSizeBig;
    458459  ySrc := (iix div 7 + 1) * ySizeBig;
    459   for y := 0 to ScaleToNative(ySizeBig) * 2 - 1 do
     460  PaintPtr := PixelPointer(OffScreen, ScaleToNative(x0), ScaleToNative(y0));
     461  CoalPtr := PixelPointer(Templates, ScaleToNative(xCoal), ScaleToNative(yCoal));
     462  for dy := -1 to 1 do
     463    ImpPtr[dy] := PixelPointer(BigImp, ScaleToNative(xSrc), ScaleToNative(ySrc));
     464  for y := 0 to ScaleToNative(ySizeBig) * 2 - 1 do begin
    460465    if ((ScaleToNative(y0) + y) >= 0) and ((ScaleToNative(y0) + y) < ScaleToNative(InnerHeight)) then begin
    461       PaintPtr := PixelPointer(OffScreen, 0, ScaleToNative(y0) + y);
    462       CoalPtr := PixelPointer(Templates, 0, ScaleToNative(yCoal) + y);
    463466      for dy := -1 to 1 do
    464467        if ((Max(y + ScaleToNative(dy), 0) shr 1) >= 0) and ((Max(y + ScaleToNative(dy), 0) shr 1) < ScaleToNative(ySizeBig)) then
    465           ImpPtr[dy] := PixelPointer(BigImp, 0, ScaleToNative(ySrc) + (Max(y + ScaleToNative(dy), 0) shr 1));
    466       for x := 0 to ScaleToNative(xSizeBig) * 2 - 1 do begin
    467         sum := 0;
     468          ImpPtr[dy].SetXY(0, Max(y + ScaleToNative(dy), 0) shr 1);
     469      for x := 0 to ScaleToNative(xSizeBig * 2) - 1 do begin
     470        Sum := 0;
    468471        for dx := -1 to 1 do begin
    469           xx := ScaleToNative(xSrc) + Max((x + ScaleToNative(dx)), 0) shr 1;
     472          xx := Max((x + ScaleToNative(dx)), 0) shr 1;
    470473          for dy := -1 to 1 do begin
    471474            ImpPtr[dy].SetX(xx);
     
    475478              (ImpPtr[dy].Pixel^.B shl 16 + ImpPtr[dy].Pixel^.G shl 8 +
    476479              ImpPtr[dy].Pixel^.R = Heaven[(ScaleFromNative(y) + dy) shr 1]) then
    477               sum := sum + 9 * 255
     480              Sum := Sum + 9 * 255
    478481            else
    479               sum := sum + ImpPtr[dy].Pixel^.B + 5 * ImpPtr[dy].Pixel^.G + 3 *
     482              Sum := Sum + ImpPtr[dy].Pixel^.B + 5 * ImpPtr[dy].Pixel^.G + 3 *
    480483                ImpPtr[dy].Pixel^.R;
    481484          end;
    482485        end;
    483         if sum < MaxSum then begin // no saturation
    484           CoalPtr.SetX(ScaleToNative(xCoal) + x);
    485           sum := 1 shl 22 - (MaxSum - sum) * (256 - CoalPtr.Pixel^.B * 2);
    486           PaintPtr.SetX(x0 + x);
    487           PaintPtr.Pixel^.B := PaintPtr.Pixel^.B * sum shr 22;
    488           PaintPtr.Pixel^.G := PaintPtr.Pixel^.G * sum shr 22;
    489           PaintPtr.Pixel^.R := PaintPtr.Pixel^.R * sum shr 22;
     486        if Sum < MaxSum then begin // no saturation
     487          Sum := 1 shl 22 - (MaxSum - Sum) * (256 - CoalPtr.Pixel^.B * 2);
     488          PaintPtr.Pixel^.B := Min(PaintPtr.Pixel^.B * Sum shr 22, 255);
     489          PaintPtr.Pixel^.G := Min(PaintPtr.Pixel^.G * Sum shr 22, 255);
     490          PaintPtr.Pixel^.R := Min(PaintPtr.Pixel^.R * Sum shr 22, 255);
    490491        end;
     492        PaintPtr.NextPixel;
     493        CoalPtr.NextPixel;
    491494      end;
    492495    end;
     496    PaintPtr.NextLine;
     497    CoalPtr.NextLine;
     498  end;
    493499  Offscreen.EndUpdate;
    494500  BigImp.EndUpdate;
  • branches/highdpi/Packages/CevoComponents/ScreenTools.pas

    r246 r247  
    820820  {$IFDEF WINDOWS}
    821821  // LCLIntf.BitBlt is slower than direct Windows BitBlt
    822   Result := Windows.DpiBitBlt(DestCanvas.Handle, X, Y, Width, Height, SrcCanvas.Handle, XSrc, YSrc, Rop);
     822  Result := DpiBitBlt(DestCanvas.Handle, X, Y, Width, Height, SrcCanvas.Handle, XSrc, YSrc, Rop);
    823823  {$ELSE}
    824824  Result := DpiBitBlt(DestCanvas.Handle, X, Y, Width, Height, SrcCanvas.Handle, XSrc, YSrc, Rop);
  • branches/highdpi/Packages/DpiControls/UDpiControls.pas

    r246 r247  
    66
    77uses
    8   Classes, SysUtils, LCLProc, LResources, Forms, FormEditingIntf, ProjectIntf,
     8  Windows, Classes, SysUtils, LCLProc, LResources, Forms, FormEditingIntf, ProjectIntf,
    99  Controls, StdCtrls, fgl, Graphics, ComCtrls, ExtCtrls, LCLType, GraphType,
    1010  Types, CustApp, LMessages, LCLIntf, Menus;
     
    990990  YSrc: Integer; Rop: DWORD = SRCCOPY): Boolean;
    991991begin
    992   Result := BitBlt(DestDC, ScaleToNative(X), ScaleToNative(Y), ScaleToNative(Width),
    993     ScaleToNative(Height), SrcDC, ScaleToNative(XSrc), ScaleToNative(YSrc), Rop);
     992  {$IFDEF WINDOWS}
     993  // LCLIntf.BitBlt is slower than direct Windows BitBlt
     994  Result := Windows.BitBlt(DestDC, ScaleToNative(X), ScaleToNative(Y),
     995    ScaleToNative(Width), ScaleToNative(Height), SrcDC,
     996    ScaleToNative(XSrc), ScaleToNative(YSrc), Rop);
     997  {$ELSE}
     998  Result := BitBlt(DestDC, ScaleToNative(X), ScaleToNative(Y),
     999    ScaleToNative(Width), ScaleToNative(Height), SrcDC,
     1000    ScaleToNative(XSrc), ScaleToNative(YSrc), Rop);
     1001  {$ENDIF}
    9941002end;
    9951003
Note: See TracChangeset for help on using the changeset viewer.