Updated to last BGRABitmap. Fixed converter. Small fixes.

This commit is contained in:
meffi@lab313.ru
2014-04-27 23:00:00 +00:00
parent 8fe0f047c9
commit 911e5cb01a
10 changed files with 142 additions and 104 deletions

View File

@@ -23,11 +23,11 @@
<UseVersionInfo Value="True"/> <UseVersionInfo Value="True"/>
<AutoIncrementBuild Value="True"/> <AutoIncrementBuild Value="True"/>
<MajorVersionNr Value="1"/> <MajorVersionNr Value="1"/>
<RevisionNr Value="74"/> <RevisionNr Value="75"/>
<BuildNr Value="2"/> <BuildNr Value="4"/>
<StringTable CompanyName="Lab 313" FileDescription="The best TIMs tool ever!:)" ProductVersion=""/> <StringTable CompanyName="Lab 313" FileDescription="The best TIMs tool ever!:)" ProductVersion=""/>
</VersionInfo> </VersionInfo>
<BuildModes Count="5"> <BuildModes Count="6">
<Item1 Name="Debug" Default="True"/> <Item1 Name="Debug" Default="True"/>
<Item2 Name="Win Release x86"> <Item2 Name="Win Release x86">
<CompilerOptions> <CompilerOptions>
@@ -38,7 +38,7 @@
</Target> </Target>
<SearchPaths> <SearchPaths>
<IncludeFiles Value="$(ProjOutDir);bgrabitmap"/> <IncludeFiles Value="$(ProjOutDir);bgrabitmap"/>
<OtherUnitFiles Value="bgrabitmap"/> <OtherUnitFiles Value="lazpaint\bgrabitmap"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths> </SearchPaths>
<Parsing> <Parsing>
@@ -82,7 +82,7 @@
</Target> </Target>
<SearchPaths> <SearchPaths>
<IncludeFiles Value="$(ProjOutDir);bgrabitmap"/> <IncludeFiles Value="$(ProjOutDir);bgrabitmap"/>
<OtherUnitFiles Value="bgrabitmap"/> <OtherUnitFiles Value="lazpaint\bgrabitmap"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths> </SearchPaths>
<Parsing> <Parsing>
@@ -126,7 +126,7 @@
</Target> </Target>
<SearchPaths> <SearchPaths>
<IncludeFiles Value="$(ProjOutDir);bgrabitmap"/> <IncludeFiles Value="$(ProjOutDir);bgrabitmap"/>
<OtherUnitFiles Value="bgrabitmap"/> <OtherUnitFiles Value="lazpaint\bgrabitmap"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths> </SearchPaths>
<Parsing> <Parsing>
@@ -170,7 +170,7 @@
</Target> </Target>
<SearchPaths> <SearchPaths>
<IncludeFiles Value="$(ProjOutDir);bgrabitmap"/> <IncludeFiles Value="$(ProjOutDir);bgrabitmap"/>
<OtherUnitFiles Value="bgrabitmap"/> <OtherUnitFiles Value="lazpaint\bgrabitmap"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths> </SearchPaths>
<Parsing> <Parsing>
@@ -205,6 +205,50 @@
</Other> </Other>
</CompilerOptions> </CompilerOptions>
</Item5> </Item5>
<Item6 Name="Mac Release x86">
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="output\tim2view_$(TargetOS)"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir);bgrabitmap"/>
<OtherUnitFiles Value="lazpaint\bgrabitmap"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<UseAnsiStrings Value="False"/>
</SyntaxOptions>
</Parsing>
<CodeGeneration>
<SmartLinkUnit Value="True"/>
<TargetCPU Value="i386"/>
<TargetOS Value="win32"/>
<Optimizations>
<OptimizationLevel Value="3"/>
</Optimizations>
</CodeGeneration>
<Linking>
<Debugging>
<GenerateDebugInfo Value="False"/>
</Debugging>
<LinkSmart Value="True"/>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CompilerMessages>
<MsgFileName Value=""/>
</CompilerMessages>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
</Item6>
</BuildModes> </BuildModes>
<PublishOptions> <PublishOptions>
<Version Value="2"/> <Version Value="2"/>
@@ -307,7 +351,7 @@
</Target> </Target>
<SearchPaths> <SearchPaths>
<IncludeFiles Value="$(ProjOutDir);bgrabitmap"/> <IncludeFiles Value="$(ProjOutDir);bgrabitmap"/>
<OtherUnitFiles Value="bgrabitmap"/> <OtherUnitFiles Value="lazpaint\bgrabitmap"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths> </SearchPaths>
<Parsing> <Parsing>

