Ignore:
Timestamp:
Dec 6, 2023, 11:05:10 PM (5 months ago)
Author:
chronos
Message:
  • Fixed: Bitmap processing out of range error.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/Term.pas

    r475 r480  
    719719  TBuffer = array [0 .. 99999, 0 .. 2] of Integer;
    720720var
    721   Sum, Cnt, dx, dy, nx, ny, ix, iy, ir, X, Y, C, ch: Integer;
     721  Sum: Int64;
     722  Cnt, dx, dy, nx, ny, ix, iy, ir, X, Y, C, ch: Integer;
    722723  xdivider, ydivider: Integer;
    723724  Resampled: ^TBuffer;
    724725  PixelPtr: TPixelPointer;
     726  V: Integer;
    725727begin
    726728  nx := BigImp.Width div xSizeBig * xSizeSmall;
     
    784786                ((dx <= 0) or (ScaleFromNative(X) mod xSizeSmall < xSizeSmall - 1)) then
    785787              begin
    786                 Inc(Sum, Resampled[ScaleFromNative(X) + dx + nx * (ScaleFromNative(Y) + dy), ch]);
     788                V := Resampled[ScaleFromNative(X) + dx + nx * (ScaleFromNative(Y) + dy), ch];
     789                Inc(Sum, V);
    787790                Inc(Cnt);
    788791              end;
    789         Sum := ((Cnt * Sharpen + 800) * Resampled[ScaleFromNative(X) + nx * ScaleFromNative(Y), ch] - Sum *
    790           Sharpen) div (800 * xSizeBig * (ySizeBig - 2 * Cut));
     792        V := Resampled[ScaleFromNative(X) + nx * ScaleFromNative(Y), ch];
     793        Sum := ((Cnt * Sharpen + 800) * V - Sum * Sharpen)
     794          div (800 * xSizeBig * (ySizeBig - 2 * Cut));
     795        Sum := Round(Sum / ScaleToNative(ScaleToNative(1)));
    791796        if Sum < 0 then Sum := 0;
    792797        if Sum > 255 then Sum := 255;
Note: See TracChangeset for help on using the changeset viewer.