Changeset 480 for trunk/LocalPlayer


Ignore:
Timestamp:
Dec 6, 2023, 11:05:10 PM (13 months ago)
Author:
chronos
Message:
  • Fixed: Bitmap processing out of range error.
Location:
trunk/LocalPlayer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/MessgEx.pas

    r473 r480  
    264264            else
    265265              share := share * yR;
    266             Screwed[xDst + dx, yDst + dy, 0] := Screwed[xDst + dx, yDst + dy, 0]
    267               + share * SrcPtr.Pixel^.B;
    268             Screwed[xDst + dx, yDst + dy, 1] := Screwed[xDst + dx, yDst + dy, 1]
    269               + share * SrcPtr.Pixel^.G;
    270             Screwed[xDst + dx, yDst + dy, 2] := Screwed[xDst + dx, yDst + dy, 2]
    271               + share * SrcPtr.Pixel^.R;
    272             Screwed[xDst + dx, yDst + dy, 3] := Screwed[xDst + dx, yDst + dy,
    273               3] + share;
     266            if (xDst + dx < ScaleToNative(Width)) and
     267            (yDst + dy < ScaleToNative(Height)) then begin
     268              Screwed[xDst + dx, yDst + dy, 0] := Screwed[xDst + dx, yDst + dy, 0]
     269                + share * SrcPtr.Pixel^.B;
     270              Screwed[xDst + dx, yDst + dy, 1] := Screwed[xDst + dx, yDst + dy, 1]
     271                + share * SrcPtr.Pixel^.G;
     272              Screwed[xDst + dx, yDst + dy, 2] := Screwed[xDst + dx, yDst + dy, 2]
     273                + share * SrcPtr.Pixel^.R;
     274              Screwed[xDst + dx, yDst + dy, 3] := Screwed[xDst + dx, yDst + dy,
     275                3] + share;
     276            end;
    274277        end;
    275278        SrcPtr.NextPixel;
  • 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.