Changeset 73 for trunk


Ignore:
Timestamp:
Jan 15, 2017, 4:12:10 PM (8 years ago)
Author:
chronos
Message:
  • Modified: All graphics images converted from BMP to PNG.
Location:
trunk
Files:
30 added
30 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Back.pas

    r38 r73  
    3939begin
    4040  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
    4643      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
    5247    WindowState := wsNormal;
    5348    Width := StartDlg.Width + 16;
     
    5550    Left := StartDlg.Left - 8;
    5651    Top := StartDlg.Top - 8;
    57   end
     52  end;
    5853end;
    5954
     
    7570procedure TBackground.FormClose(Sender: TObject; var Action: TCloseAction);
    7671begin
    77   if img <> nil then
    78   begin
     72  if img <> nil then begin
    7973    img.Free;
    8074    img := nil
  • trunk/LocalPlayer/CityScreen.pas

    r72 r73  
    1010  Protocol, ClientTools, Term, ScreenTools, IsoEngine, BaseWin,
    1111  LCLIntf, LCLType, Messages, SysUtils, Classes, Graphics, Controls, Forms, ExtCtrls,
    12   ButtonA, ButtonC, Area;
     12  ButtonA, ButtonC, Area, GraphType;
    1313
    1414const
     
    217217  Back.Canvas.FillRect(0, 0, Back.Width, Back.Height);
    218218  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);
    221221  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);
    224224  SmallCityMapTemplate := TBitmap.Create;
    225   LoadGraphicFile(SmallCityMapTemplate, HomeDir + 'Graphics' + DirectorySeparator + 'SmallCityMap',
     225  SmallCityMapTemplate.PixelFormat := pf24bit;
     226  LoadGraphicFile(SmallCityMapTemplate, HomeDir + 'Graphics' + DirectorySeparator + 'SmallCityMap.png',
    226227    gfNoGamma);
    227   SmallCityMapTemplate.PixelFormat := pf24bit;
    228228  SmallCityMap := TBitmap.Create;
    229229  SmallCityMap.PixelFormat := pf24bit;
  • trunk/LocalPlayer/Draft.pas

    r62 r73  
    9191  Back.Canvas.FillRect(0, 0, Back.Width, Back.Height);
    9292  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);
    9595end;
    9696
  • trunk/LocalPlayer/Help.pas

    r69 r73  
    968968          until (p > length(s)) or (s[p] = '\');
    969969          if LoadGraphicFile(ExtPic, LocalizedFilePath('Help' +
    970             DirectorySeparator + copy(s, 2, p - 2))) then
     970            DirectorySeparator + copy(s, 2, p - 2)) + '.png') then
    971971          begin
    972972            MainText.AddLine('', pkExternal);
  • trunk/LocalPlayer/IsoEngine.pas

    r68 r73  
    111111begin
    112112  result := false;
    113   HGrTerrainNew := LoadGraphicSet(Format('Terrain%dx%d',
     113  HGrTerrainNew := LoadGraphicSet(Format('Terrain%dx%d.png',
    114114    [xxtNew * 2, yytNew * 2]));
    115115  if HGrTerrainNew < 0 then
    116116    exit;
    117   HGrCitiesNew := LoadGraphicSet(Format('Cities%dx%d',
     117  HGrCitiesNew := LoadGraphicSet(Format('Cities%dx%d.png',
    118118    [xxtNew * 2, yytNew * 2]));
    119119  if HGrCitiesNew < 0 then
     
    334334  OceanMore.Free;
    335335  DitherMask.Free;
    336   //LandPatch.Savetofile('landpatch.bmp');
    337336
    338337  // reduce size of terrain icons
  • trunk/LocalPlayer/NatStat.pas

    r61 r73  
    9292  Back.Canvas.FillRect(0, 0, Back.Width, Back.Height);
    9393  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);
    9696end;
    9797
  • trunk/LocalPlayer/TechTree.pas

    r72 r73  
    128128  begin
    129129    Image := TBitmap.Create;
    130     LoadGraphicFile(Image, HomeDir + 'Help' + DirectorySeparator + 'AdvTree', gfNoGamma);
    131130    Image.PixelFormat := pf24bit;
     131    LoadGraphicFile(Image, HomeDir + 'Help' + DirectorySeparator + 'AdvTree.png', gfNoGamma);
    132132
    133133    with Image.Canvas do
  • trunk/LocalPlayer/Term.pas

    r72 r73  
    588588  SmallImp.EndUpdate;
    589589  FreeMem(resampled);
    590   // smallimp.savetofile(homedir+'smallimp.bmp'); //!!!
    591590end;
    592591
     
    674673    with Tribe[p].ModelPicture[mix] do
    675674    begin
    676       HGr := LoadGraphicSet(Picture.GrName);
     675      HGr := LoadGraphicSet(Picture.GrName + '.png');
    677676      pix := Picture.pix;
    678677    end;
     
    12031202    if AILogo[p] = nil then
    12041203      AILogo[p] := TBitmap.Create;
    1205     if not LoadGraphicFile(AILogo[p], HomeDir + Name, gfNoError) then
     1204    if not LoadGraphicFile(AILogo[p], HomeDir + Name + '.png', gfNoError) then
    12061205    begin
    12071206      AILogo[p].free;
     
    14671466    MainMap.SetOutput(offscreen);
    14681467
    1469     HGrStdUnits := LoadGraphicSet('StdUnits');
     1468    HGrStdUnits := LoadGraphicSet('StdUnits.png');
    14701469    SmallImp := TBitmap.Create;
    14711470    SmallImp.PixelFormat := pf24bit;
  • trunk/LocalPlayer/Tribes.pas

    r38 r73  
    301301        Item := Get;
    302302        sympix := GetNum;
    303         symHGr := LoadGraphicSet(Item);
     303        symHGr := LoadGraphicSet(Item + '.png');
    304304      end
    305305    end;
     
    425425                  end
    426426              end;
    427             cHGr := LoadGraphicSet(Item);
     427            cHGr := LoadGraphicSet(Item + '.png');
    428428            for x := 0 to 3 do
    429429              with CityPicture[x] do
     
    445445          else
    446446          begin
    447             faceHGr := LoadGraphicSet(Item);
     447            faceHGr := LoadGraphicSet(Item + '.png');
    448448            facepix := GetNum;
    449449            if GrExt[faceHGr].Data.Canvas.Pixels[facepix mod 10 * 65,
     
    477477            dec(i);
    478478          assert(i >= 0);
    479           assert(PictureList[i].HGr = LoadGraphicSet(GrName));
     479          assert(PictureList[i].HGr = LoadGraphicSet(GrName + '.png'));
    480480          assert(PictureList[i].pix = pix);
    481481          ModelPicture[mix].HGr := PictureList[i].HGr;
     
    487487          with ModelPicture[mix] do
    488488          begin
    489             HGr := LoadGraphicSet(GrName);
     489            HGr := LoadGraphicSet(GrName + '.png');
    490490            pix := Info.pix;
    491491            inc(GrExt[HGr].pixUsed[pix]);
  • trunk/LocalPlayer/UnitStat.pas

    r61 r73  
    8282  Back.Canvas.FillRect(0, 0, Back.Width,Back.Height);
    8383  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);
    8686end;
    8787
  • trunk/ScreenTools.pas

    r72 r73  
    99  {$ENDIF}
    1010  StringTables, LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls,
    11   Forms, Menus;
     11  Forms, Menus, GraphType;
    1212
    1313type
     
    4242    procedure SetXY(X, Y: Integer); inline; // Set pixel position relative to base
    4343    procedure SetX(X: Integer); inline; // Set horizontal pixel position relative to base
    44     procedure Init(Bitmap: TBitmap; BaseX: Integer = 0; BaseY: Integer = 0); inline;
     44    procedure Init(Bitmap: TRasterImage; BaseX: Integer = 0; BaseY: Integer = 0); inline;
    4545  end;
    4646  PPixelPointer = ^TPixelPointer;
     
    188188  gfNoError = $01;
    189189  gfNoGamma = $02;
    190   gfJPG = $04;
    191190
    192191type
     
    411410end;
    412411
     412procedure ApplyGammaToBitmap(Bitmap: TBitmap);
     413var
     414  PixelPtr: TPixelPointer;
     415  X, Y: Integer;
     416begin
     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;
     429end;
     430
     431procedure CopyGray8BitTo24bitBitmap(Dst, Src: TRasterImage);
     432var
     433  SrcPtr, DstPtr: TPixelPointer;
     434  X, Y: Integer;
     435begin
     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;
     450end;
     451
    413452function LoadGraphicFile(bmp: TBitmap; Path: string; Options: integer): boolean;
    414453var
    415   PixelPtr: TPixelPointer;
    416454  jtex: tjpegimage;
    417   X, Y: Integer;
    418 begin
    419   result := true;
    420   if Options and gfJPG <> 0 then
    421   begin
     455  Png: TPortableNetworkGraphic;
     456begin
     457  Result := True;
     458  if ExtractFileExt(Path) = '.jpg' then begin
    422459    jtex := tjpegimage.create;
    423460    try
    424       jtex.loadfromfile(Path + '.jpg');
     461      jtex.LoadFromFile(Path);
    425462    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);
    435469    end;
    436470    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;
    440475    try
    441       bmp.loadfromfile(Path + '.bmp');
     476      Png.LoadFromFile(Path);
    442477    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
    447498      if Options and gfNoGamma = 0 then
    448499        bmp.PixelFormat := pf24bit;
    449500    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
    453505    if Options and gfNoError = 0 then
    454506      Application.MessageBox(PChar(Format(Phrases.Lookup('FILENOTFOUND'),
    455507        [Path])), 'C-evo', 0);
    456     exit;
    457   end;
     508    Exit;
     509  end;
     510
    458511  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);
    473513end;
    474514
     
    484524    inc(i);
    485525  result := i;
    486   if i = nGrExt then
    487   begin
    488     FileName := HomeDir + 'Graphics' + DirectorySeparator + Name + '.bmp';
     526  if i = nGrExt then begin
    489527    Source := TBitmap.Create;
    490     try
    491       Source.LoadFromFile(FileName)
    492     except
     528    Source.PixelFormat := pf24bit;
     529    FileName := HomeDir + 'Graphics' + DirectorySeparator + Name;
     530    if not LoadGraphicFile(Source, FileName) then begin
    493531      Result := -1;
    494       Application.MessageBox(PChar(Format(Phrases.Lookup('FILENOTFOUND'),
    495         [FileName])), 'C-evo', 0);
    496       exit;
     532      Exit;
    497533    end;
    498534
     
    501537
    502538    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;
    505540
    506541    GrExt[nGrExt].Data := Source;
     
    13961431          MainTextureAge := Age;
    13971432          LoadGraphicFile(Image, HomeDir + 'Graphics' + DirectorySeparator + 'Texture' +
    1398             IntToStr(Age + 1), gfJPG);
     1433            IntToStr(Age + 1) + '.jpg');
    13991434          clBevelLight := Colors.Canvas.Pixels[clkAge0 + Age, cliBevelLight];
    14001435          clBevelShade := Colors.Canvas.Pixels[clkAge0 + Age, cliBevelShade];
     
    14421477end;
    14431478
    1444 procedure TPixelPointer.Init(Bitmap: TBitmap; BaseX: Integer = 0; BaseY: Integer = 0); inline;
     1479procedure TPixelPointer.Init(Bitmap: TRasterImage; BaseX: Integer = 0; BaseY: Integer = 0); inline;
    14451480begin
    14461481  BytesPerLine := Bitmap.RawImage.Description.BytesPerLine;
     
    15711606
    15721607  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;
    15771611  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;
    15851623  MainTextureAge := -2;
    15861624  ClickFrameColor := GrExt[HGrSystem].Data.Canvas.Pixels[187, 175];
    1587   InitOrnamentDone := false;
    1588   GenerateNames := true;
     1625  InitOrnamentDone := False;
     1626  GenerateNames := True;
    15891627end;
    15901628
  • trunk/Start.pas

    r72 r73  
    330330
    331331  BrainPicture[0] := TBitmap.Create;
    332   BrainPicture[0].width := 64;
    333   BrainPicture[0].height := 64;
     332  BrainPicture[0].SetSize(64, 64);
    334333  BitBlt(BrainPicture[0].Canvas.Handle, 0, 0, 64, 64,
    335334    GrExt[HGrSystem2].Data.Canvas.Handle, 1, 111, SRCCOPY);
    336335  BrainPicture[1] := TBitmap.Create;
    337   BrainPicture[1].width := 64;
    338   BrainPicture[1].height := 64;
     336  BrainPicture[1].SetSize(64, 64);
    339337  BitBlt(BrainPicture[1].Canvas.Handle, 0, 0, 64, 64,
    340338    GrExt[HGrSystem2].Data.Canvas.Handle, 66, 111, SRCCOPY);
    341339  BrainPicture[2] := TBitmap.Create;
    342   BrainPicture[2].width := 64;
    343   BrainPicture[2].height := 64;
     340  BrainPicture[2].SetSize(64, 64);
    344341  BitBlt(BrainPicture[2].Canvas.Handle, 0, 0, 64, 64,
    345342    GrExt[HGrSystem2].Data.Canvas.Handle, 131, 111, SRCCOPY);
    346343  BrainPicture[3] := TBitmap.Create;
    347   BrainPicture[3].width := 64;
    348   BrainPicture[3].height := 64;
     344  BrainPicture[3].SetSize(64, 64);
    349345  BitBlt(BrainPicture[3].Canvas.Handle, 0, 0, 64, 64,
    350346    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
    353348    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
    357351      BrainPicture[i].width := 64;
    358352      BrainPicture[i].height := 64;
    359       with BrainPicture[i].Canvas do
    360       begin
     353      with BrainPicture[i].Canvas do begin
    361354        Brush.Color := $904830;
    362355        FillRect(Rect(0, 0, 64, 64));
     
    366359        Textout(32 - TextWidth(Brain[i].FileName) div 2,
    367360          32 - TextHeight(Brain[i].FileName) div 2, Brain[i].FileName);
    368       end
    369     end
     361      end;
     362    end;
    370363  end;
    371364
     
    11681161          MapFileName := List.Items[List.ItemIndex] + '.cevo map';
    11691162        if LoadGraphicFile(Mini, DataDir + 'Maps' + DirectorySeparator + Copy(MapFileName, 1,
    1170           Length(MapFileName) - 9), gfNoError) then
     1163          Length(MapFileName) - 9) + '.png', gfNoError) then
    11711164        begin
    11721165          if Mini.width div 2 > MaxWidthMapLogo then
     
    17651758        try // rename map picture
    17661759          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');
    17691762        except
    17701763        end;
Note: See TracChangeset for help on using the changeset viewer.