Ignore:
Timestamp:
Jun 23, 2019, 9:12:54 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Improved scaling support.
File:
1 edited

Legend:

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

    r178 r179  
    441441end;
    442442
     443procedure ResizeBitmap(Bitmap: TDpiBitmap; const NewWidth, NewHeight: Integer);
     444var
     445  Buffer: TDpiBitmap;
     446begin
     447  Buffer := TDpiBitmap.Create;
     448  try
     449    Buffer.SetSize(NewWidth, NewHeight);
     450    Buffer.Canvas.StretchDraw(Rect(0, 0, NewWidth, NewHeight), Bitmap);
     451    Bitmap.SetSize(NewWidth, NewHeight);
     452    Bitmap.Canvas.Draw(0, 0, Buffer);
     453  finally
     454    Buffer.Free;
     455  end;
     456end;
     457
    443458function LoadGraphicFile(bmp: TDpiBitmap; Path: string; Options: Integer): Boolean;
    444459var
     
    453468    try
    454469      jtex.LoadFromFile(Path);
     470      ResizeBitmap(jtex, ScaleToVcl(jtex.Width), ScaleToVcl(jtex.Height));
    455471    except
    456472      Result := False;
     
    471487    try
    472488      Png.LoadFromFile(Path);
     489      ResizeBitmap(Png, ScaleToVcl(Png.Width), ScaleToVcl(Png.Height));
    473490    except
    474491      Result := False;
     
    494511    try
    495512      bmp.LoadFromFile(Path);
     513      ResizeBitmap(bmp, ScaleToVcl(bmp.Width), ScaleToVcl(bmp.Height));
    496514    except
    497515      Result := False;
     
    580598procedure Dump(dst: TDpiBitmap; HGr, xDst, yDst, Width, Height, xGr, yGr: integer);
    581599begin
    582   BitBlt(dst.Canvas.Handle, xDst, yDst, Width, Height,
     600  DpiBitBlt(dst.Canvas.Handle, xDst, yDst, Width, Height,
    583601    GrExt[HGr].Data.Canvas.Handle, xGr, yGr, SRCCOPY);
    584602end;
     
    764782procedure Sprite(Canvas: TDpiCanvas; HGr, xDst, yDst, Width, Height, xGr, yGr: integer);
    765783begin
    766   BitBlt(Canvas.Handle, xDst, yDst, Width, Height,
     784  DpiBitBlt(Canvas.Handle, xDst, yDst, Width, Height,
    767785    GrExt[HGr].Mask.Canvas.Handle, xGr, yGr, SRCAND);
    768   BitBlt(Canvas.Handle, xDst, yDst, Width, Height,
     786  DpiBitBlt(Canvas.Handle, xDst, yDst, Width, Height,
    769787    GrExt[HGr].Data.Canvas.Handle, xGr, yGr, SRCPAINT);
    770788end;
     
    772790procedure Sprite(dst: TDpiBitmap; HGr, xDst, yDst, Width, Height, xGr, yGr: integer);
    773791begin
    774   BitBlt(dst.Canvas.Handle, xDst, yDst, Width, Height,
     792  DpiBitBlt(dst.Canvas.Handle, xDst, yDst, Width, Height,
    775793    GrExt[HGr].Mask.Canvas.Handle, xGr, yGr, SRCAND);
    776   BitBlt(dst.Canvas.Handle, xDst, yDst, Width, Height,
     794  DpiBitBlt(dst.Canvas.Handle, xDst, yDst, Width, Height,
    777795    GrExt[HGr].Data.Canvas.Handle, xGr, yGr, SRCPAINT);
    778796end;
     
    866884  end else
    867885    Frame(ca, x - 1, y - 1, x + Width, y + Height, $000000, $000000);
    868   BitBlt(ca.Handle, x, y, Width, Height, Src.Canvas.Handle, xSrc, ySrc,
     886  DpiBitBlt(ca.Handle, x, y, Width, Height, Src.Canvas.Handle, xSrc, ySrc,
    869887    SRCCOPY);
    870888end;
     
    947965          $FF * intensity div $FF shl 16;
    948966      end;
    949   BitBlt(GrExt[HGrSystem].Mask.Canvas.Handle, 77, 47, 10, 10,
     967  DpiBitBlt(GrExt[HGrSystem].Mask.Canvas.Handle, 77, 47, 10, 10,
    950968    GrExt[HGrSystem].Mask.Canvas.Handle, 66, 47, SRCCOPY);
    951969end;
     
    955973  Assert((Left + xOffset >= 0) and (Left + xOffset + Width <= wMainTexture) and
    956974    (Top + yOffset >= 0) and (Top + yOffset + Height <= hMainTexture));
    957   BitBlt(ca.Handle, Left, Top, Width, Height, MainTexture.Image.Canvas.Handle,
     975  DpiBitBlt(ca.Handle, Left, Top, Width, Height, MainTexture.Image.Canvas.Handle,
    958976    Left + xOffset, Top + yOffset, SRCCOPY);
    959977end;
     
    977995begin
    978996  for I := 0 to (x1 - xm) div wMainTexture - 1 do
    979     BitBlt(ca.Handle, xm + I * wMainTexture, y0, wMainTexture, y1 - y0,
     997    DpiBitBlt(ca.Handle, xm + I * wMainTexture, y0, wMainTexture, y1 - y0,
    980998      MainTexture.Image.Canvas.Handle, 0, hMainTexture div 2 + Band(I) *
    981999      (y1 - y0), SRCCOPY);
    982   BitBlt(ca.Handle, xm + ((x1 - xm) div wMainTexture) * wMainTexture, y0,
     1000  DpiBitBlt(ca.Handle, xm + ((x1 - xm) div wMainTexture) * wMainTexture, y0,
    9831001    x1 - (xm + ((x1 - xm) div wMainTexture) * wMainTexture), y1 - y0,
    9841002    MainTexture.Image.Canvas.Handle, 0, hMainTexture div 2 + Band(
    9851003    (x1 - xm) div wMainTexture) * (y1 - y0), SRCCOPY);
    9861004  for I := 0 to (xm - x0) div wMainTexture - 1 do
    987     BitBlt(ca.Handle, xm - (I + 1) * wMainTexture, y0, wMainTexture, y1 - y0,
     1005    DpiBitBlt(ca.Handle, xm - (I + 1) * wMainTexture, y0, wMainTexture, y1 - y0,
    9881006      MainTexture.Image.Canvas.Handle, 0, hMainTexture div 2 +
    9891007      Band(-I - 1) * (y1 - y0), SRCCOPY);
    990   BitBlt(ca.Handle, x0, y0, xm - ((xm - x0) div wMainTexture) *
     1008  DpiBitBlt(ca.Handle, x0, y0, xm - ((xm - x0) div wMainTexture) *
    9911009    wMainTexture - x0, y1 - y0, MainTexture.Image.Canvas.Handle,
    9921010    ((xm - x0) div wMainTexture + 1) * wMainTexture - (xm - x0),
     
    10211039      if x1cut < 0 then
    10221040        x1cut := 0;
    1023       BitBlt(ca.Handle, x * Texture.Width + x0cut - xOffset,
     1041      DpiBitBlt(ca.Handle, x * Texture.Width + x0cut - xOffset,
    10241042        y * Texture.Height + y0cut - yOffset, Texture.Width - x0cut - x1cut,
    10251043        Texture.Height - y0cut - y1cut, Texture.Canvas.Handle, x0cut,
     
    10431061procedure Corner(ca: TDpiCanvas; x, y, Kind: Integer; const T: TTexture);
    10441062begin
    1045   { BitBlt(ca.Handle,x,y,8,8,GrExt[T.HGr].Mask.Canvas.Handle,
     1063  { DpiBitBlt(ca.Handle,x,y,8,8,GrExt[T.HGr].Mask.Canvas.Handle,
    10461064    T.xGr+29+Kind*9,T.yGr+89,SRCAND);
    1047     BitBlt(ca.Handle,x,y,8,8,GrExt[T.HGr].Data.Canvas.Handle,
     1065    DpiBitBlt(ca.Handle,x,y,8,8,GrExt[T.HGr].Data.Canvas.Handle,
    10481066    T.xGr+29+Kind*9,T.yGr+89,SRCPAINT); }
    10491067end;
     
    10531071  procedure PaintIcon(x, y, Kind: Integer);
    10541072  begin
    1055     BitBlt(ca.Handle, x, y + 6, 10, 10, GrExt[HGrSystem].Mask.Canvas.Handle,
     1073    DpiBitBlt(ca.Handle, x, y + 6, 10, 10, GrExt[HGrSystem].Mask.Canvas.Handle,
    10561074      66 + Kind mod 11 * 11, 115 + Kind div 11 * 11, SRCAND);
    1057     BitBlt(ca.Handle, x, y + 6, 10, 10, GrExt[HGrSystem].Data.Canvas.Handle,
     1075    DpiBitBlt(ca.Handle, x, y + 6, 10, 10, GrExt[HGrSystem].Data.Canvas.Handle,
    10581076      66 + Kind mod 11 * 11, 115 + Kind div 11 * 11, SRCPAINT);
    10591077  end;
     
    12771295      for i := 0 to val mod 10 - 1 do
    12781296      begin
    1279         BitBlt(Handle, xIcon + 4 + i * (14 * ld div sd), yIcon + 2 + 1, 14,
     1297        DpiBitBlt(Handle, xIcon + 4 + i * (14 * ld div sd), yIcon + 2 + 1, 14,
    12801298          14, GrExt[HGrSystem].Mask.Canvas.Handle, 67 + Kind mod 8 * 15,
    12811299          70 + Kind div 8 * 15, SRCAND);
     
    12851303      for i := 0 to val div 10 - 1 do
    12861304      begin
    1287         BitBlt(dst.Canvas.Handle, xIcon + 4 + (val mod 10) *
     1305        DpiBitBlt(dst.Canvas.Handle, xIcon + 4 + (val mod 10) *
    12881306          (14 * ld div sd) + i * (14 * ld div sd), yIcon + 3, 14, 14,
    12891307          GrExt[HGrSystem].Mask.Canvas.Handle, 67 + 7 mod 8 * 15,
     
    13101328      for i := 0 to val div 10 - 1 do
    13111329      begin
    1312         BitBlt(Handle, xIcon + 4 + i * (14 * ld div sd), yIcon + 3, 14, 14,
     1330        DpiBitBlt(Handle, xIcon + 4 + i * (14 * ld div sd), yIcon + 3, 14, 14,
    13131331          GrExt[HGrSystem].Mask.Canvas.Handle, 67 + Kind mod 8 * 15,
    13141332          70 + Kind div 8 * 15, SRCAND);
     
    13181336      for i := 0 to val mod 10 - 1 do
    13191337      begin
    1320         BitBlt(dst.Canvas.Handle, xIcon + 4 + (val div 10) *
     1338        DpiBitBlt(dst.Canvas.Handle, xIcon + 4 + (val div 10) *
    13211339          (14 * ld div sd) + i * (10 * ld div sd), yIcon + 7, 10, 10,
    13221340          GrExt[HGrSystem].Mask.Canvas.Handle, 66 + Kind mod 11 * 11,
     
    13551373  begin
    13561374    for i := 0 to pos div 8 - 1 do
    1357       BitBlt(Handle, x + i * 8, y, 8, 7,
     1375      DpiBitBlt(Handle, x + i * 8, y, 8, 7,
    13581376        GrExt[HGrSystem].Data.Canvas.Handle, 104, 9 + 8 * Kind, SRCCOPY);
    1359     BitBlt(Handle, x + 8 * (pos div 8), y, pos - 8 * (pos div 8), 7,
     1377    DpiBitBlt(Handle, x + 8 * (pos div 8), y, pos - 8 * (pos div 8), 7,
    13601378      GrExt[HGrSystem].Data.Canvas.Handle, 104, 9 + 8 * Kind, SRCCOPY);
    13611379    if Growth > 0 then
    13621380    begin
    13631381      for i := 0 to Growth div 8 - 1 do
    1364         BitBlt(Handle, x + pos + i * 8, y, 8, 7,
     1382        DpiBitBlt(Handle, x + pos + i * 8, y, 8, 7,
    13651383          GrExt[HGrSystem].Data.Canvas.Handle, 112, 9 + 8 * Kind, SRCCOPY);
    1366       BitBlt(Handle, x + pos + 8 * (Growth div 8), y,
     1384      DpiBitBlt(Handle, x + pos + 8 * (Growth div 8), y,
    13671385        Growth - 8 * (Growth div 8), 7, GrExt[HGrSystem].Data.Canvas.Handle,
    13681386        112, 9 + 8 * Kind, SRCCOPY);
     
    13711389    begin
    13721390      for i := 0 to -Growth div 8 - 1 do
    1373         BitBlt(Handle, x + pos + i * 8, y, 8, 7,
     1391        DpiBitBlt(Handle, x + pos + i * 8, y, 8, 7,
    13741392          GrExt[HGrSystem].Data.Canvas.Handle, 104, 1, SRCCOPY);
    1375       BitBlt(Handle, x + pos + 8 * (-Growth div 8), y, -Growth -
     1393      DpiBitBlt(Handle, x + pos + 8 * (-Growth div 8), y, -Growth -
    13761394        8 * (-Growth div 8), 7,
    13771395        GrExt[HGrSystem].Data.Canvas.Handle, 104, 1, SRCCOPY);
     
    14041422  ImageOp_BCC(LogoBuffer, Templates, 0, 0, 1, 1, wLogo, hLogo,
    14051423    clLight, clShade);
    1406   BitBlt(ca.Handle, x, y, wLogo, hLogo, LogoBuffer.Canvas.Handle, 0,
     1424  DpiBitBlt(ca.Handle, x, y, wLogo, hLogo, LogoBuffer.Canvas.Handle, 0,
    14071425    0, SRCCOPY);
    14081426end;
Note: See TracChangeset for help on using the changeset viewer.