Changeset 245


Ignore:
Timestamp:
May 21, 2020, 7:58:42 PM (4 years ago)
Author:
chronos
Message:
  • Added: Inactive scaling functions for future HighDPI support.
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/Help.pas

    r206 r245  
    441441const
    442442  nHeaven = 28;
    443   maxsum = 9 * 9 * 255 * 75 div 100;
     443  MaxSum = 9 * 9 * 255 * 75 div 100;
    444444var
    445445  x, y, dx, dy, xSrc, ySrc, sum, xx: integer;
     
    457457  xSrc := iix mod 7 * xSizeBig;
    458458  ySrc := (iix div 7 + 1) * ySizeBig;
    459   for y := 0 to ySizeBig * 2 - 1 do
    460     if ((y0 + y) >= 0) and ((y0 + y) < InnerHeight) then begin
    461       PaintPtr := PixelPointer(OffScreen, 0, y0 + y);
    462       CoalPtr := PixelPointer(Templates, 0, yCoal + y);
     459  for y := 0 to ScaleToNative(ySizeBig) * 2 - 1 do
     460    if ((ScaleToNative(y0) + y) >= 0) and ((ScaleToNative(y0) + y) < ScaleToNative(InnerHeight)) then begin
     461      PaintPtr := PixelPointer(OffScreen, 0, ScaleToNative(y0) + y);
     462      CoalPtr := PixelPointer(Templates, 0, ScaleToNative(yCoal) + y);
    463463      for dy := -1 to 1 do
    464         if ((Max(y + dy, 0) shr 1) >= 0) and ((Max(y + dy, 0) shr 1) < ySizeBig) then
    465           ImpPtr[dy] := PixelPointer(BigImp, 0, ySrc + (Max(y + dy, 0) shr 1));
    466       for x := 0 to xSizeBig * 2 - 1 do begin
     464        if ((Max(y + ScaleToNative(dy), 0) shr 1) >= 0) and ((Max(y + ScaleToNative(dy), 0) shr 1) < ScaleToNative(ySizeBig)) then
     465          ImpPtr[dy] := PixelPointer(BigImp, 0, ScaleToNative(ySrc) + (Max(y + ScaleToNative(dy), 0) shr 1));
     466      for x := 0 to ScaleToNative(xSizeBig) * 2 - 1 do begin
    467467        sum := 0;
    468468        for dx := -1 to 1 do begin
    469           xx := xSrc + Max((x + dx), 0) shr 1;
     469          xx := ScaleToNative(xSrc) + Max((x + ScaleToNative(dx)), 0) shr 1;
    470470          for dy := -1 to 1 do begin
    471471            ImpPtr[dy].SetX(xx);
    472             if ((y + dy) shr 1 < 0) or ((y + dy) shr 1 >= ySizeBig) or
    473               ((x + dx) shr 1 < 0) or ((x + dx) shr 1 >= xSizeBig) or
    474               ((y + dy) shr 1 < nHeaven) and
     472            if ((y + ScaleToNative(dy)) shr 1 < 0) or ((y + ScaleToNative(dy)) shr 1 >= ScaleToNative(ySizeBig)) or
     473              ((x + ScaleToNative(dx)) shr 1 < 0) or ((x + ScaleToNative(dx)) shr 1 >= ScaleToNative(xSizeBig)) or
     474              ((y + ScaleToNative(dy)) shr 1 < ScaleToNative(nHeaven)) and
    475475              (ImpPtr[dy].Pixel^.B shl 16 + ImpPtr[dy].Pixel^.G shl 8 +
    476               ImpPtr[dy].Pixel^.R = Heaven[(y + dy) shr 1]) then
     476              ImpPtr[dy].Pixel^.R = Heaven[(ScaleFromNative(y) + dy) shr 1]) then
    477477              sum := sum + 9 * 255
    478478            else
     
    481481          end;
    482482        end;
    483         if sum < maxsum then begin // no saturation
    484           CoalPtr.SetX(xCoal + x);
    485           sum := 1 shl 22 - (maxsum - sum) * (256 - CoalPtr.Pixel^.B * 2);
     483        if sum < MaxSum then begin // no saturation
     484          CoalPtr.SetX(ScaleToNative(xCoal) + x);
     485          sum := 1 shl 22 - (MaxSum - sum) * (256 - CoalPtr.Pixel^.B * 2);
    486486          PaintPtr.SetX(x0 + x);
    487487          PaintPtr.Pixel^.B := PaintPtr.Pixel^.B * sum shr 22;
  • trunk/LocalPlayer/IsoEngine.pas

    r206 r245  
    3434    function IsShoreTile(Loc: integer): boolean;
    3535    procedure MakeDark(Line: PPixelPointer; Length: Integer);
    36     procedure ShadeOutside(x0, y0, x1, y1, xm, ym: integer);
     36    procedure ShadeOutside(x0, y0, Width, Height, xm, ym: integer);
    3737  protected
    3838    FOutput: TBitmap;
     
    10151015            1 + 8 * (xxt * 2 + 1), 1 + yyt + 16 * (yyt * 3 + 1));
    10161016          Borders.BeginUpdate;
    1017           for dy := 0 to yyt * 2 - 1 do
    1018           begin
    1019             PixelPtr := PixelPointer(Borders, 0, p1 * (yyt * 2) + dy);
    1020             for dx := 0 to xxt * 2 - 1 do begin
     1017          PixelPtr := PixelPointer(Borders, ScaleToNative(0), ScaleToNative(p1 * (yyt * 2)));
     1018          for dy := 0 to ScaleToNative(yyt * 2) - 1 do begin
     1019            for dx := 0 to ScaleToNative(xxt * 2) - 1 do begin
    10211020              if PixelPtr.Pixel^.B = 99 then begin
    10221021                PixelPtr.Pixel^.B := Tribe[p1].Color shr 16 and $FF;
     
    10261025              PixelPtr.NextPixel;
    10271026            end;
     1027            PixelPtr.NextLine;
    10281028          end;
    10291029          Borders.EndUpdate;
     
    13301330end;
    13311331
    1332 procedure TIsoMap.ShadeOutside(x0, y0, x1, y1, xm, ym: integer);
     1332procedure TIsoMap.ShadeOutside(x0, y0, Width, Height, xm, ym: integer);
    13331333const
    13341334  rShade = 3.75;
     
    13391339begin
    13401340  FOutput.BeginUpdate;
    1341   for y := y0 to y1 - 1 do begin
    1342     Line := PixelPointer(FOutput, 0, y);
    1343     y_n := (y - ym) / yyt;
     1341  Line := PixelPointer(FOutput, ScaleToNative(x0), ScaleToNative(y0));
     1342  for y := 0 to ScaleToNative(Height) - 1 do begin
     1343    y_n := (ScaleFromNative(y) + y0 - ym) / yyt;
    13441344    if abs(y_n) < rShade then begin
    13451345      // Darken left and right parts of elipsis
    13461346      w_n := sqrt(sqr(rShade) - sqr(y_n));
    13471347      wBright := trunc(w_n * xxt + 0.5);
    1348       Line.SetX(x0);
    1349       MakeDark(@Line, xm - x0 - wBright);
    1350       Line.SetX(xm + wBright);
    1351       MakeDark(@Line, x1 - xm - wBright);
     1348      Line.SetX(0);
     1349      MakeDark(@Line, ScaleToNative(xm - wBright));
     1350      Line.SetX(ScaleToNative(xm + wBright));
     1351      MakeDark(@Line, ScaleToNative(Width - xm - wBright));
    13521352    end else begin
    13531353      // Darken entire line
    1354       Line.SetX(x0);
    1355       MakeDark(@Line, x1 - x0);
     1354      Line.SetX(0);
     1355      MakeDark(@Line, ScaleToNative(Width));
    13561356    end;
     1357    Line.NextLine;
    13571358  end;
    13581359  FOutput.EndUpdate;
     
    15761577    xm := x + (dx + 1) * xxt;
    15771578    ym := y + (dy + 1) * yyt + yyt;
    1578     ShadeOutside(FLeft, FTop, FRight, FBottom, xm, ym);
     1579    ShadeOutside(FLeft, FTop, FRight - FLeft, FBottom - FTop, xm, ym);
    15791580    CityGrid(xm, ym, CityAllowClick);
    15801581    for dy := -2 to ny + 1 do
  • trunk/LocalPlayer/MessgEx.pas

    r227 r245  
    237237  Screwed: array [0 .. wScrewed - 1, 0 .. hScrewed - 1, 0 .. 3] of single;
    238238  SrcPtr: TPixelPointer;
    239 begin
     239  Width: Integer;
     240  Height: Integer;
     241begin
     242  Width := 56;
     243  Height := 40;
    240244  if IconIndex >= 0 then begin
    241245    xIcon := IconIndex mod 7 * xSizeBig;
    242246    yIcon := (IconIndex + SystemIconLines * 7) div 7 * ySizeBig;
    243247    // prepare screwed icon
    244     fillchar(Screwed, sizeof(Screwed), 0);
     248    FillChar(Screwed, sizeof(Screwed), 0);
    245249    BigImp.BeginUpdate;
    246     for iy := 0 to 39 do begin
    247       for ix := 0 to 55 do begin
    248         SrcPtr := PixelPointer(BigImp, ix + xIcon, iy + yIcon);
    249         xR := ix * (37 + iy * 5 / 40) / 56;
     250    SrcPtr := PixelPointer(BigImp, ScaleToNative(xIcon), ScaleToNative(yIcon));
     251    for iy := 0 to ScaleToNative(Height) - 1 do begin
     252      for ix := 0 to ScaleToNative(Width) - 1 do begin
     253        xR := ScaleFromNative(ix) * (37 + ScaleFromNative(iy) * 5 / Height) / Width;
    250254        xDst := Trunc(xR);
    251255        xR := Frac(xR);
    252         x1 := (120 - ix) * (120 - ix) - 10000;
    253         yR := iy * 18 / 40 + x1 * x1 / 4000000;
     256        x1 := (120 - ScaleFromNative(ix)) * (120 - ScaleFromNative(ix)) - 10000;
     257        yR := ScaleFromNative(iy) * 18 / Height + x1 * x1 / 4000000;
    254258        yDst := Trunc(yR);
    255259        yR := Frac(yR);
     
    272276            Screwed[xDst + dx, yDst + dy, 3] := Screwed[xDst + dx, yDst + dy,
    273277              3] + share;
    274           end;
    275       end;
     278        end;
     279        SrcPtr.NextPixel;
     280      end;
     281      SrcPtr.NextLine;
    276282    end;
    277283    BigImp.EndUpdate;
  • trunk/LocalPlayer/Term.pas

    r227 r245  
    554554  Sharpen = 80;
    555555type
    556   TBuffer = array [0 .. 99999, 0 .. 2] of integer;
     556  TBuffer = array [0 .. 99999, 0 .. 2] of Integer;
    557557var
    558   sum, Cnt, dx, dy, nx, ny, ix, iy, ir, x, y, c, ch, xdivider,
    559     ydivider: integer;
    560   resampled: ^TBuffer;
     558  Sum, Cnt, dx, dy, nx, ny, ix, iy, ir, x, y, c, ch: Integer;
     559  xdivider, ydivider: Integer;
     560  Resampled: ^TBuffer;
    561561  PixelPtr: TPixelPointer;
    562562begin
    563   nx := BigImp.width div xSizeBig * xSizeSmall;
    564   ny := BigImp.height div ySizeBig * ySizeSmall;
     563  nx := BigImp.Width div xSizeBig * xSizeSmall;
     564  ny := BigImp.Height div ySizeBig * ySizeSmall;
    565565
    566566  // resample icons
    567   GetMem(resampled, nx * ny * 12);
    568   FillChar(resampled^, nx * ny * 12, 0);
     567  GetMem(Resampled, nx * ny * 12);
     568  FillChar(Resampled^, nx * ny * 12, 0);
    569569  BigImp.BeginUpdate;
    570   for ix := 0 to BigImp.width div xSizeBig - 1 do
    571     for iy := 0 to BigImp.height div ySizeBig - 1 do
    572       for y := 0 to ySizeBig - 2 * cut - 1 do
    573       begin
    574         ydivider := (y * ySizeSmall div (ySizeBig - 2 * cut) + 1) *
    575           (ySizeBig - 2 * cut) - y * ySizeSmall;
     570  for ix := 0 to BigImp.Width div xSizeBig - 1 do
     571    for iy := 0 to BigImp.Height div ySizeBig - 1 do begin
     572      PixelPtr := PixelPointer(BigImp, ScaleToNative(ix * xSizeBig),
     573        ScaleToNative(cut + iy * ySizeBig));
     574      for y := 0 to ScaleToNative(ySizeBig - 2 * cut) - 1 do begin
     575        ydivider := (ScaleFromNative(y) * ySizeSmall div (ySizeBig - 2 * cut) + 1) *
     576          (ySizeBig - 2 * cut) - ScaleFromNative(y) * ySizeSmall;
    576577        if ydivider > ySizeSmall then
    577578          ydivider := ySizeSmall;
    578         PixelPtr := PixelPointer(BigImp, 0, cut + iy * ySizeBig + y);
    579         for x := 0 to xSizeBig - 1 do
    580         begin
    581           ir := ix * xSizeSmall + iy * nx * ySizeSmall + x *
    582             xSizeSmall div xSizeBig + y *
     579        for x := 0 to ScaleToNative(xSizeBig) - 1 do begin
     580          ir := ix * xSizeSmall + iy * nx * ySizeSmall + ScaleFromNative(x) *
     581            xSizeSmall div xSizeBig + ScaleFromNative(y) *
    583582            ySizeSmall div (ySizeBig - 2 * cut) * nx;
    584           xdivider := (x * xSizeSmall div xSizeBig + 1) * xSizeBig - x *
    585             xSizeSmall;
     583          xdivider := (ScaleFromNative(x) * xSizeSmall div xSizeBig + 1) *
     584            xSizeBig - ScaleFromNative(x) * xSizeSmall;
    586585          if xdivider > xSizeSmall then
    587586            xdivider := xSizeSmall;
    588           for ch := 0 to 2 do
    589           begin
    590             PixelPtr.SetX(ix * xSizeBig + x);
     587          for ch := 0 to 2 do begin
    591588            c := PixelPtr.Pixel^.Planes[ch];
    592             inc(resampled[ir, ch], c * xdivider * ydivider);
     589            Inc(Resampled[ir, ch], c * xdivider * ydivider);
    593590            if xdivider < xSizeSmall then
    594               inc(resampled[ir + 1, ch], c * (xSizeSmall - xdivider) *
     591              Inc(Resampled[ir + 1, ch], c * (xSizeSmall - xdivider) *
    595592                ydivider);
    596593            if ydivider < ySizeSmall then
    597               inc(resampled[ir + nx, ch],
     594              Inc(Resampled[ir + nx, ch],
    598595                c * xdivider * (ySizeSmall - ydivider));
    599596            if (xdivider < xSizeSmall) and (ydivider < ySizeSmall) then
    600               inc(resampled[ir + nx + 1, ch], c * (xSizeSmall - xdivider) *
     597              Inc(Resampled[ir + nx + 1, ch], c * (xSizeSmall - xdivider) *
    601598                (ySizeSmall - ydivider));
    602599          end;
     600          PixelPtr.NextPixel;
    603601        end;
     602        PixelPtr.NextLine;
    604603      end;
     604    end;
    605605  BigImp.EndUpdate;
    606606
    607   // sharpen resampled icons
     607  // Sharpen Resampled icons
    608608  SmallImp.SetSize(nx, ny);
    609609  SmallImp.BeginUpdate;
    610   for y := 0 to ny - 1 do begin
    611     PixelPtr := PixelPointer(SmallImp, 0, y);
    612     for x := 0 to nx - 1 do
     610  PixelPtr := PixelPointer(SmallImp);
     611  for y := 0 to ScaleToNative(ny) - 1 do begin
     612    for x := 0 to ScaleToNative(nx) - 1 do begin
    613613      for ch := 0 to 2 do begin
    614         sum := 0;
     614        Sum := 0;
    615615        Cnt := 0;
    616616        for dy := -1 to 1 do
    617           if ((dy >= 0) or (y mod ySizeSmall > 0)) and
    618             ((dy <= 0) or (y mod ySizeSmall < ySizeSmall - 1)) then
     617          if ((dy >= 0) or (ScaleFromNative(y) mod ySizeSmall > 0)) and
     618            ((dy <= 0) or (ScaleFromNative(y) mod ySizeSmall < ySizeSmall - 1)) then
    619619            for dx := -1 to 1 do
    620               if ((dx >= 0) or (x mod xSizeSmall > 0)) and
    621                 ((dx <= 0) or (x mod xSizeSmall < xSizeSmall - 1)) then
     620              if ((dx >= 0) or (ScaleFromNative(x) mod xSizeSmall > 0)) and
     621                ((dx <= 0) or (ScaleFromNative(x) mod xSizeSmall < xSizeSmall - 1)) then
    622622              begin
    623                 inc(sum, resampled[x + dx + nx * (y + dy), ch]);
    624                 inc(Cnt);
     623                Inc(Sum, Resampled[ScaleFromNative(x) + dx + nx * (ScaleFromNative(y) + dy), ch]);
     624                Inc(Cnt);
    625625              end;
    626         sum := ((Cnt * Sharpen + 800) * resampled[x + nx * y, ch] - sum *
     626        Sum := ((Cnt * Sharpen + 800) * Resampled[ScaleFromNative(x) + nx * ScaleFromNative(y), ch] - Sum *
    627627          Sharpen) div (800 * xSizeBig * (ySizeBig - 2 * cut));
    628         if sum < 0 then sum := 0;
    629         if sum > 255 then sum := 255;
    630         PixelPtr.SetX(x);
    631         PixelPtr.Pixel^.Planes[ch] := sum;
     628        if Sum < 0 then Sum := 0;
     629        if Sum > 255 then Sum := 255;
     630        PixelPtr.Pixel^.Planes[ch] := Sum;
    632631      end;
     632      PixelPtr.NextPixel;
     633    end;
     634    PixelPtr.NextLine;
    633635  end;
    634636  SmallImp.EndUpdate;
    635   FreeMem(resampled);
     637  FreeMem(Resampled);
    636638end;
    637639
     
    40664068  MiniPixel := PixelPointer(Mini);
    40674069  PrevMiniPixel := PixelPointer(Mini);
    4068   for y := 0 to G.ly - 1 do
    4069   begin
    4070     for x := 0 to G.lx - 1 do
    4071       if MyMap[x + G.lx * y] and fTerrain <> fUNKNOWN then
    4072       begin
    4073         Loc := x + G.lx * y;
     4070  for y := 0 to ScaleToNative(G.ly) - 1 do
     4071  begin
     4072    for x := 0 to ScaleToNative(G.lx) - 1 do
     4073      if MyMap[ScaleFromNative(x) + G.lx * ScaleFromNative(y)] and fTerrain <> fUNKNOWN then
     4074      begin
     4075        Loc := ScaleFromNative(x) + G.lx * ScaleFromNative(y);
    40744076        for i := 0 to 1 do
    40754077        begin
    4076           xm := ((x - xwMini) * 2 + i + y and 1 - hw + G.lx * 5) mod (G.lx * 2);
     4078          xm := ((x - ScaleToNative(xwMini)) * 2 + i + y and 1 - ScaleToNative(hw) +
     4079            ScaleToNative(G.lx) * 5) mod (ScaleToNative(G.lx) * 2);
    40774080          MiniPixel.SetXY(xm, y);
    40784081          cm := MiniColors[MyMap[Loc] and fTerrain, i];
  • trunk/LocalPlayer/Wonders.pas

    r230 r245  
    104104  Ch: Integer;
    105105  Line: array [0..3] of TPixelPointer;
    106 begin
     106  Width: Integer;
     107  Height: Integer;
     108begin
     109  Width := ScaleToNative(180);
     110  Height := ScaleToNative(128);
    107111  Offscreen.BeginUpdate;
    108   Line[0] := PixelPointer(Offscreen, Center.X, Center.Y);
    109   Line[1] := PixelPointer(Offscreen, Center.X, Center.Y - 1);
    110   Line[2] := PixelPointer(Offscreen, Center.X - 1, Center.Y);
    111   Line[3] := PixelPointer(Offscreen, Center.X - 1, Center.Y - 1);
    112   for Y := 0 to 127 do begin
    113     for X := 0 to 179 do begin
    114       r := X * X * (32 * 32) + Y * Y * (45 * 45);
    115       ax := ((1 shl 16 div 32) * 45) * Y;
    116       if (r < 8 * 128 * 180 * 180) and
    117         ((r >= 32 * 64 * 90 * 90) and (ax < amax2 * X) and
     112  Line[0] := PixelPointer(Offscreen, ScaleToNative(Center.X), ScaleToNative(Center.Y));
     113  Line[1] := PixelPointer(Offscreen, ScaleToNative(Center.X), ScaleToNative(Center.Y) - 1);
     114  Line[2] := PixelPointer(Offscreen, ScaleToNative(Center.X) - 1, ScaleToNative(Center.Y));
     115  Line[3] := PixelPointer(Offscreen, ScaleToNative(Center.X) - 1, ScaleToNative(Center.Y) - 1);
     116  for Y := 0 to Height - 1 do begin
     117    for X := 0 to Width - 1 do begin
     118      r := X * X * ((Height div 4) * (Height div 4)) + Y * Y * ((Width div 4) * (Width div 4));
     119      ax := ((1 shl 16 div (Height div 4)) * (Width div 4)) * Y;
     120      if (r < ScaleToNative(8) * Height * Width * Width) and
     121        ((r >= (Height div 4) * (Height div 2) * (Width div 2) * (Width div 2)) and (ax < amax2 * X) and
    118122        ((ax < amax0 * X) or (ax > amin2 * X)) or (ax > amin1 * X) and
    119123        ((ax < amax1 * X) or (ax > amin3 * X))) then begin
     
    156160  x0Src := (i mod 7) * xSizeBig;
    157161  y0Src := (i div 7 + SystemIconLines) * ySizeBig;
    158   Src := PixelPointer(BigImp, x0Src, y0Src);
    159   Dst := PixelPointer(Offscreen, x0Dst, y0Dst);
    160   for Y := 0 to ySizeBig - 1 do begin
    161     for X := 0 to xSizeBig - 1 do begin
     162  Src := PixelPointer(BigImp, ScaleToNative(x0Src), ScaleToNative(y0Src));
     163  Dst := PixelPointer(Offscreen, ScaleToNative(x0Dst), ScaleToNative(y0Dst));
     164  for Y := 0 to ScaleToNative(ySizeBig) - 1 do begin
     165    for X := 0 to ScaleToNative(xSizeBig) - 1 do begin
    162166      Darken := ((255 - Src.Pixel^.B) * 3 + (255 - Src.Pixel^.G) *
    163167        15 + (255 - Src.Pixel^.R) * 9) div 128;
     
    229233              ySizeBig + 6, (wMaintexture - ClientWidth) div 2,
    230234              (hMaintexture - ClientHeight) div 2);
    231             //DarkIcon(I);
     235            DarkIcon(I);
    232236          end;
    233237        -2: // destroyed
  • trunk/Packages/CevoComponents/ScreenTools.pas

    r230 r245  
    4242procedure ImageOp_CBC(Dst, Src: TBitmap; xDst, yDst, xSrc, ySrc, Width, Height,
    4343  Color0, Color2: Integer);
    44 procedure ImageOp_CCC(bmp: TBitmap; x, y, w, h, Color0, Color1, Color2: Integer);
     44procedure ImageOp_CCC(bmp: TBitmap; x, y, Width, Height, Color0, Color1, Color2: Integer);
    4545function BitBltCanvas(DestCanvas: TCanvas; X, Y, Width, Height: Integer;
    4646  SrcCanvas: TCanvas; XSrc, YSrc: Integer; Rop: DWORD = SRCCOPY): Boolean; overload;
     
    5858procedure FrameImage(ca: TCanvas; Src: TBitmap;
    5959  x, y, Width, Height, xSrc, ySrc: integer; IsControl: boolean = False);
    60 procedure GlowFrame(dst: TBitmap; x0, y0, Width, Height: integer; cl: TColor);
     60procedure GlowFrame(Dst: TBitmap; x0, y0, Width, Height: integer; cl: TColor);
    6161procedure InitOrnament;
    6262procedure InitCityMark(const T: TTexture);
     
    9393procedure Texturize(Dest, Texture: TBitmap; TransparentColor: Integer);
    9494procedure DarkenImage(Bitmap: TBitmap; Change: Integer);
     95function ScaleToNative(Value: Integer): Integer;
     96function ScaleFromNative(Value: Integer): Integer;
    9597
    9698const
     
    364366  Bitmap.BeginUpdate;
    365367  PixelPtr := PixelPointer(Bitmap);
    366   for Y := 0 to Bitmap.Height - 1 do begin
    367     for X := 0 to Bitmap.Width - 1 do begin
     368  for Y := 0 to ScaleToNative(Bitmap.Height) - 1 do begin
     369    for X := 0 to ScaleToNative(Bitmap.Width) - 1 do begin
    368370      PixelPtr.Pixel^ := ApplyGammaToPixel(PixelPtr.Pixel^);
    369371      PixelPtr.NextPixel;
     
    382384  SrcPtr := PixelPointer(Src);
    383385  DstPtr := PixelPointer(Dst);
    384   for Y := 0 to Src.Height - 1 do begin
    385     for X := 0 to Src.Width - 1 do begin
     386  for Y := 0 to ScaleToNative(Src.Height - 1) do begin
     387    for X := 0 to ScaleToNative(Src.Width - 1) do begin
    386388      DstPtr.Pixel^.B := SrcPtr.Pixel^.B;
    387389      DstPtr.Pixel^.G := SrcPtr.Pixel^.B;
     
    404406    Path := Path + '.png';
    405407  if ExtractFileExt(Path) = '.jpg' then begin
    406     jtex := tjpegimage.Create;
     408    jtex := TJpegImage.Create;
    407409    try
    408410      jtex.LoadFromFile(Path);
     
    506508    DataPixel := PixelPointer(GrExt[nGrExt].Data);
    507509    MaskPixel := PixelPointer(GrExt[nGrExt].Mask);
    508     for y := 0 to Source.Height - 1 do begin
    509       for x := 0 to xmax - 1 do begin
     510    for y := 0 to ScaleToNative(Source.Height) - 1 do begin
     511      for x := 0 to ScaleToNative(xmax) - 1 do begin
    510512        OriginalColor := DataPixel.Pixel^.ARGB and $FFFFFF;
    511513        if (OriginalColor = $FF00FF) or (OriginalColor = $7F007F) then
     
    545547begin
    546548  Dst.BeginUpdate;
    547   PixelPtr := PixelPointer(Dst, X, Y);
    548   for yy := 0 to Height - 1 do begin
    549     for xx := 0 to Width - 1 do begin
     549  PixelPtr := PixelPointer(Dst, ScaleToNative(X), ScaleToNative(Y));
     550  for yy := 0 to ScaleToNative(Height) - 1 do begin
     551    for xx := 0 to ScaleToNative(Width) - 1 do begin
    550552      PixelPtr.Pixel^.B := PixelPtr.Pixel^.B div 2;
    551553      PixelPtr.Pixel^.G := PixelPtr.Pixel^.G div 2;
     
    565567begin
    566568  Dst.BeginUpdate;
    567   PixelPtr := PixelPointer(Dst, X, Y);
    568   for YY := 0 to Height - 1 do begin
    569     for XX := 0 to Width - 1 do begin
     569  PixelPtr := PixelPointer(Dst, ScaleToNative(X), ScaleToNative(Y));
     570  for YY := 0 to ScaleToNative(Height) - 1 do begin
     571    for XX := 0 to ScaleToNative(Width) - 1 do begin
    570572      Gray := (Integer(PixelPtr.Pixel^.B) + Integer(PixelPtr.Pixel^.G) +
    571573        Integer(PixelPtr.Pixel^.R)) * 85 shr 8;
     
    589591  PixelDst: TPixelPointer;
    590592begin
     593  xDst := ScaleToNative(xDst);
     594  yDst := ScaleToNative(yDst);
     595  xSrc := ScaleToNative(xSrc);
     596  ySrc := ScaleToNative(ySrc);
     597  Width := ScaleToNative(Width);
     598  Height := ScaleToNative(Height);
    591599  //Assert(Src.PixelFormat = pf8bit);
    592600  Assert(dst.PixelFormat = pf24bit);
     
    601609    yDst := 0;
    602610  end;
    603   if xDst + Width > dst.Width then
    604     Width := dst.Width - xDst;
    605   if yDst + Height > dst.Height then
    606     Height := dst.Height - yDst;
     611  if xDst + Width > ScaleToNative(dst.Width) then
     612    Width := ScaleToNative(dst.Width) - xDst;
     613  if yDst + Height > ScaleToNative(dst.Height) then
     614    Height := ScaleToNative(dst.Height) - yDst;
    607615  if (Width < 0) or (Height < 0) then
    608616    exit;
     
    651659  DstPixel: TPixelPointer;
    652660begin
     661  xDst := ScaleToNative(xDst);
     662  yDst := ScaleToNative(yDst);
     663  xSrc := ScaleToNative(xSrc);
     664  ySrc := ScaleToNative(ySrc);
     665  Width := ScaleToNative(Width);
     666  Height := ScaleToNative(Height);
    653667  if xDst < 0 then begin
    654668    Width := Width + xDst;
     
    661675    yDst := 0;
    662676  end;
    663   if xDst + Width > dst.Width then
    664     Width := dst.Width - xDst;
    665   if yDst + Height > dst.Height then
    666     Height := dst.Height - yDst;
     677  if xDst + Width > ScaleToNative(dst.Width) then
     678    Width := ScaleToNative(dst.Width) - xDst;
     679  if yDst + Height > ScaleToNative(dst.Height) then
     680    Height := ScaleToNative(dst.Height) - yDst;
    667681  if (Width < 0) or (Height < 0) then
    668682    exit;
     
    712726  DstPixel: TPixelPointer;
    713727begin
     728  xDst := ScaleToNative(xDst);
     729  yDst := ScaleToNative(yDst);
     730  xSrc := ScaleToNative(xSrc);
     731  ySrc := ScaleToNative(ySrc);
     732  Width := ScaleToNative(Width);
     733  Height := ScaleToNative(Height);
    714734  Src.BeginUpdate;
    715735  Dst.BeginUpdate;
     
    744764end;
    745765
    746 procedure ImageOp_CCC(bmp: TBitmap; x, y, w, h, Color0, Color1, Color2: Integer);
     766procedure ImageOp_CCC(bmp: TBitmap; x, y, Width, Height, Color0, Color1, Color2: Integer);
    747767// Bmp is template
    748768// B channel = Color0 amp, 128=original brightness
     
    753773  PixelPtr: TPixelPointer;
    754774begin
     775  X := ScaleToNative(X);
     776  Y := ScaleToNative(Y);
     777  Width := ScaleToNative(Width);
     778  Height := ScaleToNative(Height);
    755779  bmp.BeginUpdate;
    756780  assert(bmp.PixelFormat = pf24bit);
    757   h := y + h;
     781  Height := y + Height;
    758782  PixelPtr := PixelPointer(Bmp, x, y);
    759   while y < h do begin
    760     for i := 0 to w - 1 do begin
     783  while y < Height do begin
     784    for i := 0 to Width - 1 do begin
    761785      Red := ((PixelPtr.Pixel^.B * (Color0 and $0000FF) + PixelPtr.Pixel^.G *
    762786        (Color1 and $0000FF) + PixelPtr.Pixel^.R * (Color2 and $0000FF)) shr 8) and $ff;
     
    905929end;
    906930
    907 procedure GlowFrame(dst: TBitmap; x0, y0, Width, Height: Integer; cl: TColor);
     931procedure GlowFrame(Dst: TBitmap; x0, y0, Width, Height: Integer; cl: TColor);
    908932var
    909933  x, y, ch, r: Integer;
    910934  DstPtr: TPixelPointer;
    911 begin
    912   dst.BeginUpdate;
    913   DstPtr := PixelPointer(dst, x0 - GlowRange + 1, y0 - GlowRange + 1);
    914   for y := -GlowRange + 1 to Height - 1 + GlowRange - 1 do begin
    915     for x := -GlowRange + 1 to Width - 1 + GlowRange - 1 do begin
     935  DpiGlowRange: Integer;
     936begin
     937  DpiGlowRange := ScaleToNative(GlowRange);
     938  X0 := ScaleToNative(X0);
     939  Y0 := ScaleToNative(Y0);
     940  Width := ScaleToNative(Width);
     941  Height := ScaleToNative(Height);
     942  Dst.BeginUpdate;
     943  DstPtr := PixelPointer(Dst, x0 - DpiGlowRange + 1, y0 - DpiGlowRange + 1);
     944  for y := -DpiGlowRange + 1 to Height - 1 + DpiGlowRange - 1 do begin
     945    for x := -DpiGlowRange + 1 to Width - 1 + DpiGlowRange - 1 do begin
    916946      if x < 0 then
    917947        if y < 0 then
     
    938968      if r = 0 then
    939969        r := 1;
    940       if r < GlowRange then
     970      if r < DpiGlowRange then
    941971        for ch := 0 to 2 do
    942972          DstPtr.Pixel^.Planes[2 - ch] :=
    943973            (DstPtr.Pixel^.Planes[2 - ch] * (r - 1) + (cl shr (8 * ch) and $FF) *
    944             (GlowRange - r)) div (GlowRange - 1);
     974            (DpiGlowRange - r)) div (DpiGlowRange - 1);
    945975      DstPtr.NextPixel;
    946976    end;
    947977    DstPtr.NextLine;
    948978  end;
    949   dst.EndUpdate;
     979  Dst.EndUpdate;
    950980end;
    951981
     
    15121542  DstPixel := PixelPointer(Dest);
    15131543  SrcPixel := PixelPointer(Texture);
    1514   for Y := 0 to Dest.Height - 1 do begin
    1515     for X := 0 to Dest.Width - 1 do begin
     1544  for Y := 0 to ScaleToNative(Dest.Height) - 1 do begin
     1545    for X := 0 to ScaleToNative(Dest.Width) - 1 do begin
    15161546      if (DstPixel.Pixel^.ARGB and $FFFFFF) = TransparentColor then begin
    15171547        SrcPixel.SetXY(X mod TexWidth, Y mod TexHeight);
     
    15341564  Bitmap.BeginUpdate;
    15351565  PicturePixel := PixelPointer(Bitmap);
    1536   for y := 0 to Bitmap.Height - 1 do begin
    1537     for x := 0 to Bitmap.Width - 1 do begin
     1566  for y := 0 to ScaleToNative(Bitmap.Height) - 1 do begin
     1567    for x := 0 to ScaleToNative(Bitmap.Width) - 1 do begin
    15381568      PicturePixel.Pixel^.B := Max(PicturePixel.Pixel^.B - Change, 0);
    15391569      PicturePixel.Pixel^.G := Max(PicturePixel.Pixel^.G - Change, 0);
     
    15441574  end;
    15451575  Bitmap.EndUpdate;
     1576end;
     1577
     1578function ScaleToNative(Value: Integer): Integer;
     1579begin
     1580  Result := Value;
     1581end;
     1582
     1583function ScaleFromNative(Value: Integer): Integer;
     1584begin
     1585  Result := Value;
    15461586end;
    15471587
  • trunk/Start.pas

    r238 r245  
    355355  Bitmap.BeginUpdate;
    356356  MiniPixel := PixelPointer(Bitmap);
    357   for y := 0 to Size.Y - 1 do begin
    358     for x := 0 to Size.X - 1 do begin
     357  for y := 0 to ScaleToNative(Size.Y) - 1 do begin
     358    for x := 0 to ScaleToNative(Size.X) - 1 do begin
    359359      for i := 0 to 1 do begin
    360         xm := (x * 2 + i + y and 1) mod (Size.X * 2);
     360        xm := (x * 2 + i + y and 1) mod (ScaleToNative(Size.X) * 2);
    361361        MiniPixel.SetX(xm);
    362362        cm := Colors
    363           [Map[x * lxmax div Size.X + lxmax *
    364           ((y * (lymax - 1) + Size.Y div 2) div (Size.Y - 1))] and
     363          [Map[ScaleFromNative(x) * lxmax div Size.X + lxmax *
     364          ((ScaleFromNative(y) * (lymax - 1) + Size.Y div 2) div (Size.Y - 1))] and
    365365          fTerrain, i];
    366366        MiniPixel.Pixel^.B := ((cm shr 16) and $FF) * Brightness div 3;
     
    388388    MiniPixel := PixelPointer(Bitmap);
    389389    PrevMiniPixel := PixelPointer(Bitmap, 0, -1);
    390     for y := 0 to Size.Y - 1 do begin
    391       for x := 0 to Size.X - 1 do begin
     390    for y := 0 to ScaleToNative(Size.Y) - 1 do begin
     391      for x := 0 to ScaleToNative(Size.X) - 1 do begin
    392392        for i := 0 to 1 do begin
    393           xm := (x * 2 + i + y and 1) mod (Size.X * 2);
     393          xm := (x * 2 + i + y and 1) mod (ScaleToNative(Size.X) * 2);
    394394          MiniPixel.SetX(xm);
    395           Tile := SaveMap[x + Size.X * y];
     395          Tile := SaveMap[ScaleFromNative(x) + Size.X * ScaleFromNative(y)];
    396396          if Tile and fTerrain = fUNKNOWN then
    397397            cm := $000000
Note: See TracChangeset for help on using the changeset viewer.