Changeset 245 for trunk/LocalPlayer/Term.pas
- Timestamp:
- May 21, 2020, 7:58:42 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LocalPlayer/Term.pas
r227 r245 554 554 Sharpen = 80; 555 555 type 556 TBuffer = array [0 .. 99999, 0 .. 2] of integer;556 TBuffer = array [0 .. 99999, 0 .. 2] of Integer; 557 557 var 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; 561 561 PixelPtr: TPixelPointer; 562 562 begin 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; 565 565 566 566 // 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); 569 569 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; 576 577 if ydivider > ySizeSmall then 577 578 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) * 583 582 ySizeSmall div (ySizeBig - 2 * cut) * nx; 584 xdivider := ( x * xSizeSmall div xSizeBig + 1) * xSizeBig - x*585 xSize Small;583 xdivider := (ScaleFromNative(x) * xSizeSmall div xSizeBig + 1) * 584 xSizeBig - ScaleFromNative(x) * xSizeSmall; 586 585 if xdivider > xSizeSmall then 587 586 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 591 588 c := PixelPtr.Pixel^.Planes[ch]; 592 inc(resampled[ir, ch], c * xdivider * ydivider);589 Inc(Resampled[ir, ch], c * xdivider * ydivider); 593 590 if xdivider < xSizeSmall then 594 inc(resampled[ir + 1, ch], c * (xSizeSmall - xdivider) *591 Inc(Resampled[ir + 1, ch], c * (xSizeSmall - xdivider) * 595 592 ydivider); 596 593 if ydivider < ySizeSmall then 597 inc(resampled[ir + nx, ch],594 Inc(Resampled[ir + nx, ch], 598 595 c * xdivider * (ySizeSmall - ydivider)); 599 596 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) * 601 598 (ySizeSmall - ydivider)); 602 599 end; 600 PixelPtr.NextPixel; 603 601 end; 602 PixelPtr.NextLine; 604 603 end; 604 end; 605 605 BigImp.EndUpdate; 606 606 607 // sharpen resampled icons607 // Sharpen Resampled icons 608 608 SmallImp.SetSize(nx, ny); 609 609 SmallImp.BeginUpdate; 610 for y := 0 to ny - 1 do begin611 PixelPtr := PixelPointer(SmallImp, 0, y);612 for x := 0 to nx - 1 do610 PixelPtr := PixelPointer(SmallImp); 611 for y := 0 to ScaleToNative(ny) - 1 do begin 612 for x := 0 to ScaleToNative(nx) - 1 do begin 613 613 for ch := 0 to 2 do begin 614 sum := 0;614 Sum := 0; 615 615 Cnt := 0; 616 616 for dy := -1 to 1 do 617 if ((dy >= 0) or ( ymod ySizeSmall > 0)) and618 ((dy <= 0) or ( ymod ySizeSmall < ySizeSmall - 1)) then617 if ((dy >= 0) or (ScaleFromNative(y) mod ySizeSmall > 0)) and 618 ((dy <= 0) or (ScaleFromNative(y) mod ySizeSmall < ySizeSmall - 1)) then 619 619 for dx := -1 to 1 do 620 if ((dx >= 0) or ( xmod xSizeSmall > 0)) and621 ((dx <= 0) or ( xmod xSizeSmall < xSizeSmall - 1)) then620 if ((dx >= 0) or (ScaleFromNative(x) mod xSizeSmall > 0)) and 621 ((dx <= 0) or (ScaleFromNative(x) mod xSizeSmall < xSizeSmall - 1)) then 622 622 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); 625 625 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 * 627 627 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; 632 631 end; 632 PixelPtr.NextPixel; 633 end; 634 PixelPtr.NextLine; 633 635 end; 634 636 SmallImp.EndUpdate; 635 FreeMem( resampled);637 FreeMem(Resampled); 636 638 end; 637 639 … … 4066 4068 MiniPixel := PixelPointer(Mini); 4067 4069 PrevMiniPixel := PixelPointer(Mini); 4068 for y := 0 to G.ly- 1 do4069 begin 4070 for x := 0 to G.lx- 1 do4071 if MyMap[ x + G.lx * y] and fTerrain <> fUNKNOWN then4072 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); 4074 4076 for i := 0 to 1 do 4075 4077 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); 4077 4080 MiniPixel.SetXY(xm, y); 4078 4081 cm := MiniColors[MyMap[Loc] and fTerrain, i];
Note:
See TracChangeset
for help on using the changeset viewer.