Changeset 514 for trunk/Packages


Ignore:
Timestamp:
Jan 3, 2024, 3:05:32 PM (11 months ago)
Author:
chronos
Message:
Location:
trunk/Packages
Files:
2 edited

Legend:

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

    r512 r514  
    9797  T: TTexture);
    9898procedure PaintLogo(Canvas: TCanvas; X, Y, LightColor, ShadeColor: Integer);
     99procedure DrawBufferEnsureSize(Width, Height: Integer);
    99100procedure LoadPhrases;
    100101procedure Texturize(Dest, Texture: TBitmap; TransparentColor: Cardinal);
     
    190191  Paper: TBitmap;
    191192  BigImp: TBitmap;
    192   LogoBuffer: TBitmap;
     193  DrawBuffer: TBitmap;
    193194  FullScreen: Boolean;
    194195  GenerateNames: Boolean;
     
    15671568procedure PaintLogo(Canvas: TCanvas; X, Y, LightColor, ShadeColor: Integer);
    15681569begin
    1569   if not Assigned(LogoBuffer) then Exit;
    1570   UnshareBitmap(LogoBuffer);
    1571   BitBltCanvas(LogoBuffer.Canvas, 0, 0, Logo.Width, Logo.Height, Canvas, X, Y);
    1572   ImageOp_BCC(LogoBuffer, Templates.Data, Point(0, 0), Logo.BoundsRect,
     1570  if not Assigned(DrawBuffer) then Exit;
     1571  DrawBufferEnsureSize(Logo.Width, Logo.Height);
     1572  UnshareBitmap(DrawBuffer);
     1573  BitBltCanvas(DrawBuffer.Canvas, 0, 0, Logo.Width, Logo.Height, Canvas, X, Y);
     1574  ImageOp_BCC(DrawBuffer, Templates.Data, Point(0, 0), Logo.BoundsRect,
    15731575    LightColor, ShadeColor);
    1574   BitBltCanvas(Canvas, X, Y, Logo.Width, Logo.Height, LogoBuffer.Canvas, 0, 0);
     1576  BitBltCanvas(Canvas, X, Y, Logo.Width, Logo.Height, DrawBuffer.Canvas, 0, 0);
     1577end;
     1578
     1579procedure DrawBufferEnsureSize(Width, Height: Integer);
     1580begin
     1581  if (DrawBuffer.Width >= Width) and (DrawBuffer.Height >= Height) then Exit;
     1582  if (DrawBuffer.Width < Width) and (DrawBuffer.Height < Height) then
     1583    DrawBuffer.SetSize(Width, Height)
     1584  else if DrawBuffer.Width < Width then DrawBuffer.Width := Width
     1585  else if DrawBuffer.Height < Height then DrawBuffer.Height := Height;
     1586  DrawBuffer.Canvas.FillRect(0, 0, DrawBuffer.Width, DrawBuffer.Height);
    15751587end;
    15761588
     
    18131825  end;
    18141826
    1815   if not Assigned(LogoBuffer) then begin
    1816     LogoBuffer := TBitmap.Create;
    1817     LogoBuffer.PixelFormat := TPixelFormat.pf24bit;
    1818     LogoBuffer.SetSize(BigBook.Width, BigBook.Height);
    1819   end;
    1820 
    18211827  LoadGraphicFile(Colors, GetGraphicsDir + DirectorySeparator + 'Colors.png');
    18221828  LoadGraphicFile(Paper, GetGraphicsDir + DirectorySeparator + 'Paper.jpg');
     
    18381844  for Section := Low(TFontType) to High(TFontType) do
    18391845    UniFont[Section] := TFont.Create;
     1846
     1847  DrawBuffer := TBitmap.Create;
     1848  DrawBuffer.PixelFormat := TPixelFormat.pf24bit;
    18401849
    18411850  GrExt := TGraphicSets.Create;
     
    18771886  FreeAndNil(Phrases);
    18781887  FreeAndNil(Phrases2);
    1879   if Assigned(LogoBuffer) then FreeAndNil(LogoBuffer);
     1888  FreeAndNil(DrawBuffer);
    18801889  FreeAndNil(BigImp);
    18811890  FreeAndNil(Paper);
  • trunk/Packages/DpiControls/Dpi.Common.pas

    r476 r514  
    55uses
    66  {$IFDEF WINDOWS}Windows,{$ENDIF}
    7   Classes, SysUtils, LCLType, Types, LCLIntf, Graphics, Dpi.Graphics;
     7  Classes, SysUtils, LCLType, Types, Math, LCLIntf, Graphics, Dpi.Graphics;
    88
    99const
     
    100100function ScaleToNative(Value: Integer): Integer;
    101101begin
    102   Result := Round(Value * ScreenInfo.Dpi / 96);
     102  Result := Ceil(Value * ScreenInfo.Dpi / 96);
    103103end;
    104104
     
    110110function ScaleFromNative(Value: Integer): Integer;
    111111begin
    112   Result := Round(Value * 96 / ScreenInfo.Dpi);
     112  Result := Floor(Value * 96 / ScreenInfo.Dpi);
    113113end;
    114114
     
    185185  DstWidth, DstHeight: Integer;
    186186  SrcWidth, SrcHeight: Integer;
     187  ReduceWidth, ReduceHeight: Integer;
    187188begin
    188189  {$IFDEF WINDOWS}
     
    193194  {$ELSE}
    194195
    195 
    196196  DstWidth := ScaleToNativeDist(X, Width);
    197197  DstHeight := ScaleToNativeDist(Y, Height);
    198198  SrcWidth := ScaleToNativeDist(XSrc, Width);
    199199  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;
    200206  if (DstWidth = SrcWidth) and (DstHeight = SrcHeight) then begin
    201207    Result := LCLIntf.BitBlt(DestDC, ScaleToNative(X), ScaleToNative(Y),
     
    204210  end else begin
    205211    Result := LCLIntf.BitBlt(DestDC, ScaleToNative(X), ScaleToNative(Y),
    206       DstWidth, DstHeight, SrcDC,
     212      DstWidth - ReduceWidth, DstHeight - ReduceHeight, SrcDC,
    207213      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),
    209228      DstWidth, DstHeight, SrcDC,
    210229      ScaleToNative(XSrc), ScaleToNative(YSrc),
    211       SrcWidth, SrcHeight, Rop);
    212 }  end;
     230      SrcWidth, SrcHeight, Rop);}
     231  end;
    213232
    214233{  Result := LCLIntf.BitBlt(DestDC, ScaleToNative(X), ScaleToNative(Y),
Note: See TracChangeset for help on using the changeset viewer.