- Timestamp:
- May 21, 2020, 7:58:42 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LocalPlayer/Help.pas
r206 r245 441 441 const 442 442 nHeaven = 28; 443 maxsum = 9 * 9 * 255 * 75 div 100;443 MaxSum = 9 * 9 * 255 * 75 div 100; 444 444 var 445 445 x, y, dx, dy, xSrc, ySrc, sum, xx: integer; … … 457 457 xSrc := iix mod 7 * xSizeBig; 458 458 ySrc := (iix div 7 + 1) * ySizeBig; 459 for y := 0 to ySizeBig* 2 - 1 do460 if (( y0 + y) >= 0) and ((y0 + y) < InnerHeight) then begin461 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); 463 463 for dy := -1 to 1 do 464 if ((Max(y + dy, 0) shr 1) >= 0) and ((Max(y + dy, 0) shr 1) < ySizeBig) then465 ImpPtr[dy] := PixelPointer(BigImp, 0, ySrc + (Max(y + dy, 0) shr 1));466 for x := 0 to xSizeBig* 2 - 1 do begin464 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 467 467 sum := 0; 468 468 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; 470 470 for dy := -1 to 1 do begin 471 471 ImpPtr[dy].SetX(xx); 472 if ((y + dy) shr 1 < 0) or ((y + dy) shr 1 >= ySizeBig) or473 ((x + dx) shr 1 < 0) or ((x + dx) shr 1 >= xSizeBig) or474 ((y + dy) shr 1 < nHeaven) and472 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 475 475 (ImpPtr[dy].Pixel^.B shl 16 + ImpPtr[dy].Pixel^.G shl 8 + 476 ImpPtr[dy].Pixel^.R = Heaven[( y+ dy) shr 1]) then476 ImpPtr[dy].Pixel^.R = Heaven[(ScaleFromNative(y) + dy) shr 1]) then 477 477 sum := sum + 9 * 255 478 478 else … … 481 481 end; 482 482 end; 483 if sum < maxsum then begin // no saturation484 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); 486 486 PaintPtr.SetX(x0 + x); 487 487 PaintPtr.Pixel^.B := PaintPtr.Pixel^.B * sum shr 22; -
trunk/LocalPlayer/IsoEngine.pas
r206 r245 34 34 function IsShoreTile(Loc: integer): boolean; 35 35 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); 37 37 protected 38 38 FOutput: TBitmap; … … 1015 1015 1 + 8 * (xxt * 2 + 1), 1 + yyt + 16 * (yyt * 3 + 1)); 1016 1016 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 1021 1020 if PixelPtr.Pixel^.B = 99 then begin 1022 1021 PixelPtr.Pixel^.B := Tribe[p1].Color shr 16 and $FF; … … 1026 1025 PixelPtr.NextPixel; 1027 1026 end; 1027 PixelPtr.NextLine; 1028 1028 end; 1029 1029 Borders.EndUpdate; … … 1330 1330 end; 1331 1331 1332 procedure TIsoMap.ShadeOutside(x0, y0, x1, y1, xm, ym: integer);1332 procedure TIsoMap.ShadeOutside(x0, y0, Width, Height, xm, ym: integer); 1333 1333 const 1334 1334 rShade = 3.75; … … 1339 1339 begin 1340 1340 FOutput.BeginUpdate; 1341 for y := y0 to y1 - 1 do begin1342 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; 1344 1344 if abs(y_n) < rShade then begin 1345 1345 // Darken left and right parts of elipsis 1346 1346 w_n := sqrt(sqr(rShade) - sqr(y_n)); 1347 1347 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)); 1352 1352 end else begin 1353 1353 // Darken entire line 1354 Line.SetX( x0);1355 MakeDark(@Line, x1 - x0);1354 Line.SetX(0); 1355 MakeDark(@Line, ScaleToNative(Width)); 1356 1356 end; 1357 Line.NextLine; 1357 1358 end; 1358 1359 FOutput.EndUpdate; … … 1576 1577 xm := x + (dx + 1) * xxt; 1577 1578 ym := y + (dy + 1) * yyt + yyt; 1578 ShadeOutside(FLeft, FTop, FRight , FBottom, xm, ym);1579 ShadeOutside(FLeft, FTop, FRight - FLeft, FBottom - FTop, xm, ym); 1579 1580 CityGrid(xm, ym, CityAllowClick); 1580 1581 for dy := -2 to ny + 1 do -
trunk/LocalPlayer/MessgEx.pas
r227 r245 237 237 Screwed: array [0 .. wScrewed - 1, 0 .. hScrewed - 1, 0 .. 3] of single; 238 238 SrcPtr: TPixelPointer; 239 begin 239 Width: Integer; 240 Height: Integer; 241 begin 242 Width := 56; 243 Height := 40; 240 244 if IconIndex >= 0 then begin 241 245 xIcon := IconIndex mod 7 * xSizeBig; 242 246 yIcon := (IconIndex + SystemIconLines * 7) div 7 * ySizeBig; 243 247 // prepare screwed icon 244 fillchar(Screwed, sizeof(Screwed), 0);248 FillChar(Screwed, sizeof(Screwed), 0); 245 249 BigImp.BeginUpdate; 246 for iy := 0 to 39 do begin247 for ix := 0 to 55do begin248 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; 250 254 xDst := Trunc(xR); 251 255 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; 254 258 yDst := Trunc(yR); 255 259 yR := Frac(yR); … … 272 276 Screwed[xDst + dx, yDst + dy, 3] := Screwed[xDst + dx, yDst + dy, 273 277 3] + share; 274 end; 275 end; 278 end; 279 SrcPtr.NextPixel; 280 end; 281 SrcPtr.NextLine; 276 282 end; 277 283 BigImp.EndUpdate; -
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]; -
trunk/LocalPlayer/Wonders.pas
r230 r245 104 104 Ch: Integer; 105 105 Line: array [0..3] of TPixelPointer; 106 begin 106 Width: Integer; 107 Height: Integer; 108 begin 109 Width := ScaleToNative(180); 110 Height := ScaleToNative(128); 107 111 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 127do begin113 for X := 0 to 179do begin114 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) and117 ((r >= 32 * 64 * 90 * 90) and (ax < amax2 * X) and112 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 118 122 ((ax < amax0 * X) or (ax > amin2 * X)) or (ax > amin1 * X) and 119 123 ((ax < amax1 * X) or (ax > amin3 * X))) then begin … … 156 160 x0Src := (i mod 7) * xSizeBig; 157 161 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 begin161 for X := 0 to xSizeBig- 1 do begin162 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 162 166 Darken := ((255 - Src.Pixel^.B) * 3 + (255 - Src.Pixel^.G) * 163 167 15 + (255 - Src.Pixel^.R) * 9) div 128; … … 229 233 ySizeBig + 6, (wMaintexture - ClientWidth) div 2, 230 234 (hMaintexture - ClientHeight) div 2); 231 //DarkIcon(I);235 DarkIcon(I); 232 236 end; 233 237 -2: // destroyed -
trunk/Packages/CevoComponents/ScreenTools.pas
r230 r245 42 42 procedure ImageOp_CBC(Dst, Src: TBitmap; xDst, yDst, xSrc, ySrc, Width, Height, 43 43 Color0, Color2: Integer); 44 procedure ImageOp_CCC(bmp: TBitmap; x, y, w, h, Color0, Color1, Color2: Integer);44 procedure ImageOp_CCC(bmp: TBitmap; x, y, Width, Height, Color0, Color1, Color2: Integer); 45 45 function BitBltCanvas(DestCanvas: TCanvas; X, Y, Width, Height: Integer; 46 46 SrcCanvas: TCanvas; XSrc, YSrc: Integer; Rop: DWORD = SRCCOPY): Boolean; overload; … … 58 58 procedure FrameImage(ca: TCanvas; Src: TBitmap; 59 59 x, y, Width, Height, xSrc, ySrc: integer; IsControl: boolean = False); 60 procedure GlowFrame( dst: TBitmap; x0, y0, Width, Height: integer; cl: TColor);60 procedure GlowFrame(Dst: TBitmap; x0, y0, Width, Height: integer; cl: TColor); 61 61 procedure InitOrnament; 62 62 procedure InitCityMark(const T: TTexture); … … 93 93 procedure Texturize(Dest, Texture: TBitmap; TransparentColor: Integer); 94 94 procedure DarkenImage(Bitmap: TBitmap; Change: Integer); 95 function ScaleToNative(Value: Integer): Integer; 96 function ScaleFromNative(Value: Integer): Integer; 95 97 96 98 const … … 364 366 Bitmap.BeginUpdate; 365 367 PixelPtr := PixelPointer(Bitmap); 366 for Y := 0 to Bitmap.Height- 1 do begin367 for X := 0 to Bitmap.Width- 1 do begin368 for Y := 0 to ScaleToNative(Bitmap.Height) - 1 do begin 369 for X := 0 to ScaleToNative(Bitmap.Width) - 1 do begin 368 370 PixelPtr.Pixel^ := ApplyGammaToPixel(PixelPtr.Pixel^); 369 371 PixelPtr.NextPixel; … … 382 384 SrcPtr := PixelPointer(Src); 383 385 DstPtr := PixelPointer(Dst); 384 for Y := 0 to S rc.Height - 1do begin385 for X := 0 to S rc.Width - 1do begin386 for Y := 0 to ScaleToNative(Src.Height - 1) do begin 387 for X := 0 to ScaleToNative(Src.Width - 1) do begin 386 388 DstPtr.Pixel^.B := SrcPtr.Pixel^.B; 387 389 DstPtr.Pixel^.G := SrcPtr.Pixel^.B; … … 404 406 Path := Path + '.png'; 405 407 if ExtractFileExt(Path) = '.jpg' then begin 406 jtex := tjpegimage.Create;408 jtex := TJpegImage.Create; 407 409 try 408 410 jtex.LoadFromFile(Path); … … 506 508 DataPixel := PixelPointer(GrExt[nGrExt].Data); 507 509 MaskPixel := PixelPointer(GrExt[nGrExt].Mask); 508 for y := 0 to S ource.Height- 1 do begin509 for x := 0 to xmax- 1 do begin510 for y := 0 to ScaleToNative(Source.Height) - 1 do begin 511 for x := 0 to ScaleToNative(xmax) - 1 do begin 510 512 OriginalColor := DataPixel.Pixel^.ARGB and $FFFFFF; 511 513 if (OriginalColor = $FF00FF) or (OriginalColor = $7F007F) then … … 545 547 begin 546 548 Dst.BeginUpdate; 547 PixelPtr := PixelPointer(Dst, X, Y);548 for yy := 0 to Height- 1 do begin549 for xx := 0 to Width- 1 do begin549 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 550 552 PixelPtr.Pixel^.B := PixelPtr.Pixel^.B div 2; 551 553 PixelPtr.Pixel^.G := PixelPtr.Pixel^.G div 2; … … 565 567 begin 566 568 Dst.BeginUpdate; 567 PixelPtr := PixelPointer(Dst, X, Y);568 for YY := 0 to Height- 1 do begin569 for XX := 0 to Width- 1 do begin569 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 570 572 Gray := (Integer(PixelPtr.Pixel^.B) + Integer(PixelPtr.Pixel^.G) + 571 573 Integer(PixelPtr.Pixel^.R)) * 85 shr 8; … … 589 591 PixelDst: TPixelPointer; 590 592 begin 593 xDst := ScaleToNative(xDst); 594 yDst := ScaleToNative(yDst); 595 xSrc := ScaleToNative(xSrc); 596 ySrc := ScaleToNative(ySrc); 597 Width := ScaleToNative(Width); 598 Height := ScaleToNative(Height); 591 599 //Assert(Src.PixelFormat = pf8bit); 592 600 Assert(dst.PixelFormat = pf24bit); … … 601 609 yDst := 0; 602 610 end; 603 if xDst + Width > dst.Widththen604 Width := dst.Width- xDst;605 if yDst + Height > dst.Heightthen606 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; 607 615 if (Width < 0) or (Height < 0) then 608 616 exit; … … 651 659 DstPixel: TPixelPointer; 652 660 begin 661 xDst := ScaleToNative(xDst); 662 yDst := ScaleToNative(yDst); 663 xSrc := ScaleToNative(xSrc); 664 ySrc := ScaleToNative(ySrc); 665 Width := ScaleToNative(Width); 666 Height := ScaleToNative(Height); 653 667 if xDst < 0 then begin 654 668 Width := Width + xDst; … … 661 675 yDst := 0; 662 676 end; 663 if xDst + Width > dst.Widththen664 Width := dst.Width- xDst;665 if yDst + Height > dst.Heightthen666 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; 667 681 if (Width < 0) or (Height < 0) then 668 682 exit; … … 712 726 DstPixel: TPixelPointer; 713 727 begin 728 xDst := ScaleToNative(xDst); 729 yDst := ScaleToNative(yDst); 730 xSrc := ScaleToNative(xSrc); 731 ySrc := ScaleToNative(ySrc); 732 Width := ScaleToNative(Width); 733 Height := ScaleToNative(Height); 714 734 Src.BeginUpdate; 715 735 Dst.BeginUpdate; … … 744 764 end; 745 765 746 procedure ImageOp_CCC(bmp: TBitmap; x, y, w, h, Color0, Color1, Color2: Integer);766 procedure ImageOp_CCC(bmp: TBitmap; x, y, Width, Height, Color0, Color1, Color2: Integer); 747 767 // Bmp is template 748 768 // B channel = Color0 amp, 128=original brightness … … 753 773 PixelPtr: TPixelPointer; 754 774 begin 775 X := ScaleToNative(X); 776 Y := ScaleToNative(Y); 777 Width := ScaleToNative(Width); 778 Height := ScaleToNative(Height); 755 779 bmp.BeginUpdate; 756 780 assert(bmp.PixelFormat = pf24bit); 757 h := y + h;781 Height := y + Height; 758 782 PixelPtr := PixelPointer(Bmp, x, y); 759 while y < hdo begin760 for i := 0 to w- 1 do begin783 while y < Height do begin 784 for i := 0 to Width - 1 do begin 761 785 Red := ((PixelPtr.Pixel^.B * (Color0 and $0000FF) + PixelPtr.Pixel^.G * 762 786 (Color1 and $0000FF) + PixelPtr.Pixel^.R * (Color2 and $0000FF)) shr 8) and $ff; … … 905 929 end; 906 930 907 procedure GlowFrame( dst: TBitmap; x0, y0, Width, Height: Integer; cl: TColor);931 procedure GlowFrame(Dst: TBitmap; x0, y0, Width, Height: Integer; cl: TColor); 908 932 var 909 933 x, y, ch, r: Integer; 910 934 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; 936 begin 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 916 946 if x < 0 then 917 947 if y < 0 then … … 938 968 if r = 0 then 939 969 r := 1; 940 if r < GlowRange then970 if r < DpiGlowRange then 941 971 for ch := 0 to 2 do 942 972 DstPtr.Pixel^.Planes[2 - ch] := 943 973 (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); 945 975 DstPtr.NextPixel; 946 976 end; 947 977 DstPtr.NextLine; 948 978 end; 949 dst.EndUpdate;979 Dst.EndUpdate; 950 980 end; 951 981 … … 1512 1542 DstPixel := PixelPointer(Dest); 1513 1543 SrcPixel := PixelPointer(Texture); 1514 for Y := 0 to Dest.Height- 1 do begin1515 for X := 0 to Dest.Width- 1 do begin1544 for Y := 0 to ScaleToNative(Dest.Height) - 1 do begin 1545 for X := 0 to ScaleToNative(Dest.Width) - 1 do begin 1516 1546 if (DstPixel.Pixel^.ARGB and $FFFFFF) = TransparentColor then begin 1517 1547 SrcPixel.SetXY(X mod TexWidth, Y mod TexHeight); … … 1534 1564 Bitmap.BeginUpdate; 1535 1565 PicturePixel := PixelPointer(Bitmap); 1536 for y := 0 to Bitmap.Height- 1 do begin1537 for x := 0 to Bitmap.Width- 1 do begin1566 for y := 0 to ScaleToNative(Bitmap.Height) - 1 do begin 1567 for x := 0 to ScaleToNative(Bitmap.Width) - 1 do begin 1538 1568 PicturePixel.Pixel^.B := Max(PicturePixel.Pixel^.B - Change, 0); 1539 1569 PicturePixel.Pixel^.G := Max(PicturePixel.Pixel^.G - Change, 0); … … 1544 1574 end; 1545 1575 Bitmap.EndUpdate; 1576 end; 1577 1578 function ScaleToNative(Value: Integer): Integer; 1579 begin 1580 Result := Value; 1581 end; 1582 1583 function ScaleFromNative(Value: Integer): Integer; 1584 begin 1585 Result := Value; 1546 1586 end; 1547 1587 -
trunk/Start.pas
r238 r245 355 355 Bitmap.BeginUpdate; 356 356 MiniPixel := PixelPointer(Bitmap); 357 for y := 0 to S ize.Y- 1 do begin358 for x := 0 to S ize.X- 1 do begin357 for y := 0 to ScaleToNative(Size.Y) - 1 do begin 358 for x := 0 to ScaleToNative(Size.X) - 1 do begin 359 359 for i := 0 to 1 do begin 360 xm := (x * 2 + i + y and 1) mod (S ize.X* 2);360 xm := (x * 2 + i + y and 1) mod (ScaleToNative(Size.X) * 2); 361 361 MiniPixel.SetX(xm); 362 362 cm := Colors 363 [Map[ x* lxmax div Size.X + lxmax *364 (( y* (lymax - 1) + Size.Y div 2) div (Size.Y - 1))] and363 [Map[ScaleFromNative(x) * lxmax div Size.X + lxmax * 364 ((ScaleFromNative(y) * (lymax - 1) + Size.Y div 2) div (Size.Y - 1))] and 365 365 fTerrain, i]; 366 366 MiniPixel.Pixel^.B := ((cm shr 16) and $FF) * Brightness div 3; … … 388 388 MiniPixel := PixelPointer(Bitmap); 389 389 PrevMiniPixel := PixelPointer(Bitmap, 0, -1); 390 for y := 0 to S ize.Y- 1 do begin391 for x := 0 to S ize.X- 1 do begin390 for y := 0 to ScaleToNative(Size.Y) - 1 do begin 391 for x := 0 to ScaleToNative(Size.X) - 1 do begin 392 392 for i := 0 to 1 do begin 393 xm := (x * 2 + i + y and 1) mod (S ize.X* 2);393 xm := (x * 2 + i + y and 1) mod (ScaleToNative(Size.X) * 2); 394 394 MiniPixel.SetX(xm); 395 Tile := SaveMap[ x + Size.X * y];395 Tile := SaveMap[ScaleFromNative(x) + Size.X * ScaleFromNative(y)]; 396 396 if Tile and fTerrain = fUNKNOWN then 397 397 cm := $000000
Note:
See TracChangeset
for help on using the changeset viewer.