View File

@@ -6,9 +6,7 @@ uses
{$IFDEF UNIX} {$IFDEF UNIX}
cthreads, cmem, cthreads, cmem,
{$ENDIF} {$ENDIF}
Interfaces, // this includes the LCL widgetset Forms, umain, Interfaces;
Forms, umain, edc, ucommon, ecc, ucdimage, utim, usettings, uscanresult,
uscanthread, ucpucount, udrawtim, BGRABitmap, uexportimport;
{$R *.res} {$R *.res}

View File

@@ -3,16 +3,16 @@
<ProjectSession> <ProjectSession>
<PathDelim Value="\"/> <PathDelim Value="\"/>
<Version Value="9"/> <Version Value="9"/>
<BuildModes Active="Win Release x86"/> <BuildModes Active="Debug"/>
<Units Count="15"> <Units Count="15">
<Unit0> <Unit0>
<Filename Value="tim2view.lpr"/> <Filename Value="tim2view.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="tim2view"/> <UnitName Value="tim2view"/>
<EditorIndex Value="11"/> <EditorIndex Value="1"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<CursorPos X="46" Y="15"/> <CursorPos X="46" Y="13"/>
<UsageCount Value="816"/> <UsageCount Value="816"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit0> </Unit0>
@@ -25,8 +25,8 @@
<UnitName Value="umain"/> <UnitName Value="umain"/>
<EditorIndex Value="0"/> <EditorIndex Value="0"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="489"/> <TopLine Value="890"/>
<CursorPos X="63" Y="499"/> <CursorPos X="50" Y="901"/>
<UsageCount Value="816"/> <UsageCount Value="816"/>
<Loaded Value="True"/> <Loaded Value="True"/>
<LoadedDesigner Value="True"/> <LoadedDesigner Value="True"/>
@@ -41,20 +41,19 @@
<Filename Value="ecc.pas"/> <Filename Value="ecc.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="ecc"/> <UnitName Value="ecc"/>
<EditorIndex Value="3"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="13"/> <TopLine Value="13"/>
<CursorPos X="1" Y="1"/> <CursorPos X="1" Y="1"/>
<UsageCount Value="816"/> <UsageCount Value="816"/>
<Loaded Value="True"/>
</Unit3> </Unit3>
<Unit4> <Unit4>
<Filename Value="ucommon.pas"/> <Filename Value="ucommon.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="ucommon"/> <UnitName Value="ucommon"/>
<EditorIndex Value="4"/> <IsVisibleTab Value="True"/>
<EditorIndex Value="3"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="14"/> <TopLine Value="1"/>
<CursorPos X="35" Y="6"/> <CursorPos X="35" Y="6"/>
<UsageCount Value="816"/> <UsageCount Value="816"/>
<Loaded Value="True"/> <Loaded Value="True"/>
@@ -63,7 +62,7 @@
<Filename Value="utim.pas"/> <Filename Value="utim.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="utim"/> <UnitName Value="utim"/>
<EditorIndex Value="7"/> <EditorIndex Value="10"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="185"/> <TopLine Value="185"/>
<CursorPos X="1" Y="204"/> <CursorPos X="1" Y="204"/>
@@ -74,7 +73,7 @@
<Filename Value="ucdimage.pas"/> <Filename Value="ucdimage.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="ucdimage"/> <UnitName Value="ucdimage"/>
<EditorIndex Value="1"/> <EditorIndex Value="2"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="112"/> <TopLine Value="112"/>
<CursorPos X="50" Y="117"/> <CursorPos X="50" Y="117"/>
@@ -85,7 +84,7 @@
<Filename Value="usettings.pas"/> <Filename Value="usettings.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="usettings"/> <UnitName Value="usettings"/>
<EditorIndex Value="5"/> <EditorIndex Value="9"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="81"/> <TopLine Value="81"/>
<CursorPos X="55" Y="92"/> <CursorPos X="55" Y="92"/>
@@ -96,10 +95,10 @@
<Filename Value="uscanresult.pas"/> <Filename Value="uscanresult.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="uscanresult"/> <UnitName Value="uscanresult"/>
<EditorIndex Value="12"/> <EditorIndex Value="7"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="51"/> <TopLine Value="1"/>
<CursorPos X="1" Y="67"/> <CursorPos X="10" Y="5"/>
<UsageCount Value="816"/> <UsageCount Value="816"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit8> </Unit8>
@@ -107,10 +106,10 @@
<Filename Value="uscanthread.pas"/> <Filename Value="uscanthread.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="uscanthread"/> <UnitName Value="uscanthread"/>
<EditorIndex Value="6"/> <EditorIndex Value="8"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="155"/> <TopLine Value="1"/>
<CursorPos X="36" Y="168"/> <CursorPos X="43" Y="6"/>
<UsageCount Value="816"/> <UsageCount Value="816"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit9> </Unit9>
@@ -118,7 +117,7 @@
<Filename Value="ucpucount.pas"/> <Filename Value="ucpucount.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="ucpucount"/> <UnitName Value="ucpucount"/>
<EditorIndex Value="2"/> <EditorIndex Value="4"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="19"/> <TopLine Value="19"/>
<CursorPos X="87" Y="34"/> <CursorPos X="87" Y="34"/>
@@ -129,11 +128,10 @@
<Filename Value="udrawtim.pas"/> <Filename Value="udrawtim.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="udrawtim"/> <UnitName Value="udrawtim"/>
<IsVisibleTab Value="True"/> <EditorIndex Value="5"/>
<EditorIndex Value="8"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="234"/> <TopLine Value="6"/>
<CursorPos X="61" Y="245"/> <CursorPos X="49" Y="14"/>
<UsageCount Value="816"/> <UsageCount Value="816"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit11> </Unit11>
@@ -149,22 +147,20 @@
<Unit13> <Unit13>
<Filename Value="todos.inc"/> <Filename Value="todos.inc"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<EditorIndex Value="10"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<CursorPos X="20" Y="1"/> <CursorPos X="48" Y="2"/>
<UsageCount Value="802"/> <UsageCount Value="802"/>
<Loaded Value="True"/>
</Unit13> </Unit13>
<Unit14> <Unit14>
<Filename Value="uexportimport.pas"/> <Filename Value="uexportimport.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="uexportimport"/> <UnitName Value="uexportimport"/>
<EditorIndex Value="9"/> <EditorIndex Value="6"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="13"/> <TopLine Value="7"/>
<CursorPos X="52" Y="19"/> <CursorPos X="69" Y="16"/>
<UsageCount Value="53"/> <UsageCount Value="56"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit14> </Unit14>
</Units> </Units>
@@ -173,7 +169,7 @@
</General> </General>
</ProjectSession> </ProjectSession>
<Debugging> <Debugging>
<BreakPoints Count="4"> <BreakPoints Count="2">
<Item1> <Item1>
<Kind Value="bpkSource"/> <Kind Value="bpkSource"/>
<WatchScope Value="wpsLocal"/> <WatchScope Value="wpsLocal"/>
@@ -188,20 +184,6 @@
<Source Value="c:\Lazarus\fpc\2.6.2\source\packages\fcl-image\src\fppalette.inc"/> <Source Value="c:\Lazarus\fpc\2.6.2\source\packages\fcl-image\src\fppalette.inc"/>
<Line Value="159"/> <Line Value="159"/>
</Item2> </Item2>
<Item3>
<Kind Value="bpkSource"/>
<WatchScope Value="wpsLocal"/>
<WatchKind Value="wpkWrite"/>
<Source Value="umain.pas"/>
<Line Value="361"/>
</Item3>
<Item4>
<Kind Value="bpkSource"/>
<WatchScope Value="wpsLocal"/>
<WatchKind Value="wpkWrite"/>
<Source Value="umain.pas"/>
<Line Value="767"/>
</Item4>
</BreakPoints> </BreakPoints>
<Watches Count="3"> <Watches Count="3">
<Item1> <Item1>

