Changeset 68
- Timestamp:
- Jan 14, 2017, 8:42:46 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LocalPlayer/Help.pas
r55 r68 960 960 inc(p) 961 961 until (p > length(s)) or (s[p] = '\'); 962 if LoadLocalizedGraphicFile(ExtPic, 'Help' + DirectorySeparator + copy(s, 2, p - 2)) then 962 if LoadGraphicFile(ExtPic, LocalizedFilePath('Help' + 963 DirectorySeparator + copy(s, 2, p - 2))) then 963 964 begin 964 965 MainText.AddLine('', pkExternal); -
trunk/LocalPlayer/IsoEngine.pas
r58 r68 104 104 105 105 function ApplyTileSize(xxtNew, yytNew: integer): boolean; 106 type107 TLine = array [0 .. INFIN, 0 .. 2] of Byte;108 106 var 109 107 i, x, y, xSrc, ySrc, HGrTerrainNew, HGrCitiesNew, age, size: integer; 110 108 LandMore, OceanMore, DitherMask, Mask24: TBitmap; 111 MaskLine: array [0 .. 32 * 3 - 1] of ^TLine; // 32 = assumed maximum for yyt109 MaskLine: array [0 .. 32 * 3 - 1] of TPixelPointer; // 32 = assumed maximum for yyt 112 110 Border: boolean; 113 111 begin … … 346 344 begin 347 345 for i := 0 to yyt * 3 - 1 do 348 MaskLine[i] := Mask24.ScanLine[1 + ySrc * (yyt * 3 + 1) + i];346 MaskLine[i].Init(Mask24, 0, 1 + ySrc * (yyt * 3 + 1) + i); 349 347 for xSrc := 0 to 9 - 1 do 350 348 begin … … 353 351 repeat 354 352 Border := true; 355 for y := 0 to yyt * 3 - 1 do 356 if MaskLine[y]^[1 + xSrc * (xxt * 2 + 1) + TSpriteSize[i].Left, 0] = 0 357 then 358 Border := false; 359 if Border then 360 inc(TSpriteSize[i].Left); 353 for y := 0 to yyt * 3 - 1 do begin 354 MaskLine[y].SetX(1 + xSrc * (xxt * 2 + 1) + TSpriteSize[i].Left); 355 if MaskLine[y].Pixel^.B = 0 then Border := false; 356 end; 357 if Border then Inc(TSpriteSize[i].Left); 361 358 until not Border or (TSpriteSize[i].Left = xxt * 2 - 1); 362 359 TSpriteSize[i].Top := 0; 363 360 repeat 364 361 Border := true; 365 for x := 0 to xxt * 2 - 1 do 366 if MaskLine[TSpriteSize[i].Top]^[1 + xSrc * (xxt * 2 + 1) + x, 0] = 0 367 then 368 Border := false; 369 if Border then 370 inc(TSpriteSize[i].Top); 362 for x := 0 to xxt * 2 - 1 do begin 363 MaskLine[TSpriteSize[i].Top].SetX(1 + xSrc * (xxt * 2 + 1) + x); 364 if MaskLine[TSpriteSize[i].Top].Pixel^.B = 0 then Border := false; 365 end; 366 if Border then inc(TSpriteSize[i].Top); 371 367 until not Border or (TSpriteSize[i].Top = yyt * 3 - 1); 372 368 TSpriteSize[i].Right := xxt * 2; 373 369 repeat 374 370 Border := true; 375 for y := 0 to yyt * 3 - 1 do 376 if MaskLine[y]^[xSrc * (xxt * 2 + 1) + TSpriteSize[i].Right, 0] = 0 377 then 378 Border := false; 379 if Border then 380 dec(TSpriteSize[i].Right); 371 for y := 0 to yyt * 3 - 1 do begin 372 MaskLine[y].SetX(xSrc * (xxt * 2 + 1) + TSpriteSize[i].Right); 373 if MaskLine[y].Pixel^.B = 0 then Border := false; 374 end; 375 if Border then Dec(TSpriteSize[i].Right); 381 376 until not Border or (TSpriteSize[i].Right = TSpriteSize[i].Left); 382 377 TSpriteSize[i].Bottom := yyt * 3; 383 378 repeat 384 379 Border := true; 385 for x := 0 to xxt * 2 - 1 do 386 if MaskLine[TSpriteSize[i].Bottom - 1]^[1 + xSrc * (xxt * 2 + 1) + x, 387 0] = 0 then 388 Border := false; 389 if Border then 390 dec(TSpriteSize[i].Bottom); 380 for x := 0 to xxt * 2 - 1 do begin 381 MaskLine[TSpriteSize[i].Bottom - 1].SetX(1 + xSrc * (xxt * 2 + 1) + x); 382 if MaskLine[TSpriteSize[i].Bottom - 1].Pixel^.B = 0 then Border := false; 383 end; 384 if Border then Dec(TSpriteSize[i].Bottom); 391 385 until not Border or (TSpriteSize[i].Bottom = TSpriteSize[i].Top); 392 386 end … … 930 924 procedure TIsoMap.PaintTileObjects(x, y, Loc, CityLoc, CityOwner: integer; 931 925 UseBlink: boolean); 932 type933 TLine = array [0 .. 9 * 65, 0 .. 2] of Byte;934 926 var 935 927 p1, p2, uix, cix, dy, Loc1, Tile, Multi, Destination: integer; … … 1299 1291 1300 1292 procedure ShadeOutside(x0, y0, x1, y1, xm, ym: integer); 1293 1294 procedure MakeDark(Line: PPixelPointer; Length: Integer); 1295 var 1296 I: Integer; 1297 begin 1298 for I := 0 to Length - 1 do begin 1299 Line^.Pixel^.B := (Line^.Pixel^.B shr 1) and $7f; 1300 Line^.Pixel^.G := (Line^.Pixel^.G shr 1) and $7f; 1301 Line^.Pixel^.R := (Line^.Pixel^.R shr 1) and $7f; 1302 Line^.NextPixel; 1303 end; 1304 end; 1305 1301 1306 const 1302 1307 rShade = 3.75; 1303 1304 procedure MakeDark(Line: pointer; length: integer);1305 type1306 TCardArray = array [0 .. 9999] of Cardinal;1307 PCardArray = ^TCardArray;1308 TByteArray = array [0 .. 9999] of Byte;1309 PByteArray = ^TByteArray;1310 var1311 i, rest: integer;1312 begin1313 for i := length * 3 div 4 - 1 downto 0 do1314 PCardArray(Line)[i] := PCardArray(Line)[i] shr 1 and $7F7F7F7F;1315 rest := (length * 3 div 4) * 4;1316 for i := length * 3 mod 4 - 1 downto 0 do1317 PByteArray(Line)[rest + i] := PByteArray(Line)[rest + i] shr 1 and $7F;1318 end;1319 1320 type1321 TLine = array [0 .. 99999, 0 .. 2] of Byte;1322 1308 var 1323 1309 y, wBright: integer; 1324 1310 y_n, w_n: single; 1325 Line: ^TLine;1311 Line: TPixelPointer; 1326 1312 begin 1327 1313 FOutput.BeginUpdate; 1328 for y := y0 to y1 - 1 do 1329 begin 1330 Line := FOutput.ScanLine[y]; 1314 for y := y0 to y1 - 1 do begin 1315 Line.Init(FOutput, 0, y); 1331 1316 y_n := (y - ym) / yyt; 1332 if abs(y_n) < rShade then 1333 begin1317 if abs(y_n) < rShade then begin 1318 // Darken left and right parts of elipsis 1334 1319 w_n := sqrt(sqr(rShade) - sqr(y_n)); 1335 1320 wBright := trunc(w_n * xxt + 0.5); 1336 MakeDark(@Line[x0], xm - x0 - wBright); 1337 MakeDark(@Line[xm + wBright], x1 - xm - wBright); 1338 end 1339 else 1340 MakeDark(@Line[x0], x1 - x0); 1321 Line.SetX(x0); 1322 MakeDark(@Line, xm - x0 - wBright); 1323 Line.SetX(xm + wBright); 1324 MakeDark(@Line, x1 - xm - wBright); 1325 end else begin 1326 // Darken entire line 1327 Line.SetX(x0); 1328 MakeDark(@Line, x1 - x0); 1329 end; 1341 1330 end; 1342 1331 FOutput.EndUpdate; -
trunk/ScreenTools.pas
r64 r68 43 43 procedure Init(Bitmap: TBitmap; X: Integer = 0; Y: Integer = 0); inline; 44 44 end; 45 PPixelPointer = ^TPixelPointer; 45 46 46 47 {$IFDEF WINDOWS} … … 59 60 function HexStringToColor(s: string): integer; 60 61 function LoadGraphicFile(bmp: TBitmap; Path: string; 61 Options: integer = 0): boolean;62 function LoadLocalizedGraphicFile(bmp: TBitmap; Path: string;63 62 Options: integer = 0): boolean; 64 63 function LoadGraphicSet(Name: string): integer; … … 417 416 end; 418 417 419 procedure ApplyGamma(Start, Stop: pbyte);420 begin421 while Start < Stop do422 begin423 Start^ := GammaLUT[Start^];424 inc(Start);425 end;426 end;427 428 418 function LoadGraphicFile(bmp: TBitmap; Path: string; Options: integer): boolean; 429 type 430 TLine = array [0 .. 9999, 0 .. 2] of Byte; 431 var 432 FirstLine, LastLine: ^TLine; 419 var 420 PixelPtr: TPixelPointer; 433 421 jtex: tjpegimage; 422 X, Y: Integer; 434 423 begin 435 424 result := true; … … 474 463 if (Options and gfNoGamma = 0) and (Gamma <> 100) then 475 464 begin 476 bmp.BeginUpdate; 477 FirstLine := bmp.ScanLine[0]; 478 LastLine := bmp.ScanLine[bmp.Height - 1]; 479 if FirstLine < LastLine then 480 ApplyGamma(pointer(FirstLine), @LastLine[bmp.Width]) 481 else 482 ApplyGamma(pointer(LastLine), @FirstLine[bmp.Width]); 483 bmp.EndUpdate; 484 end 485 end; 486 487 function LoadLocalizedGraphicFile(bmp: TBitmap; Path: string; 488 Options: integer): boolean; 489 type 490 TLine = array [0 .. 9999, 0 .. 2] of Byte; 491 var 492 FirstLine, LastLine: ^TLine; 493 jtex: tjpegimage; 494 begin 495 result := true; 496 if Options and gfJPG <> 0 then 497 begin 498 jtex := tjpegimage.create; 499 try 500 jtex.loadfromfile(LocalizedFilePath(Path + '.jpg')); 501 except 502 result := false; 503 end; 504 if result then 505 begin 506 if Options and gfNoGamma = 0 then 507 bmp.PixelFormat := pf24bit; 508 bmp.Width := jtex.Width; 509 bmp.Height := jtex.Height; 510 bmp.Canvas.draw(0, 0, jtex); 511 end; 512 jtex.Free; 513 end 514 else 515 begin 516 try 517 bmp.loadfromfile(LocalizedFilePath(Path + '.bmp')); 518 except 519 result := false; 520 end; 521 if result then 522 begin 523 if Options and gfNoGamma = 0 then 524 bmp.PixelFormat := pf24bit; 525 end 526 end; 527 if not result then 528 begin 529 if Options and gfNoError = 0 then 530 Application.MessageBox(PChar(Format(Phrases.Lookup('FILENOTFOUND'), 531 [Path])), 'C-evo', 0); 532 exit; 533 end; 534 if (Options and gfNoGamma = 0) and (Gamma <> 100) then 535 begin 536 bmp.BeginUpdate; 537 FirstLine := bmp.ScanLine[0]; 538 LastLine := bmp.ScanLine[bmp.Height - 1]; 539 if FirstLine < LastLine then 540 ApplyGamma(Pointer(FirstLine), @LastLine[bmp.Width]) 541 else 542 ApplyGamma(Pointer(LastLine), @FirstLine[bmp.Width]); 543 bmp.EndUpdate; 465 Bmp.BeginUpdate; 466 PixelPtr.Init(bmp, 0, 0); 467 for Y := 0 to Bmp.Height - 1 do begin 468 for X := 0 to Bmp.Width - 1 do begin 469 PixelPtr.Pixel^.B := GammaLUT[PixelPtr.Pixel^.B]; 470 PixelPtr.Pixel^.G := GammaLUT[PixelPtr.Pixel^.G]; 471 PixelPtr.Pixel^.R := GammaLUT[PixelPtr.Pixel^.R]; 472 PixelPtr.NextPixel; 473 end; 474 PixelPtr.NextLine; 475 end; 476 Bmp.EndUpdate; 544 477 end 545 478 end;
Note:
See TracChangeset
for help on using the changeset viewer.