Ignore:
Timestamp:
Apr 25, 2024, 8:40:07 PM (3 weeks ago)
Author:
chronos
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/DpiControls/Dpi.Common.pas

    r552 r559  
    2525function SetWindowPos(hWnd: HWND; hWndInsertAfter: HWND;
    2626  X, Y, cx, cy: Integer; uFlags: UINT): Boolean;
    27 function ScaleToNative(Value: Integer): Integer;
     27function ScaleToNative(Value: Integer): Integer; inline;
    2828function ScaleToNativeDist(Base, Value: Integer): Integer;
    2929function ScaleFromNative(Value: Integer): Integer;
     
    6464  DstPixelX, DstPixelY: Integer;
    6565  DstPixelWidth, DstPixelHeight: Integer;
    66   NewX, NewY: Integer;
     66  NewY: Integer;
    6767begin
    6868  if not Precise or (Frac(ScreenInfo.Dpi / 96) = 0) then begin
     
    107107  Dest.BeginUpdate;
    108108  SrcPixel := TPixelPointer.Create(Src.NativeBitmap);
    109   DstPixel := TPixelPointer.Create(Dest.NativeBitmap);
     109  DstPixel := TPixelPointer.Create(Dest.NativeBitmap, ScaleToNative(X), ScaleToNative(Y));
    110110  if Rop = SRCCOPY then begin
    111111    for YY := 0 to Height - 1 do begin
    112       NewY := ScaleToNative(Y + YY);
    113       DstPixelHeight := ScaleToNative(Y + YY + 1) - NewY;
    114112      SrcPixel.SetXY(0, ScaleToNative(YSrc + YY));
     113      DstPixelHeight := ScaleToNative(Y + YY + 1) - ScaleToNative(Y + YY);
    115114      for DstPixelY := 0 to DstPixelHeight - 1 do begin
    116         DstPixel.SetXY(0, NewY + DstPixelY);
    117115        for XX := 0 to Width - 1 do begin
    118116          SrcPixel.SetX(ScaleToNative(XSrc + XX));
    119           NewX := ScaleToNative(X + XX);
    120           DstPixel.SetX(NewX);
    121           DstPixelWidth := ScaleToNative(X + XX + 1) - NewX;
     117          DstPixelWidth := ScaleToNative(X + XX + 1) - ScaleToNative(X + XX);
    122118          for DstPixelX := 0 to DstPixelWidth - 1 do begin
    123119            DstPixel.PixelRGB := SrcPixel.PixelARGB;
     
    125121          end;
    126122        end;
     123        DstPixel.NextLine;
    127124      end;
    128125    end;
     
    130127  if Rop = SRCPAINT then begin
    131128    for YY := 0 to Height - 1 do begin
    132       NewY := ScaleToNative(Y + YY);
    133       DstPixelHeight := ScaleToNative(Y + YY + 1) - NewY;
    134129      SrcPixel.SetXY(0, ScaleToNative(YSrc + YY));
     130      DstPixelHeight := ScaleToNative(Y + YY + 1) - ScaleToNative(Y + YY);
    135131      for DstPixelY := 0 to DstPixelHeight - 1 do begin
    136         DstPixel.SetXY(0, NewY + DstPixelY);
    137132        for XX := 0 to Width - 1 do begin
    138133          SrcPixel.SetX(ScaleToNative(XSrc + XX));
    139           NewX := ScaleToNative(X + XX);
    140           DstPixel.SetX(NewX);
    141           DstPixelWidth := ScaleToNative(X + XX + 1) - NewX;
     134          DstPixelWidth := ScaleToNative(X + XX + 1) - ScaleToNative(X + XX);
    142135          for DstPixelX := 0 to DstPixelWidth - 1 do begin
    143             DstPixel.PixelRGB := SrcPixel.PixelARGB or DstPixel.PixelARGB;
     136            DstPixel.PixelRGB := DstPixel.PixelRGB or SrcPixel.PixelARGB;
    144137            DstPixel.NextPixel;
    145138          end;
    146139        end;
     140        DstPixel.NextLine;
    147141      end;
    148142    end;
     
    150144  if Rop = SRCAND then begin
    151145    for YY := 0 to Height - 1 do begin
    152       NewY := ScaleToNative(Y + YY);
    153       DstPixelHeight := ScaleToNative(Y + YY + 1) - NewY;
    154146      SrcPixel.SetXY(0, ScaleToNative(YSrc + YY));
     147      DstPixelHeight := ScaleToNative(Y + YY + 1) - ScaleToNative(Y + YY);
    155148      for DstPixelY := 0 to DstPixelHeight - 1 do begin
    156         DstPixel.SetXY(0, NewY + DstPixelY);
    157149        for XX := 0 to Width - 1 do begin
    158150          SrcPixel.SetX(ScaleToNative(XSrc + XX));
    159           NewX := ScaleToNative(X + XX);
    160           DstPixel.SetX(NewX);
    161           DstPixelWidth := ScaleToNative(X + XX + 1) - NewX;
     151          DstPixelWidth := ScaleToNative(X + XX + 1) - ScaleToNative(X + XX);
    162152          for DstPixelX := 0 to DstPixelWidth - 1 do begin
    163             DstPixel.PixelRGB := SrcPixel.PixelARGB and DstPixel.PixelARGB;
     153            DstPixel.PixelRGB := DstPixel.PixelRGB and SrcPixel.PixelARGB;
    164154            DstPixel.NextPixel;
    165155          end;
    166156        end;
     157        DstPixel.NextLine;
    167158      end;
    168159    end;
     
    170161  if Rop = DSTINVERT then begin
    171162    for YY := 0 to Height - 1 do begin
    172       NewY := ScaleToNative(Y + YY);
    173       DstPixelHeight := ScaleToNative(Y + YY + 1) - NewY;
    174163      SrcPixel.SetXY(0, ScaleToNative(YSrc + YY));
     164      DstPixelHeight := ScaleToNative(Y + YY + 1) - ScaleToNative(Y + YY);
    175165      for DstPixelY := 0 to DstPixelHeight - 1 do begin
    176         DstPixel.SetXY(0, NewY + DstPixelY);
    177166        for XX := 0 to Width - 1 do begin
    178167          SrcPixel.SetX(ScaleToNative(XSrc + XX));
    179           NewX := ScaleToNative(X + XX);
    180           DstPixel.SetX(NewX);
    181           DstPixelWidth := ScaleToNative(X + XX + 1) - NewX;
     168          DstPixelWidth := ScaleToNative(X + XX + 1) - ScaleToNative(X + XX);
    182169          for DstPixelX := 0 to DstPixelWidth - 1 do begin
    183             DstPixel.PixelRGB := not DstPixel.PixelARGB;
     170            DstPixel.PixelRGB := not DstPixel.PixelRGB;
    184171            DstPixel.NextPixel;
    185172          end;
    186173        end;
     174        DstPixel.NextLine;
    187175      end;
    188176    end;
     
    236224end;
    237225
    238 function ScaleToNative(Value: Integer): Integer;
     226function ScaleToNative(Value: Integer): Integer; inline;
    239227begin
    240228  Result := ScreenInfo.Lookup[Value];
Note: See TracChangeset for help on using the changeset viewer.