Binary file not shown.

View File

@@ -1 +1,2 @@
{ TODO : Zooming? } { TODO : Zooming? }
{ TODO : Add different PNG output for Export. }

View File

@@ -3,7 +3,7 @@ unit ucommon;
interface interface
const const
cProgramName = 'Tim2View SVN.r74 by [Lab 313] (for ' + cProgramName = 'Tim2View SVN.r77 by [Lab 313] (for ' +
{$IFDEF Linux}'Linux' + {$IFEND} {$IFDEF Linux}'Linux' + {$IFEND}
{$IFDEF Darwin}'Mac OS X' + {$IFEND} {$IFDEF Darwin}'Mac OS X' + {$IFEND}
{$IFDEF Windows}'Windows' + {$IFEND} {$IFDEF Windows}'Windows' + {$IFEND}

View File

@@ -11,7 +11,7 @@ type
PDrawGrid = ^TDrawGrid; PDrawGrid = ^TDrawGrid;
procedure Tim2Png(TIM: PTIM; CLUT_NUM: Integer; Surf: PDrawSurf; TranspMode: Byte); procedure Tim2Png(TIM: PTIM; CLUT_NUM: Integer; Image: PDrawSurf; TranspMode: Byte; ForExport: Boolean);
procedure Png2Tim(Image: PDrawSurf; Dest: PTIM); procedure Png2Tim(Image: PDrawSurf; Dest: PTIM);
procedure DrawClutCell(TIM: PTIM; CLUT_NUM: Integer; Grid: PDrawGrid; X, Y: Integer); procedure DrawClutCell(TIM: PTIM; CLUT_NUM: Integer; Grid: PDrawGrid; X, Y: Integer);
procedure DrawClut(TIM: PTIM; CLUT_NUM: Integer; Grid: PDrawGrid); procedure DrawClut(TIM: PTIM; CLUT_NUM: Integer; Grid: PDrawGrid);
@@ -69,7 +69,7 @@ begin
end end
end; end;
procedure PrepareClut(TIM: PTIM; CLUT_NUM: Integer; Pal: PFPPalette; TranspMode: Integer); procedure PrepareClut(TIM: PTIM; CLUT_NUM: Integer; Pal: PFPPalette; TranspMode: Integer; ForExport: Boolean);
var var
I, COUNT: Integer; I, COUNT: Integer;
CC: TCLUT_COLOR; CC: TCLUT_COLOR;
@@ -92,19 +92,26 @@ begin
CC := GetCLUTColor(TIM, CLUT_NUM, I - 1); CC := GetCLUTColor(TIM, CLUT_NUM, I - 1);
if I <= COUNT then if I <= COUNT then
begin begin
R := CC.R + ((I - 1) and %00000011) shl 1 + CC.STP; R := CC.R;
G := CC.G + ((I - 1) and %00011100) shr 2; G := CC.G;
B := CC.B + ((I - 1) and %11100000) shr 5; B := CC.B;
A := CC.STP; A := CC.STP;
end end
else else
begin begin
R := ((I - 1) and %00000011) shl 1 + CC.STP; R := 0;
G := ((I - 1) and %00011100) shr 2; G := 0;
B := ((I - 1) and %11100000) shr 5; B := 0;
A := 0; A := 0;
end; end;
if ForExport then
begin
R := R + ((I - 1) and %00000011);
G := G + ((I - 1) and %00011100) shr 2;
B := B + ((I - 1) and %11100000) shr 5;
end;
FC := BGRAToFPColor(BGRA(R, G, B, A)); FC := BGRAToFPColor(BGRA(R, G, B, A));
AlphaForMode(@FC, TranspMode); AlphaForMode(@FC, TranspMode);
Pal^.Add(FC); Pal^.Add(FC);
@@ -175,7 +182,7 @@ begin
ClearCanvas(@Grid^.Canvas, Grid^.CellRect(X - 1, Y - 1)); ClearCanvas(@Grid^.Canvas, Grid^.CellRect(X - 1, Y - 1));
end; end;
procedure Tim2Png(TIM: PTIM; CLUT_NUM: Integer; Surf: PDrawSurf; TranspMode: Byte); procedure Tim2Png(TIM: PTIM; CLUT_NUM: Integer; Image: PDrawSurf; TranspMode: Byte; ForExport: Boolean);
var var
RW, RH, CW: Word; RW, RH, CW: Word;
INDEXES: PIMAGE_INDEXES; INDEXES: PIMAGE_INDEXES;
@@ -188,14 +195,14 @@ begin
RW := GetTimRealWidth(TIM); RW := GetTimRealWidth(TIM);
RH := GetTimHeight(TIM); RH := GetTimHeight(TIM);
if (Surf^ <> nil) then Surf^.Free; if (Image^ <> nil) then Image^.Free;
Surf^ := TBGRABitmap.Create(RW, RH); Image^ := TBGRABitmap.Create(RW, RH);
Surf^.UsePalette := not(TIM^.HEAD^.bBPP in [cTIM16NC, cTIM24NC]); Image^.UsePalette := not(TIM^.HEAD^.bBPP in [cTIM16NC, cTIM24NC]);
PAL := @(Surf^.Palette); PAL := @(Image^.Palette);
PrepareClut(TIM, CLUT_NUM, PAL, TranspMode); PrepareClut(TIM, CLUT_NUM, PAL, TranspMode, ForExport);
INDEXES := PrepareIMAGE(TIM); INDEXES := PrepareIMAGE(TIM);
COLORS := GetTimColorsCount(TIM); COLORS := GetTimColorsCount(TIM);
@@ -210,7 +217,7 @@ begin
begin begin
case TIM^.HEAD^.bBPP of case TIM^.HEAD^.bBPP of
cTIM4C, cTIM4NC, cTIM8C, cTIM8NC: cTIM4C, cTIM4NC, cTIM8C, cTIM8NC:
Surf^.Pixels[X - 1, Y - 1] := INDEXES^[IDX] mod COLORS; Image^.Pixels[X - 1, Y - 1] := INDEXES^[IDX] mod COLORS;
cTIM16C, cTIM16NC, cTIMMix: cTIM16C, cTIM16NC, cTIMMix:
begin begin
CW := 0; CW := 0;
@@ -220,7 +227,7 @@ begin
FC := BGRAToFPColor(BGRA(CC.R, CC.G, CC.B, CC.STP)); FC := BGRAToFPColor(BGRA(CC.R, CC.G, CC.B, CC.STP));
AlphaForMode(@FC, TranspMode); AlphaForMode(@FC, TranspMode);
Surf^.Colors[X - 1, Y - 1] := FC; Image^.Colors[X - 1, Y - 1] := FC;
end; end;
cTIM24C, cTIM24NC: cTIM24C, cTIM24NC:
begin begin
@@ -229,7 +236,7 @@ begin
R := (INDEX and $FF); R := (INDEX and $FF);
G := ((INDEX and $FF00) shr 8); G := ((INDEX and $FF00) shr 8);
B := ((INDEX and $FF0000) shr 16); B := ((INDEX and $FF0000) shr 16);
Surf^.Colors[X - 1, Y - 1] := BGRAToFPColor(BGRA(R, G, B, 255)); Image^.Colors[X - 1, Y - 1] := BGRAToFPColor(BGRA(R, G, B, 255));
end; end;
else else
Break; Break;

