- Timestamp:
- Jan 15, 2017, 4:12:10 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 30 added
- 30 deleted
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Back.pas
r38 r73 39 39 begin 40 40 img := nil; 41 if FullScreen then 42 begin 43 if FileExists(HomeDir + 'Graphics' + DirectorySeparator + 'Background.bmp') or 44 FileExists(HomeDir + 'Graphics' + DirectorySeparator + 'Background.png') then 45 begin 41 if FullScreen then begin 42 if FileExists(HomeDir + 'Graphics' + DirectorySeparator + 'Background.png') then begin 46 43 img := TBitmap.Create; 47 LoadGraphicFile(img, HomeDir + 'Graphics' + DirectorySeparator + 'Background'); 48 end 49 end 50 else 51 begin 44 LoadGraphicFile(img, HomeDir + 'Graphics' + DirectorySeparator + 'Background.png'); 45 end; 46 end else begin 52 47 WindowState := wsNormal; 53 48 Width := StartDlg.Width + 16; … … 55 50 Left := StartDlg.Left - 8; 56 51 Top := StartDlg.Top - 8; 57 end 52 end; 58 53 end; 59 54 … … 75 70 procedure TBackground.FormClose(Sender: TObject; var Action: TCloseAction); 76 71 begin 77 if img <> nil then 78 begin 72 if img <> nil then begin 79 73 img.Free; 80 74 img := nil -
trunk/LocalPlayer/CityScreen.pas
r72 r73 10 10 Protocol, ClientTools, Term, ScreenTools, IsoEngine, BaseWin, 11 11 LCLIntf, LCLType, Messages, SysUtils, Classes, Graphics, Controls, Forms, ExtCtrls, 12 ButtonA, ButtonC, Area ;12 ButtonA, ButtonC, Area, GraphType; 13 13 14 14 const … … 217 217 Back.Canvas.FillRect(0, 0, Back.Width, Back.Height); 218 218 Template := TBitmap.Create; 219 LoadGraphicFile(Template, HomeDir + 'Graphics' + DirectorySeparator + 'City', gfNoGamma);220 Template.PixelFormat := pf8bit;219 Template.PixelFormat := pf24bit; 220 LoadGraphicFile(Template, HomeDir + 'Graphics' + DirectorySeparator + 'City.png', gfNoGamma); 221 221 CityMapTemplate := TBitmap.Create; 222 LoadGraphicFile(CityMapTemplate, HomeDir + 'Graphics' + DirectorySeparator + 'BigCityMap', gfNoGamma);223 CityMapTemplate.PixelFormat := pf8bit;222 CityMapTemplate.PixelFormat := pf24bit; 223 LoadGraphicFile(CityMapTemplate, HomeDir + 'Graphics' + DirectorySeparator + 'BigCityMap.png', gfNoGamma); 224 224 SmallCityMapTemplate := TBitmap.Create; 225 LoadGraphicFile(SmallCityMapTemplate, HomeDir + 'Graphics' + DirectorySeparator + 'SmallCityMap', 225 SmallCityMapTemplate.PixelFormat := pf24bit; 226 LoadGraphicFile(SmallCityMapTemplate, HomeDir + 'Graphics' + DirectorySeparator + 'SmallCityMap.png', 226 227 gfNoGamma); 227 SmallCityMapTemplate.PixelFormat := pf24bit;228 228 SmallCityMap := TBitmap.Create; 229 229 SmallCityMap.PixelFormat := pf24bit; -
trunk/LocalPlayer/Draft.pas
r62 r73 91 91 Back.Canvas.FillRect(0, 0, Back.Width, Back.Height); 92 92 Template := TBitmap.Create; 93 LoadGraphicFile(Template, HomeDir + 'Graphics' + DirectorySeparator + 'MiliRes', gfNoGamma);94 Template.PixelFormat := pf8bit;93 Template.PixelFormat := pf24bit; 94 LoadGraphicFile(Template, HomeDir + 'Graphics' + DirectorySeparator + 'MiliRes.png', gfNoGamma); 95 95 end; 96 96 -
trunk/LocalPlayer/Help.pas
r69 r73 968 968 until (p > length(s)) or (s[p] = '\'); 969 969 if LoadGraphicFile(ExtPic, LocalizedFilePath('Help' + 970 DirectorySeparator + copy(s, 2, p - 2)) ) then970 DirectorySeparator + copy(s, 2, p - 2)) + '.png') then 971 971 begin 972 972 MainText.AddLine('', pkExternal); -
trunk/LocalPlayer/IsoEngine.pas
r68 r73 111 111 begin 112 112 result := false; 113 HGrTerrainNew := LoadGraphicSet(Format('Terrain%dx%d ',113 HGrTerrainNew := LoadGraphicSet(Format('Terrain%dx%d.png', 114 114 [xxtNew * 2, yytNew * 2])); 115 115 if HGrTerrainNew < 0 then 116 116 exit; 117 HGrCitiesNew := LoadGraphicSet(Format('Cities%dx%d ',117 HGrCitiesNew := LoadGraphicSet(Format('Cities%dx%d.png', 118 118 [xxtNew * 2, yytNew * 2])); 119 119 if HGrCitiesNew < 0 then … … 334 334 OceanMore.Free; 335 335 DitherMask.Free; 336 //LandPatch.Savetofile('landpatch.bmp');337 336 338 337 // reduce size of terrain icons -
trunk/LocalPlayer/NatStat.pas
r61 r73 92 92 Back.Canvas.FillRect(0, 0, Back.Width, Back.Height); 93 93 Template := TBitmap.Create; 94 LoadGraphicFile(Template, HomeDir + 'Graphics' + DirectorySeparator + 'Nation', gfNoGamma);95 Template.PixelFormat := pf8bit;94 Template.PixelFormat := pf24bit; 95 LoadGraphicFile(Template, HomeDir + 'Graphics' + DirectorySeparator + 'Nation.png', gfNoGamma); 96 96 end; 97 97 -
trunk/LocalPlayer/TechTree.pas
r72 r73 128 128 begin 129 129 Image := TBitmap.Create; 130 LoadGraphicFile(Image, HomeDir + 'Help' + DirectorySeparator + 'AdvTree', gfNoGamma);131 130 Image.PixelFormat := pf24bit; 131 LoadGraphicFile(Image, HomeDir + 'Help' + DirectorySeparator + 'AdvTree.png', gfNoGamma); 132 132 133 133 with Image.Canvas do -
trunk/LocalPlayer/Term.pas
r72 r73 588 588 SmallImp.EndUpdate; 589 589 FreeMem(resampled); 590 // smallimp.savetofile(homedir+'smallimp.bmp'); //!!!591 590 end; 592 591 … … 674 673 with Tribe[p].ModelPicture[mix] do 675 674 begin 676 HGr := LoadGraphicSet(Picture.GrName );675 HGr := LoadGraphicSet(Picture.GrName + '.png'); 677 676 pix := Picture.pix; 678 677 end; … … 1203 1202 if AILogo[p] = nil then 1204 1203 AILogo[p] := TBitmap.Create; 1205 if not LoadGraphicFile(AILogo[p], HomeDir + Name , gfNoError) then1204 if not LoadGraphicFile(AILogo[p], HomeDir + Name + '.png', gfNoError) then 1206 1205 begin 1207 1206 AILogo[p].free; … … 1467 1466 MainMap.SetOutput(offscreen); 1468 1467 1469 HGrStdUnits := LoadGraphicSet('StdUnits ');1468 HGrStdUnits := LoadGraphicSet('StdUnits.png'); 1470 1469 SmallImp := TBitmap.Create; 1471 1470 SmallImp.PixelFormat := pf24bit; -
trunk/LocalPlayer/Tribes.pas
r38 r73 301 301 Item := Get; 302 302 sympix := GetNum; 303 symHGr := LoadGraphicSet(Item );303 symHGr := LoadGraphicSet(Item + '.png'); 304 304 end 305 305 end; … … 425 425 end 426 426 end; 427 cHGr := LoadGraphicSet(Item );427 cHGr := LoadGraphicSet(Item + '.png'); 428 428 for x := 0 to 3 do 429 429 with CityPicture[x] do … … 445 445 else 446 446 begin 447 faceHGr := LoadGraphicSet(Item );447 faceHGr := LoadGraphicSet(Item + '.png'); 448 448 facepix := GetNum; 449 449 if GrExt[faceHGr].Data.Canvas.Pixels[facepix mod 10 * 65, … … 477 477 dec(i); 478 478 assert(i >= 0); 479 assert(PictureList[i].HGr = LoadGraphicSet(GrName ));479 assert(PictureList[i].HGr = LoadGraphicSet(GrName + '.png')); 480 480 assert(PictureList[i].pix = pix); 481 481 ModelPicture[mix].HGr := PictureList[i].HGr; … … 487 487 with ModelPicture[mix] do 488 488 begin 489 HGr := LoadGraphicSet(GrName );489 HGr := LoadGraphicSet(GrName + '.png'); 490 490 pix := Info.pix; 491 491 inc(GrExt[HGr].pixUsed[pix]); -
trunk/LocalPlayer/UnitStat.pas
r61 r73 82 82 Back.Canvas.FillRect(0, 0, Back.Width,Back.Height); 83 83 Template := TBitmap.Create; 84 LoadGraphicFile(Template, HomeDir + 'Graphics' + DirectorySeparator + 'Unit', gfNoGamma);85 Template.PixelFormat := pf8bit;84 Template.PixelFormat := pf24bit; 85 LoadGraphicFile(Template, HomeDir + 'Graphics' + DirectorySeparator + 'Unit.png', gfNoGamma); 86 86 end; 87 87 -
trunk/ScreenTools.pas
r72 r73 9 9 {$ENDIF} 10 10 StringTables, LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, 11 Forms, Menus ;11 Forms, Menus, GraphType; 12 12 13 13 type … … 42 42 procedure SetXY(X, Y: Integer); inline; // Set pixel position relative to base 43 43 procedure SetX(X: Integer); inline; // Set horizontal pixel position relative to base 44 procedure Init(Bitmap: T Bitmap; BaseX: Integer = 0; BaseY: Integer = 0); inline;44 procedure Init(Bitmap: TRasterImage; BaseX: Integer = 0; BaseY: Integer = 0); inline; 45 45 end; 46 46 PPixelPointer = ^TPixelPointer; … … 188 188 gfNoError = $01; 189 189 gfNoGamma = $02; 190 gfJPG = $04;191 190 192 191 type … … 411 410 end; 412 411 412 procedure ApplyGammaToBitmap(Bitmap: TBitmap); 413 var 414 PixelPtr: TPixelPointer; 415 X, Y: Integer; 416 begin 417 Bitmap.BeginUpdate; 418 PixelPtr.Init(Bitmap); 419 for Y := 0 to Bitmap.Height - 1 do begin 420 for X := 0 to Bitmap.Width - 1 do begin 421 PixelPtr.Pixel^.B := GammaLUT[PixelPtr.Pixel^.B]; 422 PixelPtr.Pixel^.G := GammaLUT[PixelPtr.Pixel^.G]; 423 PixelPtr.Pixel^.R := GammaLUT[PixelPtr.Pixel^.R]; 424 PixelPtr.NextPixel; 425 end; 426 PixelPtr.NextLine; 427 end; 428 Bitmap.EndUpdate; 429 end; 430 431 procedure CopyGray8BitTo24bitBitmap(Dst, Src: TRasterImage); 432 var 433 SrcPtr, DstPtr: TPixelPointer; 434 X, Y: Integer; 435 begin 436 //Dst.SetSize(Src.Width, Src.Height); 437 SrcPtr.Init(Src); 438 DstPtr.Init(Dst); 439 for Y := 0 to Src.Height - 1 do begin 440 for X := 0 to Src.Width - 1 do begin 441 DstPtr.Pixel^.B := SrcPtr.Pixel^.B; 442 DstPtr.Pixel^.G := SrcPtr.Pixel^.B; 443 DstPtr.Pixel^.R := SrcPtr.Pixel^.B; 444 SrcPtr.NextPixel; 445 DstPtr.NextPixel; 446 end; 447 SrcPtr.NextLine; 448 DstPtr.NextLine; 449 end; 450 end; 451 413 452 function LoadGraphicFile(bmp: TBitmap; Path: string; Options: integer): boolean; 414 453 var 415 PixelPtr: TPixelPointer;416 454 jtex: tjpegimage; 417 X, Y: Integer; 418 begin 419 result := true; 420 if Options and gfJPG <> 0 then 421 begin 455 Png: TPortableNetworkGraphic; 456 begin 457 Result := True; 458 if ExtractFileExt(Path) = '.jpg' then begin 422 459 jtex := tjpegimage.create; 423 460 try 424 jtex. loadfromfile(Path + '.jpg');461 jtex.LoadFromFile(Path); 425 462 except 426 result := false; 427 end; 428 if result then 429 begin 430 if Options and gfNoGamma = 0 then 431 bmp.PixelFormat := pf24bit; 432 bmp.Width := jtex.Width; 433 bmp.Height := jtex.Height; 434 bmp.Canvas.draw(0, 0, jtex); 463 Result := False; 464 end; 465 if result then begin 466 if Options and gfNoGamma = 0 then bmp.PixelFormat := pf24bit; 467 Bmp.SetSize(jtex.Width, jtex.Height); 468 Bmp.Canvas.Draw(0, 0, jtex); 435 469 end; 436 470 jtex.Free; 437 end 438 else 439 begin 471 end else 472 if ExtractFileExt(Path) = '.png' then begin 473 Png := TPortableNetworkGraphic.Create; 474 Png.PixelFormat := Bmp.PixelFormat; 440 475 try 441 bmp.loadfromfile(Path + '.bmp');476 Png.LoadFromFile(Path); 442 477 except 443 result := false; 444 end; 445 if result then 446 begin 478 Result := False; 479 end; 480 if Result then begin 481 if Options and gfNoGamma = 0 then bmp.PixelFormat := pf24bit; 482 bmp.SetSize(Png.Width, Png.Height); 483 if (Png.RawImage.Description.Format = ricfGray) then begin 484 // LCL doesn't support 8-bit colors properly. Use 24-bit instead. 485 Bmp.PixelFormat := pf24bit; 486 CopyGray8BitTo24bitBitmap(Bmp, Png) 487 end else Bmp.Canvas.draw(0, 0, Png); 488 end; 489 Png.Free; 490 end else 491 if ExtractFileExt(Path) = '.bmp' then begin 492 try 493 bmp.LoadFromFile(Path); 494 except 495 Result := False; 496 end; 497 if Result then begin 447 498 if Options and gfNoGamma = 0 then 448 499 bmp.PixelFormat := pf24bit; 449 500 end 450 end; 451 if not result then 452 begin 501 end else 502 raise Exception.Create('Unsupported image file type ' + ExtractFileExt(Path)); 503 504 if not Result then begin 453 505 if Options and gfNoError = 0 then 454 506 Application.MessageBox(PChar(Format(Phrases.Lookup('FILENOTFOUND'), 455 507 [Path])), 'C-evo', 0); 456 exit; 457 end; 508 Exit; 509 end; 510 458 511 if (Options and gfNoGamma = 0) and (Gamma <> 100) then 459 begin 460 Bmp.BeginUpdate; 461 PixelPtr.Init(bmp); 462 for Y := 0 to Bmp.Height - 1 do begin 463 for X := 0 to Bmp.Width - 1 do begin 464 PixelPtr.Pixel^.B := GammaLUT[PixelPtr.Pixel^.B]; 465 PixelPtr.Pixel^.G := GammaLUT[PixelPtr.Pixel^.G]; 466 PixelPtr.Pixel^.R := GammaLUT[PixelPtr.Pixel^.R]; 467 PixelPtr.NextPixel; 468 end; 469 PixelPtr.NextLine; 470 end; 471 Bmp.EndUpdate; 472 end 512 ApplyGammaToBitmap(Bmp); 473 513 end; 474 514 … … 484 524 inc(i); 485 525 result := i; 486 if i = nGrExt then 487 begin 488 FileName := HomeDir + 'Graphics' + DirectorySeparator + Name + '.bmp'; 526 if i = nGrExt then begin 489 527 Source := TBitmap.Create; 490 try491 Source.LoadFromFile(FileName)492 except528 Source.PixelFormat := pf24bit; 529 FileName := HomeDir + 'Graphics' + DirectorySeparator + Name; 530 if not LoadGraphicFile(Source, FileName) then begin 493 531 Result := -1; 494 Application.MessageBox(PChar(Format(Phrases.Lookup('FILENOTFOUND'), 495 [FileName])), 'C-evo', 0); 496 exit; 532 Exit; 497 533 end; 498 534 … … 501 537 502 538 xmax := Source.Width - 1; // allows 4-byte access even for last pixel 503 if xmax > 970 then 504 xmax := 970; 539 if xmax > 970 then xmax := 970; 505 540 506 541 GrExt[nGrExt].Data := Source; … … 1396 1431 MainTextureAge := Age; 1397 1432 LoadGraphicFile(Image, HomeDir + 'Graphics' + DirectorySeparator + 'Texture' + 1398 IntToStr(Age + 1) , gfJPG);1433 IntToStr(Age + 1) + '.jpg'); 1399 1434 clBevelLight := Colors.Canvas.Pixels[clkAge0 + Age, cliBevelLight]; 1400 1435 clBevelShade := Colors.Canvas.Pixels[clkAge0 + Age, cliBevelShade]; … … 1442 1477 end; 1443 1478 1444 procedure TPixelPointer.Init(Bitmap: T Bitmap; BaseX: Integer = 0; BaseY: Integer = 0); inline;1479 procedure TPixelPointer.Init(Bitmap: TRasterImage; BaseX: Integer = 0; BaseY: Integer = 0); inline; 1445 1480 begin 1446 1481 BytesPerLine := Bitmap.RawImage.Description.BytesPerLine; … … 1571 1606 1572 1607 nGrExt := 0; 1573 HGrSystem := LoadGraphicSet('System'); 1574 HGrSystem2 := LoadGraphicSet('System2'); 1575 Templates := TBitmap.create; 1576 LoadGraphicFile(Templates, HomeDir + 'Graphics' + DirectorySeparator + 'Templates', gfNoGamma); 1608 HGrSystem := LoadGraphicSet('System.png'); 1609 HGrSystem2 := LoadGraphicSet('System2.png'); 1610 Templates := TBitmap.Create; 1577 1611 Templates.PixelFormat := pf24bit; 1578 Colors := TBitmap.create; 1579 LoadGraphicFile(Colors, HomeDir + 'Graphics' + DirectorySeparator + 'Colors'); 1580 Paper := TBitmap.create; 1581 LoadGraphicFile(Paper, HomeDir + 'Graphics' + DirectorySeparator + 'Paper', gfJPG); 1582 BigImp := TBitmap.create; 1583 LoadGraphicFile(BigImp, HomeDir + 'Graphics' + DirectorySeparator + 'Icons'); 1584 MainTexture.Image := TBitmap.create; 1612 LoadGraphicFile(Templates, HomeDir + 'Graphics' + DirectorySeparator + 'Templates.png', gfNoGamma); 1613 Colors := TBitmap.Create; 1614 Colors.PixelFormat := pf24bit; 1615 LoadGraphicFile(Colors, HomeDir + 'Graphics' + DirectorySeparator + 'Colors.png'); 1616 Paper := TBitmap.Create; 1617 Paper.PixelFormat := pf24bit; 1618 LoadGraphicFile(Paper, HomeDir + 'Graphics' + DirectorySeparator + 'Paper.jpg'); 1619 BigImp := TBitmap.Create; 1620 BigImp.PixelFormat := pf24bit; 1621 LoadGraphicFile(BigImp, HomeDir + 'Graphics' + DirectorySeparator + 'Icons.png'); 1622 MainTexture.Image := TBitmap.Create; 1585 1623 MainTextureAge := -2; 1586 1624 ClickFrameColor := GrExt[HGrSystem].Data.Canvas.Pixels[187, 175]; 1587 InitOrnamentDone := false;1588 GenerateNames := true;1625 InitOrnamentDone := False; 1626 GenerateNames := True; 1589 1627 end; 1590 1628 -
trunk/Start.pas
r72 r73 330 330 331 331 BrainPicture[0] := TBitmap.Create; 332 BrainPicture[0].width := 64; 333 BrainPicture[0].height := 64; 332 BrainPicture[0].SetSize(64, 64); 334 333 BitBlt(BrainPicture[0].Canvas.Handle, 0, 0, 64, 64, 335 334 GrExt[HGrSystem2].Data.Canvas.Handle, 1, 111, SRCCOPY); 336 335 BrainPicture[1] := TBitmap.Create; 337 BrainPicture[1].width := 64; 338 BrainPicture[1].height := 64; 336 BrainPicture[1].SetSize(64, 64); 339 337 BitBlt(BrainPicture[1].Canvas.Handle, 0, 0, 64, 64, 340 338 GrExt[HGrSystem2].Data.Canvas.Handle, 66, 111, SRCCOPY); 341 339 BrainPicture[2] := TBitmap.Create; 342 BrainPicture[2].width := 64; 343 BrainPicture[2].height := 64; 340 BrainPicture[2].SetSize(64, 64); 344 341 BitBlt(BrainPicture[2].Canvas.Handle, 0, 0, 64, 64, 345 342 GrExt[HGrSystem2].Data.Canvas.Handle, 131, 111, SRCCOPY); 346 343 BrainPicture[3] := TBitmap.Create; 347 BrainPicture[3].width := 64; 348 BrainPicture[3].height := 64; 344 BrainPicture[3].SetSize(64, 64); 349 345 BitBlt(BrainPicture[3].Canvas.Handle, 0, 0, 64, 64, 350 346 GrExt[HGrSystem2].Data.Canvas.Handle, 131, 46, SRCCOPY); 351 for i := bixFirstAI to nBrain - 1 do 352 begin 347 for i := bixFirstAI to nBrain - 1 do begin 353 348 BrainPicture[i] := TBitmap.Create; 354 if not LoadGraphicFile(BrainPicture[i], HomeDir + 'AI' + DirectorySeparator + Brain[i].FileName, 355 gfNoError) then 356 begin 349 if not LoadGraphicFile(BrainPicture[i], HomeDir + 'AI' + DirectorySeparator + Brain[i].FileName + '.png', 350 gfNoError) then begin 357 351 BrainPicture[i].width := 64; 358 352 BrainPicture[i].height := 64; 359 with BrainPicture[i].Canvas do 360 begin 353 with BrainPicture[i].Canvas do begin 361 354 Brush.Color := $904830; 362 355 FillRect(Rect(0, 0, 64, 64)); … … 366 359 Textout(32 - TextWidth(Brain[i].FileName) div 2, 367 360 32 - TextHeight(Brain[i].FileName) div 2, Brain[i].FileName); 368 end 369 end 361 end; 362 end; 370 363 end; 371 364 … … 1168 1161 MapFileName := List.Items[List.ItemIndex] + '.cevo map'; 1169 1162 if LoadGraphicFile(Mini, DataDir + 'Maps' + DirectorySeparator + Copy(MapFileName, 1, 1170 Length(MapFileName) - 9) , gfNoError) then1163 Length(MapFileName) - 9) + '.png', gfNoError) then 1171 1164 begin 1172 1165 if Mini.width div 2 > MaxWidthMapLogo then … … 1765 1758 try // rename map picture 1766 1759 AssignFile(f, DataDir + 'Maps'+ DirectorySeparator + List.Items[List.ItemIndex] 1767 + '. bmp');1768 Rename(f, DataDir + 'Maps'+ DirectorySeparator + NewName + '. bmp');1760 + '.png'); 1761 Rename(f, DataDir + 'Maps'+ DirectorySeparator + NewName + '.png'); 1769 1762 except 1770 1763 end;
Note:
See TracChangeset
for help on using the changeset viewer.