Ignore:
Timestamp:
May 7, 2020, 7:05:57 PM (4 years ago)
Author:
chronos
Message:
  • Modified: Improved code in HighDPI branch.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/highdpi/Packages/CevoComponents/ScreenTools.pas

    r180 r193  
    410410  Bitmap.BeginUpdate;
    411411  PixelPtr.Init(Bitmap);
    412   for Y := 0 to Bitmap.Height - 1 do begin
    413     for X := 0 to Bitmap.Width - 1 do begin
     412  for Y := 0 to ScaleToVcl(Bitmap.Height) - 1 do begin
     413    for X := 0 to ScaleToVcl(Bitmap.Width) - 1 do begin
    414414      PixelPtr.Pixel^ := ApplyGammaToPixel(PixelPtr.Pixel^);
    415415      PixelPtr.NextPixel;
     
    428428  SrcPtr.Init(Src);
    429429  DstPtr.Init(Dst);
    430   for Y := 0 to Src.Height - 1 do begin
    431     for X := 0 to Src.Width - 1 do begin
     430  for Y := 0 to ScaleToVcl(Src.Height) - 1 do begin
     431    for X := 0 to ScaleToVcl(Src.Width) - 1 do begin
    432432      DstPtr.Pixel^.B := SrcPtr.Pixel^.B;
    433433      DstPtr.Pixel^.G := SrcPtr.Pixel^.B;
     
    607607  PixelPtr: TPixelPointer;
    608608begin
     609  X := ScaleToVcl(X);
     610  Y := ScaleToVcl(Y);
     611  W := ScaleToVcl(W);
     612  H := ScaleToVcl(H);
    609613  Dst.BeginUpdate;
    610614  PixelPtr.Init(Dst, X, Y);
     
    630634  PixelDst: TPixelPointer;
    631635begin
     636  xDst := ScaleToVcl(xDst);
     637  yDst := ScaleToVcl(yDst);
     638  xSrc := ScaleToVcl(xSrc);
     639  ySrc := ScaleToVcl(ySrc);
     640  w := ScaleToVcl(w);
     641  h := ScaleToVcl(h);
    632642  //Assert(Src.PixelFormat = pf8bit);
    633643  Assert(dst.PixelFormat = pf24bit);
     
    642652    yDst := 0;
    643653  end;
    644   if xDst + w > dst.Width then
    645     w := dst.Width - xDst;
    646   if yDst + h > dst.Height then
    647     h := dst.Height - yDst;
     654  if xDst + w > ScaleToVcl(dst.Width) then
     655    w := ScaleToVcl(dst.Width) - xDst;
     656  if yDst + h > ScaleToVcl(dst.Height) then
     657    h := ScaleToVcl(dst.Height) - yDst;
    648658  if (w < 0) or (h < 0) then
    649659    exit;
     
    691701  SrcPixel, DstPixel: TPixelPointer;
    692702begin
     703  xDst := ScaleToVcl(xDst);
     704  yDst := ScaleToVcl(yDst);
     705  xSrc := ScaleToVcl(xSrc);
     706  ySrc := ScaleToVcl(ySrc);
     707  w := ScaleToVcl(w);
     708  h := ScaleToVcl(h);
    693709  if xDst < 0 then begin
    694710    w := w + xDst;
     
    701717    yDst := 0;
    702718  end;
    703   if xDst + w > dst.Width then
    704     w := dst.Width - xDst;
    705   if yDst + h > dst.Height then
    706     h := dst.Height - yDst;
     719  if xDst + w > ScaleToVcl(dst.Width) then
     720    w := ScaleToVcl(dst.Width) - xDst;
     721  if yDst + h > ScaleToVcl(dst.Height) then
     722    h := ScaleToVcl(dst.Height) - yDst;
    707723  if (w < 0) or (h < 0) then
    708724    exit;
     
    756772  PixelPtr: TPixelPointer;
    757773begin
     774  X := ScaleToVcl(X);
     775  Y := ScaleToVcl(Y);
     776  W := ScaleToVcl(W);
     777  H := ScaleToVcl(H);
    758778  bmp.BeginUpdate;
    759779  assert(bmp.PixelFormat = pf24bit);
     
    892912  x, y, ch, r: Integer;
    893913  DstPtr: TPixelPointer;
    894 begin
     914  DpiGlowRange: Integer;
     915begin
     916  DpiGlowRange := ScaleToVcl(GlowRange);
     917  X0 := ScaleToVcl(X0);
     918  Y0 := ScaleToVcl(Y0);
     919  Width := ScaleToVcl(Width);
     920  Height := ScaleToVcl(Height);
    895921  dst.BeginUpdate;
    896922  DstPtr.Init(dst, x0, y0);
    897   for y := -GlowRange + 1 to Height - 1 + GlowRange - 1 do begin
    898     for x := -GlowRange + 1 to Width - 1 + GlowRange - 1 do begin
     923  for y := -DpiGlowRange + 1 to Height - 1 + DpiGlowRange - 1 do begin
     924    for x := -DpiGlowRange + 1 to Width - 1 + DpiGlowRange - 1 do begin
    899925      DstPtr.SetXY(x, y);
    900926      if x < 0 then
     
    924950          DstPtr.Pixel^.Planes[2 - ch] :=
    925951            (DstPtr.Pixel^.Planes[2 - ch] * (r - 1) + (cl shr (8 * ch) and $FF) *
    926             (GlowRange - r)) div (GlowRange - 1);
     952            (DpiGlowRange - r)) div (DpiGlowRange - 1);
    927953    end;
    928954  end;
     
    15591585            // 0.8 constant is compensation for Lazarus as size of fonts against Delphi differs
    15601586            UniFont[section].Size :=
    1561               Round(Size * Screen.PixelsPerInch / UniFont[section].PixelsPerInch * 0.8);
     1587              Round(Size * Screen.PixelsPerInch / UniFont[section].PixelsPerInch);
    15621588          end;
    15631589        end;
Note: See TracChangeset for help on using the changeset viewer.