Changeset 514 for trunk/Packages/DpiControls
- Timestamp:
- Jan 3, 2024, 3:05:32 PM (11 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/DpiControls/Dpi.Common.pas
r476 r514 5 5 uses 6 6 {$IFDEF WINDOWS}Windows,{$ENDIF} 7 Classes, SysUtils, LCLType, Types, LCLIntf, Graphics, Dpi.Graphics;7 Classes, SysUtils, LCLType, Types, Math, LCLIntf, Graphics, Dpi.Graphics; 8 8 9 9 const … … 100 100 function ScaleToNative(Value: Integer): Integer; 101 101 begin 102 Result := Round(Value * ScreenInfo.Dpi / 96);102 Result := Ceil(Value * ScreenInfo.Dpi / 96); 103 103 end; 104 104 … … 110 110 function ScaleFromNative(Value: Integer): Integer; 111 111 begin 112 Result := Round(Value * 96 / ScreenInfo.Dpi);112 Result := Floor(Value * 96 / ScreenInfo.Dpi); 113 113 end; 114 114 … … 185 185 DstWidth, DstHeight: Integer; 186 186 SrcWidth, SrcHeight: Integer; 187 ReduceWidth, ReduceHeight: Integer; 187 188 begin 188 189 {$IFDEF WINDOWS} … … 193 194 {$ELSE} 194 195 195 196 196 DstWidth := ScaleToNativeDist(X, Width); 197 197 DstHeight := ScaleToNativeDist(Y, Height); 198 198 SrcWidth := ScaleToNativeDist(XSrc, Width); 199 199 SrcHeight := ScaleToNativeDist(YSrc, Height); 200 if (Frac(ScaleFloatToNative(XSrc)) > 0) or 201 (Frac(ScaleFloatToNative(X)) > 0) then ReduceWidth := 1 202 else ReduceWidth := 0; 203 if (Frac(ScaleFloatToNative(YSrc)) > 0) or 204 (Frac(ScaleFloatToNative(Y)) > 0) then ReduceHeight := 1 205 else ReduceHeight := 0; 200 206 if (DstWidth = SrcWidth) and (DstHeight = SrcHeight) then begin 201 207 Result := LCLIntf.BitBlt(DestDC, ScaleToNative(X), ScaleToNative(Y), … … 204 210 end else begin 205 211 Result := LCLIntf.BitBlt(DestDC, ScaleToNative(X), ScaleToNative(Y), 206 DstWidth , DstHeight, SrcDC,212 DstWidth - ReduceWidth, DstHeight - ReduceHeight, SrcDC, 207 213 ScaleToNative(XSrc), ScaleToNative(YSrc), Rop); 208 { Result := LCLIntfStretchBlt(DestDC, ScaleToNative(X), ScaleToNative(Y), 214 215 // Instead calling StretchBlt for entire region try to draw missing part with BitBlt 216 if DstWidth > SrcWidth then begin 217 LCLIntf.BitBlt(DestDC, ScaleToNative(X) + SrcWidth, ScaleToNative(Y), 218 DstWidth - SrcWidth, DstHeight, SrcDC, 219 ScaleToNative(XSrc) + SrcWidth - (DstWidth - SrcWidth), ScaleToNative(YSrc), Rop); 220 end; 221 if DstHeight > SrcHeight then begin 222 LCLIntf.BitBlt(DestDC, ScaleToNative(X), ScaleToNative(Y) + SrcHeight, 223 DstWidth, DstHeight - SrcHeight, SrcDC, 224 ScaleToNative(XSrc), ScaleToNative(YSrc) + SrcHeight - (DstHeight - SrcHeight), Rop); 225 end; 226 227 { Result := LCLIntf.StretchBlt(DestDC, ScaleToNative(X), ScaleToNative(Y), 209 228 DstWidth, DstHeight, SrcDC, 210 229 ScaleToNative(XSrc), ScaleToNative(YSrc), 211 SrcWidth, SrcHeight, Rop); 212 }end;230 SrcWidth, SrcHeight, Rop);} 231 end; 213 232 214 233 { Result := LCLIntf.BitBlt(DestDC, ScaleToNative(X), ScaleToNative(Y),
Note:
See TracChangeset
for help on using the changeset viewer.