Changeset 617 for trunk/Packages/DpiControls
- Timestamp:
- Sep 15, 2024, 1:31:30 PM (2 months ago)
- Location:
- trunk/Packages/DpiControls
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/DpiControls/Dpi.Common.pas
r608 r617 225 225 function ScaleToNative(Value: Integer): Integer; inline; 226 226 begin 227 Result := ScreenInfo.Lookup [Value];227 Result := ScreenInfo.LookupToNative[Value]; 228 228 // Round and Trunc are fast. Ceil and Floor are slow. 229 229 // Without lookup table we would use: … … 238 238 function ScaleFromNative(Value: Integer): Integer; 239 239 begin 240 Result := Trunc(Value * ScreenInfo.FromNative); 240 Result := ScreenInfo.LookupFromNative[Value]; 241 // Round and Trunc are fast. Ceil and Floor are slow. 242 // Without lookup table we would use: 243 // Result := Floor(Value * ScreenInfo.FromNative); 241 244 end; 242 245 -
trunk/Packages/DpiControls/Dpi.Graphics.pas
r568 r617 354 354 ToNative: Double; 355 355 FromNative: Double; 356 Lookup: array[-10000..10000] of Integer; // Should be sufficient for 8K screens 356 LookupToNative: array[-10000..10000] of Integer; // Should be sufficient for 8K screens 357 LookupFromNative: array[-10000..10000] of Integer; // Should be sufficient for 8K screens 357 358 property Dpi: Integer read FDpi write SetDpi; 358 359 end; … … 1353 1354 if FDpi = AValue then Exit; 1354 1355 FDpi := AValue; 1356 1357 // Precalculate scaling coefficients 1355 1358 ToNative := ScreenInfo.Dpi / 96; 1356 1357 // Precalculate scaling coefficients1359 for I := Low(LookupToNative) to High(LookupToNative) do 1360 LookupToNative[I] := Ceil(I * ToNative); 1358 1361 FromNative := 96 / ScreenInfo.Dpi; 1359 for I := Low(Lookup ) to High(Lookup) do1360 Lookup [I] := Ceil(I * ToNative);1362 for I := Low(LookupFromNative) to High(LookupFromNative) do 1363 LookupFromNative[I] := Floor(I * FromNative); 1361 1364 end; 1362 1365
Note:
See TracChangeset
for help on using the changeset viewer.