Changeset 514 for trunk


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

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/MessgEx.pas

    r509 r514  
    4545  private
    4646    MovieCancelled: Boolean;
    47     procedure PaintBook(ca: TCanvas; X, Y, clPage, clCover: Integer);
     47    procedure PaintBook(Canvas: TCanvas; X, Y, clPage, clCover: Integer);
    4848    procedure PaintMyArmy;
    4949    procedure PaintEnemyArmy;
     
    221221end;
    222222
    223 procedure TMessgExDlg.PaintBook(ca: TCanvas; X, Y, clPage, clCover: Integer);
     223procedure TMessgExDlg.PaintBook(Canvas: TCanvas; X, Y, clPage, clCover: Integer);
    224224const
    225225  xScrewed = 77;
     
    238238  Height: Integer;
    239239begin
    240   Width := 56;
    241   Height := 40;
     240  Width := xSizeBig;
     241  Height := ySizeBig;
    242242  if IconIndex >= 0 then begin
    243243    xIcon := IconIndex mod 7 * xSizeBig;
     
    292292
    293293  // paint
    294   UnshareBitmap(LogoBuffer);
    295   BitBltCanvas(LogoBuffer.Canvas, 0, 0, BookRect.Width, BookRect.Height, ca, X, Y);
     294  UnshareBitmap(DrawBuffer);
     295  DrawBufferEnsureSize(BookRect.Width, BookRect.Height);
     296  BitBltCanvas(DrawBuffer.Canvas, 0, 0, BookRect.Width, BookRect.Height, Canvas, X, Y);
    296297
    297298  if IconIndex >= 0 then
     
    299300      for ix := 0 to wScrewed - 1 do
    300301        if Screwed[ix, iy, 3] > 0.01 then
    301           LogoBuffer.Canvas.Pixels[xScrewed + ix, yScrewed + iy] :=
     302          DrawBuffer.Canvas.Pixels[xScrewed + ix, yScrewed + iy] :=
    302303            Trunc(Screwed[ix, iy, 2] / Screwed[ix, iy, 3]) +
    303304            Trunc(Screwed[ix, iy, 1] / Screwed[ix, iy, 3]) shl 8 +
    304305            Trunc(Screwed[ix, iy, 0] / Screwed[ix, iy, 3]) shl 16;
    305306
    306   ImageOp_BCC(LogoBuffer, Templates.Data, Point(0, 0), BookRect, clCover, clPage);
    307 
    308   BitBltCanvas(ca, X, Y, BookRect.Width, BookRect.Height, LogoBuffer.Canvas, 0, 0);
     307  ImageOp_BCC(DrawBuffer, Templates.Data, Point(0, 0), BookRect, clCover, clPage);
     308
     309  BitBltCanvas(Canvas, X, Y, BookRect.Width, BookRect.Height, DrawBuffer.Canvas, 0, 0);
    309310end;
    310311
  • 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),
  • trunk/Start.pas

    r511 r514  
    114114    FormerGames: TStringList;
    115115    Maps: TStringList;
    116     LogoBuffer: TBitmap;
    117116    // BookDate: string;
    118117    PlayerSlots: TPlayerSlots;
     
    181180  ActionSideBorder = 24;
    182181  ActionBottomBorder = 10;
    183   wBuffer = 91;
    184182  x0Mini = 437;
    185183  y0Mini = 178;
     
    308306  EmptyPicture.SetSize(64, 64);
    309307  EmptyPicture.Canvas.FillRect(0, 0, EmptyPicture.Width, EmptyPicture.Height);
    310   LogoBuffer := TBitmap.Create;
    311   LogoBuffer.PixelFormat := TPixelFormat.pf24bit;
    312   LogoBuffer.SetSize(wBuffer, 56);
    313   LogoBuffer.Canvas.FillRect(0, 0, LogoBuffer.Width, LogoBuffer.Height);
    314308
    315309  MiniMap := TMiniMap.Create;
     
    336330  FreeAndNil(Maps);
    337331  FreeAndNil(EmptyPicture);
    338   FreeAndNil(LogoBuffer);
    339332  FreeAndNil(PlayerSlots);
    340333  FreeAndNil(MiniMap);
     
    537530    $000000, xAction, Y + 21, Phrases2.Lookup(TextItem));
    538531
    539   UnshareBitmap(LogoBuffer);
    540   BitBltCanvas(LogoBuffer.Canvas, 0, 0, 50, 50, Canvas,
     532  UnshareBitmap(DrawBuffer);
     533  DrawBufferEnsureSize(50, 50);
     534  BitBltCanvas(DrawBuffer.Canvas, 0, 0, 50, 50, Canvas,
    541535    xActionIcon - 2, Y - 2);
    542   GlowFrame(LogoBuffer, 8, 8, 34, 34, $202020);
     536  GlowFrame(DrawBuffer, 8, 8, 34, 34, $202020);
    543537  BitBltCanvas(Canvas, xActionIcon - 2, Y - 2, 50, 50,
    544     LogoBuffer.Canvas, 0, 0);
     538    DrawBuffer.Canvas, 0, 0);
    545539  BitBltCanvas(Canvas, xActionIcon, Y, 40, 40, BigImp.Canvas,
    546540    (IconIndex mod 7) * xSizeBig + 8, (IconIndex div 7) * ySizeBig);
     
    637631
    638632  // Paint menu logo
    639   UnshareBitmap(LogoBuffer);
    640   BitBltCanvas(LogoBuffer.Canvas, 0, 0, MenuLogo.Width, MenuLogo.Height, Canvas, 6,
     633  UnshareBitmap(DrawBuffer);
     634  DrawBufferEnsureSize(MenuLogo.Width, MenuLogo.Height);
     635  BitBltCanvas(DrawBuffer.Canvas, 0, 0, MenuLogo.Width, MenuLogo.Height, Canvas, 6,
    641636    3 + 2 * Integer(Tab <> tbMain));
    642637
    643   ImageOp_BCC(LogoBuffer, Templates.Data, 0, 0, MenuLogo.Left, MenuLogo.Top,
     638  ImageOp_BCC(DrawBuffer, Templates.Data, 0, 0, MenuLogo.Left, MenuLogo.Top,
    644639    MenuLogo.Width, MenuLogo.Height - 9, $BFBF20, $4040DF); // logo part 1
    645   ImageOp_BCC(LogoBuffer, Templates.Data, 10, 27, MenuLogo.Left + 10,
     640  ImageOp_BCC(DrawBuffer, Templates.Data, 10, 27, MenuLogo.Left + 10,
    646641    MenuLogo.Top + 27, MenuLogo.Width - 10, 9, $BFBF20, $4040DF); // logo part 2
    647642  BitBltCanvas(Canvas, 6, 3 + 2 * Integer(Tab <> tbMain), MenuLogo.Width, MenuLogo.Height,
    648     LogoBuffer.Canvas, 0, 0);
     643    DrawBuffer.Canvas, 0, 0);
    649644
    650645  if Page = pgMain then begin
    651    if SelectedAction <> maNone then // mark selected action
    652       for I := 0 to (ClientWidth - 2 * ActionSideBorder) div wBuffer + 1 do
    653       begin
    654         W := ClientWidth - 2 * ActionSideBorder - I * wBuffer;
    655         if W > wBuffer then
    656           W := wBuffer;
    657         H := ActionPitch;
    658         if yAction + Integer(SelectedAction) * ActionPitch - 8 + H > ClientHeight - ActionBottomBorder
    659         then
    660           H := ClientHeight - ActionBottomBorder -
    661             (yAction + Integer(SelectedAction) * ActionPitch - 8);
    662 
    663         UnshareBitmap(LogoBuffer);
    664         BitBltCanvas(LogoBuffer.Canvas, 0, 0, W, H, Canvas,
    665           ActionSideBorder + I * wBuffer, yAction + Integer(SelectedAction) * ActionPitch
    666           - 8);
    667         MakeBlue(LogoBuffer, 0, 0, W, H);
    668         BitBltCanvas(Canvas, ActionSideBorder + I * wBuffer,
    669           yAction + Integer(SelectedAction) * ActionPitch - 8, W, H,
    670           LogoBuffer.Canvas, 0, 0);
    671       end;
     646    if SelectedAction <> maNone then begin
     647      // Mark selected action
     648      W := ClientWidth - 2 * ActionSideBorder;
     649      H := ActionPitch;
     650      if yAction + Integer(SelectedAction) * ActionPitch - 8 + H > ClientHeight - ActionBottomBorder
     651      then
     652        H := ClientHeight - ActionBottomBorder -
     653          (yAction + Integer(SelectedAction) * ActionPitch - 8);
     654
     655      UnshareBitmap(DrawBuffer);
     656      DrawBufferEnsureSize(W, H);
     657      BitBltCanvas(DrawBuffer.Canvas, 0, 0, W, H, Canvas,
     658        ActionSideBorder, yAction + Integer(SelectedAction) * ActionPitch - 8);
     659      MakeBlue(DrawBuffer, 0, 0, W, H);
     660      BitBltCanvas(Canvas, ActionSideBorder, yAction + Integer(SelectedAction) *
     661        ActionPitch - 8, W, H, DrawBuffer.Canvas, 0, 0);
     662    end;
    672663    Y := yAction;
    673664    for MainAction := Low(TMainActionSet) to High(TMainActionSet) do
     
    687678              Canvas.Font.Assign(UniFont[ftNormal]);
    688679
    689               UnshareBitmap(LogoBuffer);
    690               BitBltCanvas(LogoBuffer.Canvas, 0, 0, LinkArrows.Width, LinkArrows.Height, Canvas,
     680              UnshareBitmap(DrawBuffer);
     681              DrawBufferEnsureSize(LinkArrows.Width, LinkArrows.Height);
     682              BitBltCanvas(DrawBuffer.Canvas, 0, 0, LinkArrows.Width, LinkArrows.Height, Canvas,
    691683                xActionIcon, Y + 2);
    692               ImageOp_BCC(LogoBuffer, Templates.Data, Point(0, 0), LinkArrows.BoundsRect, 0,
     684              ImageOp_BCC(DrawBuffer, Templates.Data, Point(0, 0), LinkArrows.BoundsRect, 0,
    693685                Colors.Canvas.Pixels[clkAge0 - 1, cliDimmedText]);
    694686              BitBltCanvas(Canvas, xActionIcon, Y + 2, LinkArrows.Width, LinkArrows.Height,
    695                 LogoBuffer.Canvas, 0, 0);
     687                DrawBuffer.Canvas, 0, 0);
    696688            end;
    697689        end;
Note: See TracChangeset for help on using the changeset viewer.