View File

@@ -1,7 +1,7 @@
object frmMain: TfrmMain object frmMain: TfrmMain
Left = 807 Left = 919
Height = 590 Height = 590
Top = 193 Top = 209
Width = 780 Width = 780
HorzScrollBar.Page = 780 HorzScrollBar.Page = 780
HorzScrollBar.Range = 489 HorzScrollBar.Range = 489
@@ -954,12 +954,12 @@ object frmMain: TfrmMain
object actScanFile: TAction object actScanFile: TAction
Caption = 'Scan &File...' Caption = 'Scan &File...'
OnExecute = actScanFileExecute OnExecute = actScanFileExecute
ShortCut = 116 ShortCut = 117
end end
object actScanDir: TAction object actScanDir: TAction
Caption = 'Scan &Directory...' Caption = 'Scan &Directory...'
OnExecute = actScanDirExecute OnExecute = actScanDirExecute
ShortCut = 117 ShortCut = 118
end end
object actCloseFile: TAction object actCloseFile: TAction
Caption = 'Close &this File' Caption = 'Close &this File'
@@ -981,20 +981,21 @@ object frmMain: TfrmMain
OnExecute = actExtractTimExecute OnExecute = actExtractTimExecute
ShortCut = 113 ShortCut = 113
end end
object actPngExport: TAction
Caption = 'Export &PNG...'
OnExecute = actPngExportExecute
ShortCut = 115
end
object actPngImport: TAction object actPngImport: TAction
Caption = '&Import PNG...' Caption = '&Import PNG...'
OnExecute = actPngImportExecute OnExecute = actPngImportExecute
ShortCut = 116
end end
object actReplaceTim: TAction object actReplaceTim: TAction
Caption = '&Replace TIM...' Caption = '&Replace TIM...'
OnExecute = actReplaceTimExecute OnExecute = actReplaceTimExecute
ShortCut = 114 ShortCut = 114
end end
object actPngExport: TAction
Caption = 'Export &PNG...'
OnExecute = actPngExportExecute
ShortCut = 115
end
object actOpenRepo: TAction object actOpenRepo: TAction
Caption = 'Tim2Vew &SVN Repo' Caption = 'Tim2Vew &SVN Repo'
OnExecute = actOpenRepoExecute OnExecute = actOpenRepoExecute

