Ignore:
Timestamp:
Dec 3, 2023, 11:28:08 AM (5 months ago)
Author:
chronos
Message:
  • Added: High DPI support integrated into trunk branch. It can be enabled by adding DPI define to compiler parameters for main project and packages.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/CevoComponents/ScreenTools.pas

    r456 r468  
    77  Windows,
    88  {$ENDIF}
    9   StringTables, LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, Math,
    10   Forms, Menus, GraphType, GraphicSet, LazFileUtils, Texture;
     9  StringTables, LCLIntf, LCLType, SysUtils, Classes, Math,
     10  GraphType, GraphicSet, LazFileUtils, Texture,
     11  {$IFDEF DPI}Dpi.Forms, Dpi.Menus, Dpi.Graphics, Dpi.Controls, Dpi.Common{$ELSE}
     12  Forms, Menus, Graphics, Controls{$ENDIF};
    1113
    1214type
     
    9698procedure Texturize(Dest, Texture: TBitmap; TransparentColor: Cardinal);
    9799procedure DarkenImage(Bitmap: TBitmap; Change: Integer);
     100{$IFNDEF DPI}
    98101function ScaleToNative(Value: Integer): Integer;
    99102function ScaleFromNative(Value: Integer): Integer;
     103{$ENDIF}
    100104procedure UnshareBitmap(Bitmap: TBitmap);
    101105procedure Gtk2Fix;
     
    199203
    200204uses
    201   Directories, Sound, PixelPointer;
     205  {$IFDEF DPI}Dpi.PixelPointer,{$ELSE}PixelPointer,{$ENDIF}
     206  Directories, Sound;
    202207
    203208var
     
    419424        Jpeg.LoadFromFile(FileName);
    420425        if not (gfNoGamma in Options) then
    421           Bmp.PixelFormat := pf24bit;
     426          Bmp.PixelFormat := TPixelFormat.pf24bit;
    422427        Bmp.SetSize(Jpeg.Width, Jpeg.Height);
    423428        Bmp.Canvas.Draw(0, 0, Jpeg);
     
    434439        Png.LoadFromFile(FileName);
    435440        if not (gfNoGamma in Options) then
    436           Bmp.PixelFormat := pf24bit;
     441          Bmp.PixelFormat := TPixelFormat.pf24bit;
    437442        Bmp.SetSize(Png.Width, Png.Height);
    438443        if (Png.RawImage.Description.Format = ricfGray) then
    439444        begin
    440445          // LCL doesn't support 8-bit colors properly. Use 24-bit instead.
    441           Bmp.PixelFormat := pf24bit;
     446          Bmp.PixelFormat := TPixelFormat.pf24bit;
    442447          CopyGray8BitTo24bitBitmap(Bmp, Png);
    443448        end
     
    454459        Bmp.LoadFromFile(FileName);
    455460        if not (gfNoGamma in Options) then
    456           Bmp.PixelFormat := pf24bit;
     461          Bmp.PixelFormat := TPixelFormat.pf24bit;
    457462        Result := True;
    458463      except
     
    634639  Height := ScaleToNative(Height);
    635640  //Assert(Src.PixelFormat = pf8bit);
    636   Assert(dst.PixelFormat = pf24bit);
     641  Assert(dst.PixelFormat = TPixelFormat.pf24bit);
    637642  if xDst < 0 then begin
    638643    Width := Width + xDst;
     
    821826  Height := ScaleToNative(Height);
    822827  bmp.BeginUpdate;
    823   Assert(bmp.PixelFormat = pf24bit);
     828  Assert(bmp.PixelFormat = TPixelFormat.pf24bit);
    824829  Height := Y + Height;
    825830  PixelPtr := TPixelPointer.Create(Bmp, X, Y);
     
    15241529    Brush.Color := $000000;
    15251530    FillRect(Rect(X + Pos + abs(Growth), Y, X + Max, Y + 7));
    1526     Brush.Style := bsClear;
     1531    Brush.Style := TBrushStyle.bsClear;
    15271532  end;
    15281533end;
     
    16271632end;
    16281633
     1634{$IFNDEF DPI}
    16291635function ScaleToNative(Value: Integer): Integer;
    16301636begin
     
    16361642  Result := Value;
    16371643end;
     1644{$ENDIF}
    16381645
    16391646procedure UnshareBitmap(Bitmap: TBitmap);
     
    16911698                  Size := Size * 10 + Byte(S[I]) - 48;
    16921699                'B', 'b':
    1693                   UniFont[section].Style := UniFont[section].Style + [fsBold];
     1700                  UniFont[section].Style := UniFont[section].Style + [TFontStyle.fsBold];
    16941701                'I', 'i':
    1695                   UniFont[section].Style := UniFont[section].Style + [fsItalic];
     1702                  UniFont[section].Style := UniFont[section].Style + [TFontStyle.fsItalic];
    16961703              end;
    1697             UniFont[section].Size := Round(Size * 72 / UniFont[section].PixelsPerInch);
     1704            UniFont[section].Size := Round(Size * ScaleToNative(72) / UniFont[section].PixelsPerInch);
    16981705          end;
    16991706        end;
     
    17831790
    17841791  Colors := TBitmap.Create;
    1785   Colors.PixelFormat := pf24bit;
     1792  Colors.PixelFormat := TPixelFormat.pf24bit;
    17861793  Paper := TBitmap.Create;
    1787   Paper.PixelFormat := pf24bit;
     1794  Paper.PixelFormat := TPixelFormat.pf24bit;
    17881795  BigImp := TBitmap.Create;
    1789   BigImp.PixelFormat := pf24bit;
     1796  BigImp.PixelFormat := TPixelFormat.pf24bit;
    17901797  MainTexture := TTexture.Create;
    17911798  ClickFrameColor := HGrSystem.Data.Canvas.Pixels[187, 175];
     
    17961803
    17971804  LogoBuffer := TBitmap.Create;
    1798   LogoBuffer.PixelFormat := pf24bit;
     1805  LogoBuffer.PixelFormat := TPixelFormat.pf24bit;
    17991806  LogoBuffer.SetSize(BigBook.Width, BigBook.Height);
    18001807end;
Note: See TracChangeset for help on using the changeset viewer.