Ignore:
Timestamp:
May 6, 2020, 11:21:12 PM (4 years ago)
Author:
chronos
Message:
  • Modified: Simplified code by replacing BitBlt which uses always handles by BitBltCanvas which uses directly TCanvas objects. Used default ROP SRCCOPY.
File:
1 edited

Legend:

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

    r187 r188  
    4040  xDst, yDst, xSrc, ySrc, w, h, Color1, Color2: integer);
    4141procedure ImageOp_CCC(bmp: TBitmap; x, y, w, h, Color0, Color1, Color2: integer);
    42 function BitBltCanvas(DestCanvas: TCanvas; X, Y, Width, Height: integer;
    43   SrcCanvas: TCanvas; XSrc, YSrc: integer; Rop: DWORD): boolean;
     42function BitBltCanvas(DestCanvas: TCanvas; X, Y, Width, Height: Integer;
     43  SrcCanvas: TCanvas; XSrc, YSrc: Integer; Rop: DWORD = SRCCOPY): Boolean;
    4444procedure SLine(ca: TCanvas; x0, x1, y: integer; cl: TColor);
    4545procedure DLine(ca: TCanvas; x0, x1, y: integer; cl0, cl1: TColor);
     
    153153  TGrExtDescr = record { don't use dynamic strings here! }
    154154    Name: string[31];
    155     Data, Mask: TBitmap;
    156     pixUsed: array [byte] of byte;
     155    Data: TBitmap;
     156    Mask: TBitmap;
     157    pixUsed: array [Byte] of Byte;
    157158  end;
    158159
     
    160161      TGrExtDescr, but without pixUsed }
    161162    Name: string[31];
    162     Data, Mask: TBitmap;
     163    Data: TBitmap;
     164    Mask: TBitmap;
    163165  end;
    164166
     
    519521procedure Dump(dst: TBitmap; HGr, xDst, yDst, Width, Height, xGr, yGr: integer);
    520522begin
    521   BitBlt(dst.Canvas.Handle, xDst, yDst, Width, Height,
    522     GrExt[HGr].Data.Canvas.Handle, xGr, yGr, SRCCOPY);
     523  BitBltCanvas(dst.Canvas, xDst, yDst, Width, Height,
     524    GrExt[HGr].Data.Canvas, xGr, yGr);
    523525end;
    524526
     
    703705procedure Sprite(Canvas: TCanvas; HGr, xDst, yDst, Width, Height, xGr, yGr: integer);
    704706begin
    705   BitBlt(Canvas.Handle, xDst, yDst, Width, Height,
    706     GrExt[HGr].Mask.Canvas.Handle, xGr, yGr, SRCAND);
    707   BitBlt(Canvas.Handle, xDst, yDst, Width, Height,
    708     GrExt[HGr].Data.Canvas.Handle, xGr, yGr, SRCPAINT);
     707  BitBltCanvas(Canvas, xDst, yDst, Width, Height,
     708    GrExt[HGr].Mask.Canvas, xGr, yGr, SRCAND);
     709  BitBltCanvas(Canvas, xDst, yDst, Width, Height,
     710    GrExt[HGr].Data.Canvas, xGr, yGr, SRCPAINT);
    709711end;
    710712
    711713procedure Sprite(dst: TBitmap; HGr, xDst, yDst, Width, Height, xGr, yGr: integer);
    712714begin
    713   BitBlt(dst.Canvas.Handle, xDst, yDst, Width, Height,
    714     GrExt[HGr].Mask.Canvas.Handle, xGr, yGr, SRCAND);
    715   BitBlt(dst.Canvas.Handle, xDst, yDst, Width, Height,
    716     GrExt[HGr].Data.Canvas.Handle, xGr, yGr, SRCPAINT);
    717 end;
    718 
    719 function BitBltCanvas(DestCanvas: TCanvas; X, Y, Width, Height: integer;
    720   SrcCanvas: TCanvas; XSrc, YSrc: integer; Rop: DWORD): boolean;
    721 begin
    722   Assert(Rop = SRCCOPY);
    723   DestCanvas.CopyRect(Rect(X, Y, X + Width, Y + Height), SrcCanvas,
    724     Rect(XSrc, YSrc, XSrc + Width, YSrc + Height));
    725   Result := True;
     715  BitBltCanvas(dst.Canvas, xDst, yDst, Width, Height,
     716    GrExt[HGr].Mask.Canvas, xGr, yGr, SRCAND);
     717  BitBltCanvas(dst.Canvas, xDst, yDst, Width, Height,
     718    GrExt[HGr].Data.Canvas, xGr, yGr, SRCPAINT);
     719end;
     720
     721function BitBltCanvas(DestCanvas: TCanvas; X, Y, Width, Height: Integer;
     722  SrcCanvas: TCanvas; XSrc, YSrc: Integer; Rop: DWORD = SRCCOPY): Boolean;
     723begin
     724  {Assert(Rop = SRCCOPY);}
     725  if Rop = SRCCOPY then begin
     726    DestCanvas.CopyRect(Rect(X, Y, X + Width, Y + Height), SrcCanvas,
     727      Rect(XSrc, YSrc, XSrc + Width, YSrc + Height));
     728    Result := True;
     729  end else Result := BitBlt(DestCanvas.Handle, X, Y, Width, Height, SrcCanvas.Handle, XSrc, YSrc, Rop);
    726730end;
    727731
     
    805809  end else
    806810    Frame(ca, x - 1, y - 1, x + Width, y + Height, $000000, $000000);
    807   BitBlt(ca.Handle, x, y, Width, Height, Src.Canvas.Handle, xSrc, ySrc,
    808     SRCCOPY);
     811  BitBltCanvas(ca, x, y, Width, Height, Src.Canvas, xSrc, ySrc);
    809812end;
    810813
     
    886889          $FF * intensity div $FF shl 16;
    887890      end;
    888   BitBlt(GrExt[HGrSystem].Mask.Canvas.Handle, 77, 47, 10, 10,
    889     GrExt[HGrSystem].Mask.Canvas.Handle, 66, 47, SRCCOPY);
     891  BitBltCanvas(GrExt[HGrSystem].Mask.Canvas, 77, 47, 10, 10,
     892    GrExt[HGrSystem].Mask.Canvas, 66, 47);
    890893end;
    891894
     
    894897  Assert((Left + xOffset >= 0) and (Left + xOffset + Width <= wMainTexture) and
    895898    (Top + yOffset >= 0) and (Top + yOffset + Height <= hMainTexture));
    896   BitBlt(ca.Handle, Left, Top, Width, Height, MainTexture.Image.Canvas.Handle,
    897     Left + xOffset, Top + yOffset, SRCCOPY);
     899  BitBltCanvas(ca, Left, Top, Width, Height, MainTexture.Image.Canvas,
     900    Left + xOffset, Top + yOffset);
    898901end;
    899902
     
    916919begin
    917920  for I := 0 to (x1 - xm) div wMainTexture - 1 do
    918     BitBlt(ca.Handle, xm + I * wMainTexture, y0, wMainTexture, y1 - y0,
    919       MainTexture.Image.Canvas.Handle, 0, hMainTexture div 2 + Band(I) *
    920       (y1 - y0), SRCCOPY);
    921   BitBlt(ca.Handle, xm + ((x1 - xm) div wMainTexture) * wMainTexture, y0,
     921    BitBltCanvas(ca, xm + I * wMainTexture, y0, wMainTexture, y1 - y0,
     922      MainTexture.Image.Canvas, 0, hMainTexture div 2 + Band(I) *
     923      (y1 - y0));
     924  BitBltCanvas(ca, xm + ((x1 - xm) div wMainTexture) * wMainTexture, y0,
    922925    x1 - (xm + ((x1 - xm) div wMainTexture) * wMainTexture), y1 - y0,
    923     MainTexture.Image.Canvas.Handle, 0, hMainTexture div 2 + Band(
    924     (x1 - xm) div wMainTexture) * (y1 - y0), SRCCOPY);
     926    MainTexture.Image.Canvas, 0, hMainTexture div 2 + Band(
     927    (x1 - xm) div wMainTexture) * (y1 - y0));
    925928  for I := 0 to (xm - x0) div wMainTexture - 1 do
    926     BitBlt(ca.Handle, xm - (I + 1) * wMainTexture, y0, wMainTexture, y1 - y0,
    927       MainTexture.Image.Canvas.Handle, 0, hMainTexture div 2 +
    928       Band(-I - 1) * (y1 - y0), SRCCOPY);
    929   BitBlt(ca.Handle, x0, y0, xm - ((xm - x0) div wMainTexture) *
    930     wMainTexture - x0, y1 - y0, MainTexture.Image.Canvas.Handle,
     929    BitBltCanvas(ca, xm - (I + 1) * wMainTexture, y0, wMainTexture, y1 - y0,
     930      MainTexture.Image.Canvas, 0, hMainTexture div 2 +
     931      Band(-I - 1) * (y1 - y0));
     932  BitBltCanvas(ca, x0, y0, xm - ((xm - x0) div wMainTexture) *
     933    wMainTexture - x0, y1 - y0, MainTexture.Image.Canvas,
    931934    ((xm - x0) div wMainTexture + 1) * wMainTexture - (xm - x0),
    932     hMainTexture div 2 + Band(-(xm - x0) div wMainTexture - 1) * (y1 - y0), SRCCOPY);
     935    hMainTexture div 2 + Band(-(xm - x0) div wMainTexture - 1) * (y1 - y0));
    933936end;
    934937
     
    960963      if x1cut < 0 then
    961964        x1cut := 0;
    962       BitBlt(ca.Handle, x * Texture.Width + x0cut - xOffset,
     965      BitBltCanvas(ca, x * Texture.Width + x0cut - xOffset,
    963966        y * Texture.Height + y0cut - yOffset, Texture.Width - x0cut - x1cut,
    964         Texture.Height - y0cut - y1cut, Texture.Canvas.Handle, x0cut,
    965         y0cut, SRCCOPY);
     967        Texture.Height - y0cut - y1cut, Texture.Canvas, x0cut, y0cut);
    966968    end;
    967969  end;
     
    982984procedure Corner(ca: TCanvas; x, y, Kind: Integer; const T: TTexture);
    983985begin
    984   { BitBlt(ca.Handle,x,y,8,8,GrExt[T.HGr].Mask.Canvas.Handle,
     986  { BitBltCanvas(ca,x,y,8,8,GrExt[T.HGr].Mask.Canvas,
    985987    T.xGr+29+Kind*9,T.yGr+89,SRCAND);
    986     BitBlt(ca.Handle,x,y,8,8,GrExt[T.HGr].Data.Canvas.Handle,
     988    BitBltCanvas(ca,x,y,8,8,GrExt[T.HGr].Data.Canvas,
    987989    T.xGr+29+Kind*9,T.yGr+89,SRCPAINT); }
    988990end;
     
    992994  procedure PaintIcon(x, y, Kind: Integer);
    993995  begin
    994     BitBlt(ca.Handle, x, y + 6, 10, 10, GrExt[HGrSystem].Mask.Canvas.Handle,
     996    BitBltCanvas(ca, x, y + 6, 10, 10, GrExt[HGrSystem].Mask.Canvas,
    995997      66 + Kind mod 11 * 11, 115 + Kind div 11 * 11, SRCAND);
    996     BitBlt(ca.Handle, x, y + 6, 10, 10, GrExt[HGrSystem].Data.Canvas.Handle,
     998    BitBltCanvas(ca, x, y + 6, 10, 10, GrExt[HGrSystem].Data.Canvas,
    997999      66 + Kind mod 11 * 11, 115 + Kind div 11 * 11, SRCPAINT);
    9981000  end;
     
    12161218      for i := 0 to val mod 10 - 1 do
    12171219      begin
    1218         BitBlt(Handle, xIcon + 4 + i * (14 * ld div sd), yIcon + 2 + 1, 14,
    1219           14, GrExt[HGrSystem].Mask.Canvas.Handle, 67 + Kind mod 8 * 15,
     1220        BitBltCanvas(dst.Canvas, xIcon + 4 + i * (14 * ld div sd), yIcon + 2 + 1, 14,
     1221          14, GrExt[HGrSystem].Mask.Canvas, 67 + Kind mod 8 * 15,
    12201222          70 + Kind div 8 * 15, SRCAND);
    12211223        Sprite(dst, HGrSystem, xIcon + 3 + i * (14 * ld div sd), yIcon + 2,
     
    12241226      for i := 0 to val div 10 - 1 do
    12251227      begin
    1226         BitBlt(dst.Canvas.Handle, xIcon + 4 + (val mod 10) *
     1228        BitBltCanvas(dst.Canvas, xIcon + 4 + (val mod 10) *
    12271229          (14 * ld div sd) + i * (14 * ld div sd), yIcon + 3, 14, 14,
    1228           GrExt[HGrSystem].Mask.Canvas.Handle, 67 + 7 mod 8 * 15,
     1230          GrExt[HGrSystem].Mask.Canvas, 67 + 7 mod 8 * 15,
    12291231          70 + 7 div 8 * 15, SRCAND);
    12301232        Sprite(dst, HGrSystem, xIcon + 3 + (val mod 10) *
     
    12491251      for i := 0 to val div 10 - 1 do
    12501252      begin
    1251         BitBlt(Handle, xIcon + 4 + i * (14 * ld div sd), yIcon + 3, 14, 14,
    1252           GrExt[HGrSystem].Mask.Canvas.Handle, 67 + Kind mod 8 * 15,
     1253        BitBltCanvas(dst.Canvas, xIcon + 4 + i * (14 * ld div sd), yIcon + 3, 14, 14,
     1254          GrExt[HGrSystem].Mask.Canvas, 67 + Kind mod 8 * 15,
    12531255          70 + Kind div 8 * 15, SRCAND);
    12541256        Sprite(dst, HGrSystem, xIcon + 3 + i * (14 * ld div sd), yIcon + 2,
     
    12571259      for i := 0 to val mod 10 - 1 do
    12581260      begin
    1259         BitBlt(dst.Canvas.Handle, xIcon + 4 + (val div 10) *
     1261        BitBltCanvas(dst.Canvas, xIcon + 4 + (val div 10) *
    12601262          (14 * ld div sd) + i * (10 * ld div sd), yIcon + 7, 10, 10,
    1261           GrExt[HGrSystem].Mask.Canvas.Handle, 66 + Kind mod 11 * 11,
     1263          GrExt[HGrSystem].Mask.Canvas, 66 + Kind mod 11 * 11,
    12621264          115 + Kind div 11 * 11, SRCAND);
    12631265        Sprite(dst, HGrSystem, xIcon + 3 + (val div 10) *
     
    12941296  begin
    12951297    for i := 0 to pos div 8 - 1 do
    1296       BitBlt(Handle, x + i * 8, y, 8, 7,
    1297         GrExt[HGrSystem].Data.Canvas.Handle, 104, 9 + 8 * Kind, SRCCOPY);
    1298     BitBlt(Handle, x + 8 * (pos div 8), y, pos - 8 * (pos div 8), 7,
    1299       GrExt[HGrSystem].Data.Canvas.Handle, 104, 9 + 8 * Kind, SRCCOPY);
     1298      BitBltCanvas(ca, x + i * 8, y, 8, 7,
     1299        GrExt[HGrSystem].Data.Canvas, 104, 9 + 8 * Kind);
     1300    BitBltCanvas(ca, x + 8 * (pos div 8), y, pos - 8 * (pos div 8), 7,
     1301      GrExt[HGrSystem].Data.Canvas, 104, 9 + 8 * Kind);
    13001302    if Growth > 0 then
    13011303    begin
    13021304      for i := 0 to Growth div 8 - 1 do
    1303         BitBlt(Handle, x + pos + i * 8, y, 8, 7,
    1304           GrExt[HGrSystem].Data.Canvas.Handle, 112, 9 + 8 * Kind, SRCCOPY);
    1305       BitBlt(Handle, x + pos + 8 * (Growth div 8), y,
    1306         Growth - 8 * (Growth div 8), 7, GrExt[HGrSystem].Data.Canvas.Handle,
    1307         112, 9 + 8 * Kind, SRCCOPY);
     1305        BitBltCanvas(ca, x + pos + i * 8, y, 8, 7,
     1306          GrExt[HGrSystem].Data.Canvas, 112, 9 + 8 * Kind);
     1307      BitBltCanvas(ca, x + pos + 8 * (Growth div 8), y,
     1308        Growth - 8 * (Growth div 8), 7, GrExt[HGrSystem].Data.Canvas,
     1309        112, 9 + 8 * Kind);
    13081310    end
    13091311    else if Growth < 0 then
    13101312    begin
    13111313      for i := 0 to -Growth div 8 - 1 do
    1312         BitBlt(Handle, x + pos + i * 8, y, 8, 7,
    1313           GrExt[HGrSystem].Data.Canvas.Handle, 104, 1, SRCCOPY);
    1314       BitBlt(Handle, x + pos + 8 * (-Growth div 8), y, -Growth -
     1314        BitBltCanvas(ca, x + pos + i * 8, y, 8, 7,
     1315          GrExt[HGrSystem].Data.Canvas, 104, 1);
     1316      BitBltCanvas(ca, x + pos + 8 * (-Growth div 8), y, -Growth -
    13151317        8 * (-Growth div 8), 7,
    1316         GrExt[HGrSystem].Data.Canvas.Handle, 104, 1, SRCCOPY);
     1318        GrExt[HGrSystem].Data.Canvas, 104, 1);
    13171319    end;
    13181320    Brush.Color := $000000;
     
    13391341procedure PaintLogo(ca: TCanvas; x, y, clLight, clShade: Integer);
    13401342begin
    1341   BitBltCanvas(LogoBuffer.Canvas, 0, 0, wLogo, hLogo, ca, x,
    1342     y, SRCCOPY);
     1343  BitBltCanvas(LogoBuffer.Canvas, 0, 0, wLogo, hLogo, ca, x, y);
    13431344  ImageOp_BCC(LogoBuffer, Templates, 0, 0, 1, 1, wLogo, hLogo,
    13441345    clLight, clShade);
    1345   BitBlt(ca.Handle, x, y, wLogo, hLogo, LogoBuffer.Canvas.Handle, 0,
    1346     0, SRCCOPY);
     1346  BitBltCanvas(ca, x, y, wLogo, hLogo, LogoBuffer.Canvas, 0, 0);
    13471347end;
    13481348
Note: See TracChangeset for help on using the changeset viewer.