View File

@@ -5,10 +5,10 @@ unit umain;
interface interface
uses uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ActnList, Classes, SysUtils, FileUtil, Forms, Dialogs, ActnList,
Menus, StdCtrls, ExtCtrls, ComCtrls, Grids, ExtDlgs, Menus, StdCtrls, ExtCtrls, ComCtrls, Grids, ExtDlgs,
uscanresult, uscanthread, usettings, utim, udrawtim; uscanresult, uscanthread, usettings, utim, udrawtim, types;
{$INCLUDE todos.inc} {$INCLUDE todos.inc}
@@ -185,7 +185,8 @@ var
implementation implementation
uses ucdimage, ucpucount, lcltype, ucommon, LCLIntf, uexportimport uses ucdimage, ucpucount, lcltype, ucommon, LCLIntf, uexportimport,
FPimage
{$IFDEF windows} {$IFDEF windows}
,registry ,registry
@@ -237,17 +238,20 @@ end;
procedure TfrmMain.actPngExportExecute(Sender: TObject); procedure TfrmMain.actPngExportExecute(Sender: TObject);
var var
TIM: PTIM; TIM: PTIM;
Image: PDrawSurf;
begin begin
TIM := SelectedTimInMode; TIM := SelectedTimInMode;
if TIM = nil then Exit; if TIM = nil then Exit;
dlgSavePNG.FileName := FormatPngName(SelectedScanResult.ScanFile, TIM^.dwTimNumber, SelectedTimInfo.BitMode, cbbCLUT.ItemIndex); dlgSavePNG.FileName := FormatPngName(SelectedScanResult.ScanFile, TIM^.dwTimNumber, SelectedTimInfo.BitMode, cbbCLUT.ItemIndex);
if not dlgSavePNG.Execute then Exit; if not dlgSavePNG.Execute then Exit;
SaveImage(dlgSavePNG.FileName, Surf, TIMisIndexed(TIM)); Tim2Png(TIM, cbbCLUT.ItemIndex, Image, cbbTranspMode.ItemIndex, True);
SaveImage(dlgSavePNG.FileName, Image, TIMisIndexed(TIM));
FreeTIM(TIM); FreeTIM(TIM);
{$IFDEF Linux}FpChmod(dlgSavePNG.FileName, &777){$IFEND} Image^.Free;
Dispose(Image);
{$IFDEF Linux}FpChmod(dlgSavePNG.FileName, &777);{$IFEND}
end; end;
procedure TfrmMain.btnShowClutClick(Sender: TObject); procedure TfrmMain.btnShowClutClick(Sender: TObject);
@@ -382,15 +386,15 @@ var
IsImage: Boolean; IsImage: Boolean;
ScanTim: TTimInfo; ScanTim: TTimInfo;
TIM: PTIM; TIM: PTIM;
PNG: PDrawSurf; Image: PDrawSurf;
begin begin
lblStatus.Caption := sStatusBarPngsExtracting; lblStatus.Caption := sStatusBarPngsExtracting;
FName := SelectedScanResult.ScanFile; FName := SelectedScanResult.ScanFile;
IsImage := SelectedScanResult.IsImage; IsImage := SelectedScanResult.IsImage;
New(PNG); New(Image);
PNG^ := nil; Image^ := nil;
pbProgress.Position := 0; pbProgress.Position := 0;
pbProgress.Max := SelectedScanResult.Count; pbProgress.Max := SelectedScanResult.Count;
@@ -407,20 +411,20 @@ begin
CreateDirUTF8(Path); CreateDirUTF8(Path);
TIM := LoadTimFromFile(FName, OFFSET, IsImage, SIZE); TIM := LoadTimFromFile(FName, OFFSET, IsImage, SIZE);
Tim2Png(TIM, cbbCLUT.ItemIndex, PNG, cbbTranspMode.ItemIndex); Tim2Png(TIM, cbbCLUT.ItemIndex, Image, cbbTranspMode.ItemIndex, False);
Path := Path + FormatPngName(FName, I - 1, BIT_MODE, 0); Path := Path + FormatPngName(FName, I - 1, BIT_MODE, 0);
SaveImage(Path, PNG, TIMisIndexed(TIM)); SaveImage(Path, Image, TIMisIndexed(TIM));
{$IFDEF Linux}FpChmod(Path, &777){$IFEND} {$IFDEF Linux}FpChmod(Path, &777);{$IFEND}
PNG^.Free; Image^.Free;
PNG^ := nil; Image^ := nil;
FreeTIM(TIM); FreeTIM(TIM);
pbProgress.Position := I; pbProgress.Position := I;
Application.ProcessMessages; Application.ProcessMessages;
end; end;
Dispose(PNG); Dispose(Image);
lblStatus.Caption := sStatusBarExtracted; lblStatus.Caption := sStatusBarExtracted;
pbProgress.Position := 0; pbProgress.Position := 0;
end; end;
@@ -435,7 +439,7 @@ begin
TIM := SelectedTimInMode; TIM := SelectedTimInMode;
SaveTimToFile(dlgSaveTIM.FileName, TIM); SaveTimToFile(dlgSaveTIM.FileName, TIM);
{$IFDEF Linux}FpChmod(dlgSaveTIM.FileName, &777){$IFEND} {$IFDEF Linux}FpChmod(dlgSaveTIM.FileName, &777);{$IFEND}
FreeTIM(TIM); FreeTIM(TIM);
end; end;
@@ -469,7 +473,7 @@ begin
TIM := LoadTimFromFile(FName, OFFSET, IsImage, SIZE); TIM := LoadTimFromFile(FName, OFFSET, IsImage, SIZE);
Path := Path + FormatTimName(FName, I - 1, BIT_MODE); Path := Path + FormatTimName(FName, I - 1, BIT_MODE);
SaveTimToFile(Path, TIM); SaveTimToFile(Path, TIM);
{$IFDEF Linux}FpChmod(Path, &777){$IFEND} {$IFDEF Linux}FpChmod(Path, &777);{$IFEND}
FreeTIM(TIM); FreeTIM(TIM);
pbProgress.Position := I; pbProgress.Position := I;
@@ -553,7 +557,6 @@ begin
Surf^.Free; Surf^.Free;
Dispose(Surf); Dispose(Surf);
Settings.Free; Settings.Free;
end; end;
@@ -821,6 +824,7 @@ begin
actReplaceTim.Enabled := (lvList.Selected <> nil) and (lvList.Selected.Index <> -1); actReplaceTim.Enabled := (lvList.Selected <> nil) and (lvList.Selected.Index <> -1);
actPngExport.Enabled := (Surf^ <> nil) and actReplaceTim.Enabled; actPngExport.Enabled := (Surf^ <> nil) and actReplaceTim.Enabled;
actPngImport.Enabled := actReplaceTim.Enabled;
actExtractTim.Enabled := actReplaceTim.Enabled; actExtractTim.Enabled := actReplaceTim.Enabled;
pnlImageOptions.Enabled := actReplaceTim.Enabled; pnlImageOptions.Enabled := actReplaceTim.Enabled;
@@ -895,13 +899,14 @@ procedure TfrmMain.DrawSelTim;
var var
TIM: PTIM; TIM: PTIM;
begin begin
imgTim.Picture.Bitmap.FreeImage;
imgTim.Picture.Bitmap := nil; imgTim.Picture.Bitmap := nil;
TIM := SelectedTimInMode; TIM := SelectedTimInMode;
if TIM = nil then Exit; if TIM = nil then Exit;
Tim2Png(TIM, cbbCLUT.ItemIndex, Surf, cbbTranspMode.ItemIndex); Tim2Png(TIM, cbbCLUT.ItemIndex, Surf, cbbTranspMode.ItemIndex, False);
imgTim.Picture.Bitmap := Surf^.Bitmap; imgTim.Picture.Bitmap.Assign(Surf^.Bitmap);
FreeTIM(TIM); FreeTIM(TIM);
imgTim.Stretch := actStretch.Checked; imgTim.Stretch := actStretch.Checked;

View File

@@ -5,7 +5,7 @@ unit usettings;
interface interface
uses uses
Classes, SysUtils, IniFiles, Graphics; SysUtils, IniFiles, Graphics;
type type