Added CLT, PXL support.

Added Mixed TIM with CLUT support.
Some longtime bugs fixed.
This commit is contained in:
meffi@lab313.ru
2015-03-05 17:37:13 +00:00
parent 347d12c47a
commit 0f9db56afa
11 changed files with 439 additions and 403 deletions

View File

@@ -14,6 +14,9 @@
<MainUnit Value="0"/> <MainUnit Value="0"/>
<Title Value="tim2view"/> <Title Value="tim2view"/>
<UseXPManifest Value="True"/> <UseXPManifest Value="True"/>
<XPManifest>
<DpiAware Value="True"/>
</XPManifest>
<Icon Value="0"/> <Icon Value="0"/>
</General> </General>
<i18n> <i18n>
@@ -23,8 +26,8 @@
<UseVersionInfo Value="True"/> <UseVersionInfo Value="True"/>
<AutoIncrementBuild Value="True"/> <AutoIncrementBuild Value="True"/>
<MajorVersionNr Value="1"/> <MajorVersionNr Value="1"/>
<RevisionNr Value="86"/> <RevisionNr Value="88"/>
<BuildNr Value="1"/> <BuildNr Value="12"/>
<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="6"> <BuildModes Count="6">
@@ -65,12 +68,6 @@
</Win32> </Win32>
</Options> </Options>
</Linking> </Linking>
<Other>
<CompilerMessages>
<MsgFileName Value=""/>
</CompilerMessages>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions> </CompilerOptions>
</Item2> </Item2>
<Item3 Name="Win Release x64"> <Item3 Name="Win Release x64">
@@ -109,12 +106,6 @@
</Win32> </Win32>
</Options> </Options>
</Linking> </Linking>
<Other>
<CompilerMessages>
<MsgFileName Value=""/>
</CompilerMessages>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions> </CompilerOptions>
</Item3> </Item3>
<Item4 Name="Linux Release x86"> <Item4 Name="Linux Release x86">
@@ -153,12 +144,6 @@
</Win32> </Win32>
</Options> </Options>
</Linking> </Linking>
<Other>
<CompilerMessages>
<MsgFileName Value=""/>
</CompilerMessages>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions> </CompilerOptions>
</Item4> </Item4>
<Item5 Name="Linux Release x64"> <Item5 Name="Linux Release x64">
@@ -197,12 +182,6 @@
</Win32> </Win32>
</Options> </Options>
</Linking> </Linking>
<Other>
<CompilerMessages>
<MsgFileName Value=""/>
</CompilerMessages>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions> </CompilerOptions>
</Item5> </Item5>
<Item6 Name="Mac Release x86"> <Item6 Name="Mac Release x86">
@@ -241,12 +220,6 @@
</Win32> </Win32>
</Options> </Options>
</Linking> </Linking>
<Other>
<CompilerMessages>
<MsgFileName Value=""/>
</CompilerMessages>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions> </CompilerOptions>
</Item6> </Item6>
</BuildModes> </BuildModes>
@@ -267,7 +240,6 @@
<Unit0> <Unit0>
<Filename Value="tim2view.lpr"/> <Filename Value="tim2view.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="tim2view"/>
</Unit0> </Unit0>
<Unit1> <Unit1>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
@@ -280,12 +252,10 @@
<Unit2> <Unit2>
<Filename Value="edc.pas"/> <Filename Value="edc.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="edc"/>
</Unit2> </Unit2>
<Unit3> <Unit3>
<Filename Value="ecc.pas"/> <Filename Value="ecc.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="ecc"/>
</Unit3> </Unit3>
<Unit4> <Unit4>
<Filename Value="ucommon.pas"/> <Filename Value="ucommon.pas"/>
@@ -330,7 +300,6 @@
<Unit12> <Unit12>
<Filename Value="bgrabitmap\bgrabitmap.pas"/> <Filename Value="bgrabitmap\bgrabitmap.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="BGRABitmap"/>
</Unit12> </Unit12>
<Unit13> <Unit13>
<Filename Value="todos.inc"/> <Filename Value="todos.inc"/>
@@ -376,12 +345,6 @@
</Win32> </Win32>
</Options> </Options>
</Linking> </Linking>
<Other>
<CompilerMessages>
<MsgFileName Value=""/>
</CompilerMessages>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions> </CompilerOptions>
<Debugging> <Debugging>
<Exceptions Count="3"> <Exceptions Count="3">

View File

@@ -3,14 +3,11 @@
<ProjectSession> <ProjectSession>
<PathDelim Value="\"/> <PathDelim Value="\"/>
<Version Value="9"/> <Version Value="9"/>
<BuildModes Active="Debug"/> <BuildModes Active="Win Release x86"/>
<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"/>
<WindowIndex Value="0"/>
<TopLine Value="1"/>
<CursorPos X="46" Y="13"/> <CursorPos X="46" Y="13"/>
<UsageCount Value="816"/> <UsageCount Value="816"/>
</Unit0> </Unit0>
@@ -21,10 +18,9 @@
<HasResources Value="True"/> <HasResources Value="True"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<UnitName Value="umain"/> <UnitName Value="umain"/>
<EditorIndex Value="0"/> <IsVisibleTab Value="True"/>
<WindowIndex Value="0"/> <TopLine Value="691"/>
<TopLine Value="295"/> <CursorPos X="81" Y="710"/>
<CursorPos X="66" Y="308"/>
<UsageCount Value="816"/> <UsageCount Value="816"/>
<Loaded Value="True"/> <Loaded Value="True"/>
<LoadedDesigner Value="True"/> <LoadedDesigner Value="True"/>
@@ -32,16 +28,12 @@
<Unit2> <Unit2>
<Filename Value="edc.pas"/> <Filename Value="edc.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="edc"/>
<UsageCount Value="816"/> <UsageCount Value="816"/>
</Unit2> </Unit2>
<Unit3> <Unit3>
<Filename Value="ecc.pas"/> <Filename Value="ecc.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="ecc"/>
<WindowIndex Value="0"/>
<TopLine Value="13"/> <TopLine Value="13"/>
<CursorPos X="1" Y="1"/>
<UsageCount Value="816"/> <UsageCount Value="816"/>
</Unit3> </Unit3>
<Unit4> <Unit4>
@@ -49,9 +41,8 @@
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="ucommon"/> <UnitName Value="ucommon"/>
<EditorIndex Value="3"/> <EditorIndex Value="3"/>
<WindowIndex Value="0"/> <TopLine Value="15"/>
<TopLine Value="1"/> <CursorPos X="73" Y="11"/>
<CursorPos X="70" Y="9"/>
<UsageCount Value="816"/> <UsageCount Value="816"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit4> </Unit4>
@@ -60,9 +51,8 @@
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="utim"/> <UnitName Value="utim"/>
<EditorIndex Value="10"/> <EditorIndex Value="10"/>
<WindowIndex Value="0"/> <TopLine Value="420"/>
<TopLine Value="244"/> <CursorPos Y="401"/>
<CursorPos X="82" Y="311"/>
<UsageCount Value="816"/> <UsageCount Value="816"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit5> </Unit5>
@@ -71,7 +61,6 @@
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="ucdimage"/> <UnitName Value="ucdimage"/>
<EditorIndex Value="2"/> <EditorIndex Value="2"/>
<WindowIndex Value="0"/>
<TopLine Value="112"/> <TopLine Value="112"/>
<CursorPos X="50" Y="117"/> <CursorPos X="50" Y="117"/>
<UsageCount Value="816"/> <UsageCount Value="816"/>
@@ -82,9 +71,8 @@
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="usettings"/> <UnitName Value="usettings"/>
<EditorIndex Value="9"/> <EditorIndex Value="9"/>
<WindowIndex Value="0"/> <TopLine Value="58"/>
<TopLine Value="132"/> <CursorPos X="35" Y="63"/>
<CursorPos X="1" Y="150"/>
<UsageCount Value="816"/> <UsageCount Value="816"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit7> </Unit7>
@@ -93,9 +81,8 @@
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="uscanresult"/> <UnitName Value="uscanresult"/>
<EditorIndex Value="7"/> <EditorIndex Value="7"/>
<WindowIndex Value="0"/> <TopLine Value="56"/>
<TopLine Value="54"/> <CursorPos Y="71"/>
<CursorPos X="79" Y="80"/>
<UsageCount Value="816"/> <UsageCount Value="816"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit8> </Unit8>
@@ -104,9 +91,8 @@
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="uscanthread"/> <UnitName Value="uscanthread"/>
<EditorIndex Value="8"/> <EditorIndex Value="8"/>
<WindowIndex Value="0"/> <TopLine Value="18"/>
<TopLine Value="172"/> <CursorPos X="37" Y="68"/>
<CursorPos X="3" Y="187"/>
<UsageCount Value="816"/> <UsageCount Value="816"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit9> </Unit9>
@@ -115,7 +101,6 @@
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="ucpucount"/> <UnitName Value="ucpucount"/>
<EditorIndex Value="4"/> <EditorIndex Value="4"/>
<WindowIndex Value="0"/>
<TopLine Value="19"/> <TopLine Value="19"/>
<CursorPos X="87" Y="34"/> <CursorPos X="87" Y="34"/>
<UsageCount Value="816"/> <UsageCount Value="816"/>
@@ -125,19 +110,14 @@
<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="5"/>
<WindowIndex Value="0"/> <CursorPos X="15" Y="212"/>
<TopLine Value="92"/>
<CursorPos X="58" Y="103"/>
<UsageCount Value="816"/> <UsageCount Value="816"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit11> </Unit11>
<Unit12> <Unit12>
<Filename Value="bgrabitmap\bgrabitmap.pas"/> <Filename Value="bgrabitmap\bgrabitmap.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="BGRABitmap"/>
<WindowIndex Value="0"/>
<TopLine Value="54"/> <TopLine Value="54"/>
<CursorPos X="3" Y="69"/> <CursorPos X="3" Y="69"/>
<UsageCount Value="816"/> <UsageCount Value="816"/>
@@ -146,8 +126,6 @@
<Filename Value="todos.inc"/> <Filename Value="todos.inc"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<EditorIndex Value="1"/> <EditorIndex Value="1"/>
<WindowIndex Value="0"/>
<TopLine Value="1"/>
<CursorPos X="31" Y="3"/> <CursorPos X="31" Y="3"/>
<UsageCount Value="802"/> <UsageCount Value="802"/>
<Loaded Value="True"/> <Loaded Value="True"/>
@@ -157,19 +135,15 @@
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="uexportimport"/> <UnitName Value="uexportimport"/>
<EditorIndex Value="6"/> <EditorIndex Value="6"/>
<WindowIndex Value="0"/>
<TopLine Value="7"/> <TopLine Value="7"/>
<CursorPos X="20" Y="16"/> <CursorPos X="32" Y="35"/>
<UsageCount Value="83"/> <UsageCount Value="96"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit14> </Unit14>
</Units> </Units>
<General>
<ActiveWindowIndexAtStart Value="0"/>
</General>
</ProjectSession> </ProjectSession>
<Debugging> <Debugging>
<BreakPoints Count="2"> <BreakPoints Count="3">
<Item1> <Item1>
<Kind Value="bpkSource"/> <Kind Value="bpkSource"/>
<WatchScope Value="wpsLocal"/> <WatchScope Value="wpsLocal"/>
@@ -184,6 +158,13 @@
<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="usettings.pas"/>
<Line Value="74"/>
</Item3>
</BreakPoints> </BreakPoints>
<Watches Count="3"> <Watches Count="3">
<Item1> <Item1>
@@ -200,5 +181,4 @@
</Item3> </Item3>
</Watches> </Watches>
</Debugging> </Debugging>
<EditorMacros Count="0"/>
</CONFIG> </CONFIG>

Binary file not shown.

View File

@@ -3,26 +3,26 @@ unit ucommon;
interface interface
const const
cProgramName = 'Tim2View SVN.r86 by [Lab 313] (for ' + cProgramName = 'Tim2View SVN.r88 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}
')'; ')';
cExtractedTimsDir = 'TIMS'; cExtractedFilesDir = 'FILES';
cExtractedPngsDir = 'PNGS'; cExtractedPngsDir = 'PNGS';
cMaxFileSize = $2EAEED80; cMaxFileSize = $2EAEED80;
cAutoExtractionTimFormat = '%s_%.6d_%.2db' + '.tim'; cAutoExtractionFileFormat = '%s_%.6d_%.2db' + '.%s' {tim|clt|pxl};
cAutoExtractionPngFormat = '%s_%.6d_%.2db_%.2dc' + '.png'; cAutoExtractionPngFormat = '%s_%.6d_%.2db_%.2dc' + '.png';
sStatusBarScanningFile = 'Scanning File...'; sStatusBarScanningFile = 'Scanning File...';
sStatusBarTimsExtracting = 'TIMs Extracting...'; sStatusBarFilesExtracting = 'Files Extracting...';
sStatusBarPngsExtracting = 'PNGs Extracting...'; sStatusBarPngsExtracting = 'PNGs Extracting...';
sStatusBarExtracted = 'Extracted Successfully!'; sStatusBarExtracted = 'Extracted Successfully!';
sStatusBarParsingResult = 'Parsing Result...'; sStatusBarParsingResult = 'Parsing Result...';
sScanResultGood = 'Scan completed!'; sScanResultGood = 'Scan completed!';
sSelectDirCaption = 'Please, select directory for scan...'; sSelectDirCaption = 'Please, select directory for scan...';
sThisTimHasNoCLUT = 'No CLUT'; sThisFileHasNoCLUT = 'No CLUT';
type type
TBytesArray = array [0 .. cMaxFileSize - 1] of byte; TBytesArray = array [0 .. cMaxFileSize - 1] of byte;

View File

@@ -219,7 +219,7 @@ begin
case TIM^.HEAD^.bBPP of case TIM^.HEAD^.bBPP of
cTIM4C, cTIM4NC, cTIM8C, cTIM8NC: cTIM4C, cTIM4NC, cTIM8C, cTIM8NC:
Image^.Pixels[X - 1, Y - 1] := INDEXES^[IDX] mod COLORS; Image^.Pixels[X - 1, Y - 1] := INDEXES^[IDX] mod COLORS;
cTIM16C, cTIM16NC, cTIMMix: cTIM16C, cTIM16NC, cTIMMixC, cTIMMixNC:
begin begin
CW := 0; CW := 0;
Move(INDEXES^[IDX], CW, 2); Move(INDEXES^[IDX], CW, 2);

141
umain.lfm
View File

@@ -9,7 +9,7 @@ object frmMain: TfrmMain
VertScrollBar.Range = 344 VertScrollBar.Range = 344
ActiveControl = pnlList ActiveControl = pnlList
AllowDropFiles = True AllowDropFiles = True
ClientHeight = 643 ClientHeight = 648
ClientWidth = 790 ClientWidth = 790
Color = clBtnFace Color = clBtnFace
Font.Color = clWindowText Font.Color = clWindowText
@@ -494,11 +494,11 @@ object frmMain: TfrmMain
OnCreate = FormCreate OnCreate = FormCreate
OnDropFiles = FormDropFiles OnDropFiles = FormDropFiles
Position = poScreenCenter Position = poScreenCenter
LCLVersion = '1.2.2.0' LCLVersion = '1.4.0.2'
object pnlStatus: TPanel object pnlStatus: TPanel
Left = 0 Left = 0
Height = 30 Height = 30
Top = 613 Top = 618
Width = 790 Width = 790
Align = alBottom Align = alBottom
BevelOuter = bvLowered BevelOuter = bvLowered
@@ -538,13 +538,13 @@ object frmMain: TfrmMain
end end
object cbbFiles: TComboBox object cbbFiles: TComboBox
Left = 0 Left = 0
Height = 28 Height = 21
Top = 0 Top = 0
Width = 790 Width = 790
Align = alTop Align = alTop
DropDownCount = 30 DropDownCount = 30
Enabled = False Enabled = False
ItemHeight = 0 ItemHeight = 13
OnChange = actChangeFileExecute OnChange = actChangeFileExecute
OnCloseUp = actReturnFocusExecute OnCloseUp = actReturnFocusExecute
Style = csDropDownList Style = csDropDownList
@@ -552,33 +552,33 @@ object frmMain: TfrmMain
end end
object pnlMain: TPanel object pnlMain: TPanel
Left = 0 Left = 0
Height = 585 Height = 597
Top = 28 Top = 21
Width = 790 Width = 790
Align = alClient Align = alClient
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 585 ClientHeight = 597
ClientWidth = 790 ClientWidth = 790
TabOrder = 1 TabOrder = 1
object splMain: TSplitter object splMain: TSplitter
Left = 253 Left = 253
Height = 585 Height = 597
Top = 0 Top = 0
Width = 5 Width = 5
end end
object pnlList: TPanel object pnlList: TPanel
Left = 0 Left = 0
Height = 585 Height = 597
Top = 0 Top = 0
Width = 253 Width = 253
Align = alLeft Align = alLeft
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 585 ClientHeight = 597
ClientWidth = 253 ClientWidth = 253
TabOrder = 0 TabOrder = 0
object lvList: TListView object lvList: TListView
Left = 0 Left = 0
Height = 372 Height = 384
Top = 28 Top = 28
Width = 253 Width = 253
Align = alClient Align = alClient
@@ -586,25 +586,31 @@ object frmMain: TfrmMain
item item
AutoSize = True AutoSize = True
Caption = '# / 0' Caption = '# / 0'
Width = 41 Width = 249
end end
item item
Alignment = taCenter Alignment = taCenter
AutoSize = True AutoSize = True
Caption = 'BPP' Caption = 'BPP'
Width = 35 Width = 30
end end
item item
Alignment = taCenter Alignment = taCenter
AutoSize = True AutoSize = True
Caption = 'CLUTs' Caption = 'CLUTs'
Width = 47 Width = 42
end
item
Alignment = taCenter
AutoSize = True
Caption = 'Type'
Width = 37
end end
item item
Alignment = taCenter Alignment = taCenter
AutoSize = True AutoSize = True
Caption = 'W x H' Caption = 'W x H'
Width = 128 Width = 41
end> end>
ColumnClick = False ColumnClick = False
OwnerData = True OwnerData = True
@@ -633,7 +639,7 @@ object frmMain: TfrmMain
Height = 26 Height = 26
Top = 1 Top = 1
Width = 100 Width = 100
Action = actExtractPNGs Action = actExtractPngs
Align = alRight Align = alRight
TabOrder = 0 TabOrder = 0
end end
@@ -642,7 +648,7 @@ object frmMain: TfrmMain
Height = 26 Height = 26
Top = 1 Top = 1
Width = 100 Width = 100
Action = actExtractTIMs Action = actExtractFiles
Align = alLeft Align = alLeft
TabOrder = 1 TabOrder = 1
end end
@@ -650,7 +656,7 @@ object frmMain: TfrmMain
object tblTimInfo: TStringGrid object tblTimInfo: TStringGrid
Left = 0 Left = 0
Height = 185 Height = 185
Top = 400 Top = 412
Width = 253 Width = 253
Align = alBottom Align = alBottom
AutoEdit = False AutoEdit = False
@@ -706,32 +712,32 @@ object frmMain: TfrmMain
end end
object pnlImage: TPanel object pnlImage: TPanel
Left = 258 Left = 258
Height = 585 Height = 597
Top = 0 Top = 0
Width = 532 Width = 532
Align = alClient Align = alClient
BevelOuter = bvLowered BevelOuter = bvLowered
ClientHeight = 585 ClientHeight = 597
ClientWidth = 532 ClientWidth = 532
Color = clBtnFace Color = clBtnFace
ParentColor = False ParentColor = False
TabOrder = 1 TabOrder = 1
object pnlImageOptions: TPanel object pnlImageOptions: TPanel
Left = 1 Left = 1
Height = 32 Height = 27
Top = 552 Top = 569
Width = 530 Width = 530
Align = alBottom Align = alBottom
AutoSize = True AutoSize = True
BevelOuter = bvLowered BevelOuter = bvLowered
ClientHeight = 32 ClientHeight = 27
ClientWidth = 530 ClientWidth = 530
Color = clBtnFace Color = clBtnFace
ParentColor = False ParentColor = False
TabOrder = 0 TabOrder = 0
object btnShowClut: TButton object btnShowClut: TButton
Left = 476 Left = 476
Height = 28 Height = 23
Top = 2 Top = 2
Width = 52 Width = 52
Align = alRight Align = alRight
@@ -742,12 +748,12 @@ object frmMain: TfrmMain
end end
object cbbBitMode: TComboBox object cbbBitMode: TComboBox
Left = 2 Left = 2
Height = 28 Height = 21
Top = 2 Top = 2
Width = 159 Width = 159
Align = alLeft Align = alLeft
BorderSpacing.Around = 1 BorderSpacing.Around = 1
ItemHeight = 0 ItemHeight = 13
ItemIndex = 0 ItemIndex = 0
Items.Strings = ( Items.Strings = (
'Real' 'Real'
@@ -766,12 +772,12 @@ object frmMain: TfrmMain
end end
object cbbTranspMode: TComboBox object cbbTranspMode: TComboBox
Left = 162 Left = 162
Height = 28 Height = 21
Top = 2 Top = 2
Width = 150 Width = 150
Align = alLeft Align = alLeft
BorderSpacing.Around = 1 BorderSpacing.Around = 1
ItemHeight = 0 ItemHeight = 13
ItemIndex = 1 ItemIndex = 1
Items.Strings = ( Items.Strings = (
'Full transparence' 'Full transparence'
@@ -787,13 +793,13 @@ object frmMain: TfrmMain
end end
object cbbCLUT: TComboBox object cbbCLUT: TComboBox
Left = 366 Left = 366
Height = 28 Height = 21
Top = 2 Top = 2
Width = 109 Width = 109
Align = alRight Align = alRight
BorderSpacing.Around = 1 BorderSpacing.Around = 1
DropDownCount = 16 DropDownCount = 16
ItemHeight = 0 ItemHeight = 13
OnChange = actChangeClutIdxExecute OnChange = actChangeClutIdxExecute
Style = csDropDownList Style = csDropDownList
TabOrder = 3 TabOrder = 3
@@ -802,7 +808,7 @@ object frmMain: TfrmMain
object pnlClut: TPanel object pnlClut: TPanel
Left = 1 Left = 1
Height = 192 Height = 192
Top = 360 Top = 377
Width = 530 Width = 530
Align = alBottom Align = alBottom
BevelOuter = bvLowered BevelOuter = bvLowered
@@ -814,7 +820,7 @@ object frmMain: TfrmMain
Visible = False Visible = False
object grdClut: TDrawGrid object grdClut: TDrawGrid
Left = 1 Left = 1
Height = 125 Height = 138
Top = 1 Top = 1
Width = 528 Width = 528
Align = alClient Align = alClient
@@ -839,8 +845,8 @@ object frmMain: TfrmMain
end end
object lblClutHint: TLabel object lblClutHint: TLabel
Left = 1 Left = 1
Height = 65 Height = 52
Top = 126 Top = 139
Width = 528 Width = 528
Align = alBottom Align = alBottom
Alignment = taCenter Alignment = taCenter
@@ -852,7 +858,7 @@ object frmMain: TfrmMain
end end
object imgTim: TImage object imgTim: TImage
Left = 1 Left = 1
Height = 359 Height = 376
Top = 1 Top = 1
Width = 530 Width = 530
AntialiasingMode = amOff AntialiasingMode = amOff
@@ -895,13 +901,13 @@ object frmMain: TfrmMain
Action = actExit Action = actExit
end end
end end
object mnTIM: TMenuItem object mnImage: TMenuItem
Caption = '&TIM' Caption = '&Image'
object mnSaveTIM: TMenuItem object mnSaveTIM: TMenuItem
Action = actExtractTim Action = actExtractFile
end end
object mnReplaceIn: TMenuItem object mnReplaceIn: TMenuItem
Action = actReplaceTim Action = actReplaceFile
end end
object MenuItem1: TMenuItem object MenuItem1: TMenuItem
Caption = '-' Caption = '-'
@@ -916,13 +922,14 @@ object frmMain: TfrmMain
object mnOptions: TMenuItem object mnOptions: TMenuItem
Caption = '&Options' Caption = '&Options'
object mnAssociate: TMenuItem object mnAssociate: TMenuItem
Action = actAssocTims Action = actAddToSendto
AutoCheck = True
end end
object N8: TMenuItem object N8: TMenuItem
Caption = '-' Caption = '-'
end end
object mnShowTimInfo: TMenuItem object mnShowTimInfo: TMenuItem
Action = actShowTimInfo Action = actShowFileInfo
AutoCheck = True AutoCheck = True
ShowAlwaysCheckable = True ShowAlwaysCheckable = True
end end
@@ -958,10 +965,11 @@ object frmMain: TfrmMain
left = 672 left = 672
top = 112 top = 112
end end
object dlgSaveTIM: TSaveDialog object dlgSaveFile: TSaveDialog
Title = 'Please, select where to save TIM file...' Title = 'Please, select where to save TIM file...'
DefaultExt = '.tim' DefaultExt = '.tim'
Filter = 'PSX TIM Files (*.tim)|*.tim|All Files (*.*)|*.*' Filter = 'PSX TIM Files (*.tim)|*.tim|PSX CLT Files (*.clt)|*.clt|PSX PXL Files (*.pxl)|*.pxl|All Files (*.*)|*.*'
FilterIndex = 0
Options = [ofOverwritePrompt, ofHideReadOnly, ofNoChangeDir, ofNoNetworkButton, ofEnableSizing] Options = [ofOverwritePrompt, ofHideReadOnly, ofNoChangeDir, ofNoNetworkButton, ofEnableSizing]
left = 592 left = 592
top = 112 top = 112
@@ -1021,9 +1029,9 @@ object frmMain: TfrmMain
OnExecute = actExitExecute OnExecute = actExitExecute
ShortCut = 121 ShortCut = 121
end end
object actExtractTim: TAction object actExtractFile: TAction
Caption = '&Extract TIM...' Caption = '&Extract File...'
OnExecute = actExtractTimExecute OnExecute = actExtractFileExecute
ShortCut = 113 ShortCut = 113
end end
object actPngExport: TAction object actPngExport: TAction
@@ -1036,9 +1044,9 @@ object frmMain: TfrmMain
OnExecute = actPngImportExecute OnExecute = actPngImportExecute
ShortCut = 116 ShortCut = 116
end end
object actReplaceTim: TAction object actReplaceFile: TAction
Caption = '&Replace TIM...' Caption = '&Replace File...'
OnExecute = actReplaceTimExecute OnExecute = actReplaceFileExecute
ShortCut = 114 ShortCut = 114
end end
object actOpenRepo: TAction object actOpenRepo: TAction
@@ -1058,18 +1066,19 @@ object frmMain: TfrmMain
Caption = '&Stretch Image' Caption = '&Stretch Image'
OnExecute = actStretchExecute OnExecute = actStretchExecute
end end
object actAssocTims: TAction object actAddToSendto: TAction
Caption = '&Open TIMs with T2V' AutoCheck = True
OnExecute = actAssocTimsExecute Caption = '&SendTo Shortcut for Tim2View'
OnExecute = actAddToSendtoExecute
end end
object actExtractTIMs: TAction object actExtractFiles: TAction
Caption = 'Extract all &TIMs' Caption = 'Extract all &Files'
OnExecute = actExtractTIMsExecute OnExecute = actExtractFilesExecute
ShortCut = 8305 ShortCut = 8305
end end
object actExtractPNGs: TAction object actExtractPngs: TAction
Caption = '&Extract all PNGs' Caption = '&Extract all PNGs'
OnExecute = actExtractPNGsExecute OnExecute = actExtractPngsExecute
ShortCut = 8307 ShortCut = 8307
end end
object actChangeClutIdx: TAction object actChangeClutIdx: TAction
@@ -1090,20 +1099,20 @@ object frmMain: TfrmMain
Caption = '&Background Color' Caption = '&Background Color'
OnExecute = actChangeBackColorExecute OnExecute = actChangeBackColorExecute
end end
object actShowTimInfo: TAction object actShowFileInfo: TAction
AutoCheck = True AutoCheck = True
Caption = '&Show Tim Info' Caption = '&Show File Info'
OnExecute = actShowTimInfoExecute OnExecute = actShowFileInfoExecute
end end
end end
object pmList: TPopupMenu object pmList: TPopupMenu
left = 432 left = 432
top = 112 top = 112
object ExtractTIM1: TMenuItem object ExtractTIM1: TMenuItem
Action = actExtractTim Action = actExtractFile
end end
object ReplaceTIM1: TMenuItem object ReplaceTIM1: TMenuItem
Action = actReplaceTim Action = actReplaceFile
end end
object SaveasPNG1: TMenuItem object SaveasPNG1: TMenuItem
Action = actPngExport Action = actPngExport
@@ -1112,10 +1121,10 @@ object frmMain: TfrmMain
Caption = '-' Caption = '-'
end end
object mnExtractAllTims2: TMenuItem object mnExtractAllTims2: TMenuItem
Action = actExtractTIMs Action = actExtractFiles
end end
object mnExtractAllPngs2: TMenuItem object mnExtractAllPngs2: TMenuItem
Action = actExtractPNGs Action = actExtractPngs
end end
end end
object pmImage: TPopupMenu object pmImage: TPopupMenu
@@ -1125,7 +1134,7 @@ object frmMain: TfrmMain
Action = actPngExport Action = actPngExport
end end
object mnSaveAsTim: TMenuItem object mnSaveAsTim: TMenuItem
Action = actExtractTim Action = actExtractFile
end end
object N5: TMenuItem object N5: TMenuItem
Caption = '-' Caption = '-'

View File

@@ -18,22 +18,22 @@ type
TfrmMain = class(TForm) TfrmMain = class(TForm)
actAbout: TAction; actAbout: TAction;
actAssocTims: TAction; actAddToSendto: TAction;
actChangeClutIdx: TAction; actChangeClutIdx: TAction;
actCloseFile: TAction; actCloseFile: TAction;
actCloseFiles: TAction; actCloseFiles: TAction;
actExit: TAction; actExit: TAction;
actExtractPNGs: TAction; actExtractPngs: TAction;
actExtractTim: TAction; actExtractFile: TAction;
actExtractTIMs: TAction; actExtractFiles: TAction;
actChangeFile: TAction; actChangeFile: TAction;
actChangeBackColor: TAction; actChangeBackColor: TAction;
actShowTimInfo: TAction; actShowFileInfo: TAction;
actPngImport: TAction; actPngImport: TAction;
actStopScan: TAction; actStopScan: TAction;
actOpenLab: TAction; actOpenLab: TAction;
actOpenRepo: TAction; actOpenRepo: TAction;
actReplaceTim: TAction; actReplaceFile: TAction;
actReturnFocus: TAction; actReturnFocus: TAction;
actScanDir: TAction; actScanDir: TAction;
actScanFile: TAction; actScanFile: TAction;
@@ -51,7 +51,7 @@ type
dlgColor: TColorDialog; dlgColor: TColorDialog;
dlgOpenFile: TOpenDialog; dlgOpenFile: TOpenDialog;
dlgSavePNG: TSavePictureDialog; dlgSavePNG: TSavePictureDialog;
dlgSaveTIM: TSaveDialog; dlgSaveFile: TSaveDialog;
ExtractTIM1: TMenuItem; ExtractTIM1: TMenuItem;
grdClut: TDrawGrid; grdClut: TDrawGrid;
imgTim: TImage; imgTim: TImage;
@@ -87,7 +87,7 @@ type
mnSite: TMenuItem; mnSite: TMenuItem;
mnStretch: TMenuItem; mnStretch: TMenuItem;
mnSVN: TMenuItem; mnSVN: TMenuItem;
mnTIM: TMenuItem; mnImage: TMenuItem;
N1: TMenuItem; N1: TMenuItem;
N3: TMenuItem; N3: TMenuItem;
N5: TMenuItem; N5: TMenuItem;
@@ -108,24 +108,24 @@ type
splMain: TSplitter; splMain: TSplitter;
tblTimInfo: TStringGrid; tblTimInfo: TStringGrid;
procedure actAboutExecute(Sender: TObject); procedure actAboutExecute(Sender: TObject);
procedure actAssocTimsExecute(Sender: TObject); procedure actAddToSendtoExecute(Sender: TObject);
procedure actChangeBackColorExecute(Sender: TObject); procedure actChangeBackColorExecute(Sender: TObject);
procedure actChangeClutIdxExecute(Sender: TObject); procedure actChangeClutIdxExecute(Sender: TObject);
procedure actChangeFileExecute(Sender: TObject); procedure actChangeFileExecute(Sender: TObject);
procedure actCloseFileExecute(Sender: TObject); procedure actCloseFileExecute(Sender: TObject);
procedure actCloseFilesExecute(Sender: TObject); procedure actCloseFilesExecute(Sender: TObject);
procedure actExitExecute(Sender: TObject); procedure actExitExecute(Sender: TObject);
procedure actExtractPNGsExecute(Sender: TObject); procedure actExtractPngsExecute(Sender: TObject);
procedure actExtractTimExecute(Sender: TObject); procedure actExtractFileExecute(Sender: TObject);
procedure actExtractTIMsExecute(Sender: TObject); procedure actExtractFilesExecute(Sender: TObject);
procedure actOpenLabExecute(Sender: TObject); procedure actOpenLabExecute(Sender: TObject);
procedure actOpenRepoExecute(Sender: TObject); procedure actOpenRepoExecute(Sender: TObject);
procedure actPngImportExecute(Sender: TObject); procedure actPngImportExecute(Sender: TObject);
procedure actReplaceTimExecute(Sender: TObject); procedure actReplaceFileExecute(Sender: TObject);
procedure actReturnFocusExecute(Sender: TObject); procedure actReturnFocusExecute(Sender: TObject);
procedure actScanDirExecute(Sender: TObject); procedure actScanDirExecute(Sender: TObject);
procedure actScanFileExecute(Sender: TObject); procedure actScanFileExecute(Sender: TObject);
procedure actShowTimInfoExecute(Sender: TObject); procedure actShowFileInfoExecute(Sender: TObject);
procedure actStopScanExecute(Sender: TObject); procedure actStopScanExecute(Sender: TObject);
procedure actStretchExecute(Sender: TObject); procedure actStretchExecute(Sender: TObject);
procedure actPngExportExecute(Sender: TObject); procedure actPngExportExecute(Sender: TObject);
@@ -173,7 +173,7 @@ type
procedure DrawSelTim; procedure DrawSelTim;
procedure DrawSelClut; procedure DrawSelClut;
procedure SetCLUTListToNoCLUT; procedure SetCLUTListToNoCLUT;
function FormatTimName(const FileName: string; ListIdx_, BitMode: Integer): string; function FormatFileName(const FileName: string; ListIdx_, BitMode: Integer; Magic: Byte): string;
function FormatPngName(const FileName: string; ListIdx_, BitMode, Clut: Integer): string; function FormatPngName(const FileName: string; ListIdx_, BitMode, Clut: Integer): string;
procedure ShowTim; procedure ShowTim;
procedure ShowTimInfo(ShowInfo: Boolean); procedure ShowTimInfo(ShowInfo: Boolean);
@@ -212,7 +212,7 @@ begin
ScanPath(dlgOpenFile.Files.Strings[I - 1]); ScanPath(dlgOpenFile.Files.Strings[I - 1]);
end; end;
procedure TfrmMain.actShowTimInfoExecute(Sender: TObject); procedure TfrmMain.actShowFileInfoExecute(Sender: TObject);
begin begin
Settings.InfoVisible := (Sender as TAction).Checked; Settings.InfoVisible := (Sender as TAction).Checked;
tblTimInfo.Visible := (Sender as TAction).Checked; tblTimInfo.Visible := (Sender as TAction).Checked;
@@ -315,9 +315,9 @@ begin
Application.MessageBox(cProgramName + #13#10#13#10 + 'Some "about strings" should be here!:)', 'About', MB_OK + MB_ICONINFORMATION); Application.MessageBox(cProgramName + #13#10#13#10 + 'Some "about strings" should be here!:)', 'About', MB_OK + MB_ICONINFORMATION);
end; end;
procedure TfrmMain.actAssocTimsExecute(Sender: TObject); procedure TfrmMain.actAddToSendtoExecute(Sender: TObject);
begin begin
Settings.AssociateWithTims; Settings.AddToSendTo(not (Sender as TAction).Checked);
end; end;
procedure TfrmMain.actChangeBackColorExecute(Sender: TObject); procedure TfrmMain.actChangeBackColorExecute(Sender: TObject);
@@ -368,7 +368,7 @@ begin
Close; Close;
end; end;
procedure TfrmMain.actExtractPNGsExecute(Sender: TObject); procedure TfrmMain.actExtractPngsExecute(Sender: TObject);
var var
I, OFFSET, BIT_MODE, SIZE: Integer; I, OFFSET, BIT_MODE, SIZE: Integer;
FName, Path: string; FName, Path: string;
@@ -418,29 +418,30 @@ begin
pbProgress.Position := 0; pbProgress.Position := 0;
end; end;
procedure TfrmMain.actExtractTimExecute(Sender: TObject); procedure TfrmMain.actExtractFileExecute(Sender: TObject);
var var
TIM: PTIM; TIM: PTIM;
begin begin
dlgSaveTIM.FileName := FormatTimName(SelectedScanResult.ScanFile, SelectedTimIdx, SelectedTimInfo.BitMode); dlgSaveFile.FileName := FormatFileName(SelectedScanResult.ScanFile, SelectedTimIdx, SelectedTimInfo.BitMode, SelectedTimInfo.Magic);
dlgSaveFile.FilterIndex := SelectedTimInfo.Magic - cTIMMagic + 1;
if not dlgSaveTIM.Execute then Exit; if not dlgSaveFile.Execute then Exit;
TIM := SelectedTimInMode; TIM := SelectedTimInMode;
SaveTimToFile(dlgSaveTIM.FileName, TIM); SaveTimToFile(dlgSaveFile.FileName, TIM);
{$IFDEF Linux}FpChmod(dlgSaveTIM.FileName, &777);{$IFEND} {$IFDEF Linux}FpChmod(dlgSaveFile.FileName, &777);{$IFEND}
FreeTIM(TIM); FreeTIM(TIM);
end; end;
procedure TfrmMain.actExtractTIMsExecute(Sender: TObject); procedure TfrmMain.actExtractFilesExecute(Sender: TObject);
var var
I, OFFSET, BIT_MODE, SIZE: Integer; I, OFFSET, BIT_MODE, SIZE, MAGIC: Integer;
FName, Path: string; FName, Path: string;
IsImage: Boolean; IsImage: Boolean;
TIM: PTIM; TIM: PTIM;
ScanTim: TTimInfo; ScanTim: TTimInfo;
begin begin
lblStatus.Caption := sStatusBarTimsExtracting; lblStatus.Caption := sStatusBarFilesExtracting;
FName := SelectedScanResult.ScanFile; FName := SelectedScanResult.ScanFile;
IsImage := SelectedScanResult.IsImage; IsImage := SelectedScanResult.IsImage;
@@ -453,14 +454,15 @@ begin
OFFSET := ScanTim.Position; OFFSET := ScanTim.Position;
SIZE := ScanTim.Size; SIZE := ScanTim.Size;
BIT_MODE := ScanTim.BitMode; BIT_MODE := ScanTim.BitMode;
MAGIC := ScanTim.Magic;
Path := SysToUTF8(IncludeTrailingPathDelimiter(ExtractFilePath(ParamStrUTF8(0)) + cExtractedTimsDir)); Path := SysToUTF8(IncludeTrailingPathDelimiter(ExtractFilePath(ParamStrUTF8(0)) + cExtractedFilesDir));
CreateDirUTF8(Path); CreateDirUTF8(Path);
Path := IncludeTrailingPathDelimiter(Path + ExtractFileName(FName)); Path := IncludeTrailingPathDelimiter(Path + ExtractFileName(FName));
CreateDirUTF8(Path); CreateDirUTF8(Path);
TIM := LoadTimFromFile(FName, OFFSET, IsImage, SIZE); TIM := LoadTimFromFile(FName, OFFSET, IsImage, SIZE);
Path := Path + FormatTimName(FName, I - 1, BIT_MODE); Path := Path + FormatFileName(FName, I - 1, BIT_MODE, MAGIC);
SaveTimToFile(Path, TIM); SaveTimToFile(Path, TIM);
{$IFDEF Linux}FpChmod(Path, &777);{$IFEND} {$IFDEF Linux}FpChmod(Path, &777);{$IFEND}
FreeTIM(TIM); FreeTIM(TIM);
@@ -503,7 +505,7 @@ begin
Dispose(Image); Dispose(Image);
end; end;
procedure TfrmMain.actReplaceTimExecute(Sender: TObject); procedure TfrmMain.actReplaceFileExecute(Sender: TObject);
var var
ScanRes: TScanResult; ScanRes: TScanResult;
begin begin
@@ -555,12 +557,14 @@ begin
cbbBitMode.Tag := NativeInt($FF); cbbBitMode.Tag := NativeInt($FF);
actAddToSendto.Checked := Settings.SendToShortcutExists;
actStretch.Checked := Settings.StretchMode; actStretch.Checked := Settings.StretchMode;
cbbTranspMode.ItemIndex := Settings.TranspMode; cbbTranspMode.ItemIndex := Settings.TranspMode;
LastDir := Settings.LastDir; LastDir := Settings.LastDir;
cbbBitMode.ItemIndex := Settings.BitMode; cbbBitMode.ItemIndex := Settings.BitMode;
pnlImage.Color := Settings.BackColor; pnlImage.Color := Settings.BackColor;
actShowTimInfo.Checked := Settings.InfoVisible; actShowFileInfo.Checked := Settings.InfoVisible;
ScanThreads := TScanThreadList.Create(False); //False - to able scan thread remove itself from this list ScanThreads := TScanThreadList.Create(False); //False - to able scan thread remove itself from this list
ScanResults := TScanResultList.Create(False); ScanResults := TScanResultList.Create(False);
@@ -708,6 +712,7 @@ begin
Item.Caption := Format('%.6d', [Item.Index + 1]); Item.Caption := Format('%.6d', [Item.Index + 1]);
Item.SubItems.Add(Format('%.2d', [TimInfoByIdx[Item.Index].BitMode])); Item.SubItems.Add(Format('%.2d', [TimInfoByIdx[Item.Index].BitMode]));
Item.SubItems.Add(Format('%.2d', [TimInfoByIdx[Item.Index].Cluts])); Item.SubItems.Add(Format('%.2d', [TimInfoByIdx[Item.Index].Cluts]));
Item.SubItems.Add(Format('%s', [AnsiUpperCase(TIMTypeStr(TimInfoByIdx[Item.Index].Magic))]));
Item.SubItems.Add(Format('%.3dx%.3d', [W, H])); Item.SubItems.Add(Format('%.3dx%.3d', [W, H]));
end; end;
@@ -835,13 +840,13 @@ begin
actScanFile.Enabled := ScanThreads.Count = 0; actScanFile.Enabled := ScanThreads.Count = 0;
actScanDir.Enabled := ScanThreads.Count = 0; actScanDir.Enabled := ScanThreads.Count = 0;
actReplaceTim.Enabled := (lvList.Selected <> nil) and (lvList.Selected.Index <> -1); actReplaceFile.Enabled := (lvList.Selected <> nil) and (lvList.Selected.Index <> -1);
actPngExport.Enabled := (Surf^ <> nil) and actReplaceTim.Enabled; actPngExport.Enabled := (Surf^ <> nil) and actReplaceFile.Enabled;
actPngImport.Enabled := actReplaceTim.Enabled; actPngImport.Enabled := actReplaceFile.Enabled;
actExtractTim.Enabled := actReplaceTim.Enabled; actExtractFile.Enabled := actReplaceFile.Enabled;
pnlImageOptions.Enabled := actReplaceTim.Enabled; pnlImageOptions.Enabled := actReplaceFile.Enabled;
end; end;
procedure TfrmMain.ScanFinished(Sender: TObject); procedure TfrmMain.ScanFinished(Sender: TObject);
@@ -970,14 +975,14 @@ end;
procedure TfrmMain.SetCLUTListToNoCLUT; procedure TfrmMain.SetCLUTListToNoCLUT;
begin begin
cbbCLUT.Items.Clear; cbbCLUT.Items.Clear;
cbbCLUT.Items.Add(sThisTimHasNoClut); cbbCLUT.Items.Add(sThisFileHasNoClut);
cbbCLUT.ItemIndex := 0; cbbCLUT.ItemIndex := 0;
end; end;
function TfrmMain.FormatTimName(const FileName: string; ListIdx_, function TfrmMain.FormatFileName(const FileName: string; ListIdx_,
BitMode: Integer): string; BitMode: Integer; Magic: Byte): string;
begin begin
Result := Format(cAutoExtractionTimFormat, [ExtractJustName(FileName), ListIdx_ + 1, BitMode]); Result := Format(cAutoExtractionFileFormat, [ExtractJustName(FileName), ListIdx_ + 1, BitMode, TIMTypeStr(Magic)]);
end; end;
function TfrmMain.FormatPngName(const FileName: string; ListIdx_, BitMode, function TfrmMain.FormatPngName(const FileName: string; ListIdx_, BitMode,
@@ -1020,7 +1025,7 @@ begin
tblTimInfo.Cells[1, 1] := Format('0x%x', [TimInfo.Position]); tblTimInfo.Cells[1, 1] := Format('0x%x', [TimInfo.Position]);
tblTimInfo.Cells[1, 2] := Format('%d', [GetTimVersion(TIM)]); tblTimInfo.Cells[1, 2] := Format('0x%.2x', [GetTimVersion(TIM)]);
tblTimInfo.Cells[1, 3] := Format('%s', [TIMIsGoodStr(TIM)]); tblTimInfo.Cells[1, 3] := Format('%s', [TIMIsGoodStr(TIM)]);
if TIMHasCLUT(TIM) then if TIMHasCLUT(TIM) then

View File

@@ -6,6 +6,7 @@ uses fgl;
type type
TTimInfo = record TTimInfo = record
Magic: Byte;
Position: Integer; Position: Integer;
Size: Integer; Size: Integer;
Width: Integer; Width: Integer;

View File

@@ -65,6 +65,7 @@ procedure TScanThread.AddResult(TIM: PTIM);
var var
ScanTim: TTimInfo; ScanTim: TTimInfo;
begin begin
ScanTim.Magic := TIM^.HEAD^.bMagic;
ScanTim.Position := TIM^.dwTimPosition; ScanTim.Position := TIM^.dwTimPosition;
ScanTim.Size := TIM^.dwSIZE; ScanTim.Size := TIM^.dwSIZE;
ScanTim.Width := GetTimRealWidth(TIM); ScanTim.Width := GetTimRealWidth(TIM);

View File

@@ -26,11 +26,20 @@ type
function FBitModeRead(): Integer; function FBitModeRead(): Integer;
procedure FInfoVisibleWrite(Value: Boolean); procedure FInfoVisibleWrite(Value: Boolean);
function FInfoVisibleRead(): Boolean; function FInfoVisibleRead(): Boolean;
{$IFDEF windows}
function FGetSendtoShortcutPath: WideString;
procedure FCreateSendtoShortcut;
function FSendtoShortcutExists: Boolean;
{$IFEND}
public public
constructor Create(const DirPath: string); constructor Create(const DirPath: string);
destructor Destroy; override; destructor Destroy; override;
procedure AssociateWithTims; {$IFDEF windows}
procedure AddToSendTo(Delete: Boolean);
property SendToShortcutExists: Boolean read FSendtoShortcutExists;
{$IFEND}
property TranspMode: Integer read FTranspModeRead write FTranspModeWrite; property TranspMode: Integer read FTranspModeRead write FTranspModeWrite;
property StretchMode: Boolean read FStretchModeRead write FStretchModeWrite; property StretchMode: Boolean read FStretchModeRead write FStretchModeWrite;
@@ -45,44 +54,71 @@ implementation
uses FileUtil uses FileUtil
{$IFDEF windows} {$IFDEF windows}
,registry ,windows, shlobj {for special folders}, ActiveX, ComObj
{$IFEND} {$IFEND}
; ;
const sMain = 'main'; const
sMain = 'main';
sSendtoShortcut : string = 'Open in Tim2View';
{ TSettings } { TSettings }
procedure TSettings.AssociateWithTims; procedure TSettings.AddToSendTo(Delete: Boolean);
{$IFDEF windows} {$IFDEF windows}
var var
reg: TRegistry; path: string;
begin begin
reg := TRegistry.Create; if Delete then
begin
try path := UTF8Encode(FGetSendtoShortcutPath);
reg.RootKey := HKEY_CURRENT_USER; DeleteFile(PChar(Utf8ToSys(path)));
reg.OpenKey('Software\Classes\.tim', True); end
reg.WriteString('', 'TimFile'); else
reg.CloseKey; FCreateSendtoShortcut;
reg.OpenKey('Software\Classes\TimFile', True);
reg.WriteString('', 'Tim File Format');
reg.CloseKey;
reg.OpenKey('Software\Classes\TimFile\DefaultIcon', True);
reg.WriteString('', '"' + ParamStr(0) +'",0');
reg.CloseKey;
reg.OpenKey('Software\Classes\TimFile\shell\Open\Command', True);
reg.WriteString('', '"' + ParamStr(0) + '" "%1"');
reg.CloseKey;
finally
reg.Free;
end;
{$ELSE} {$ELSE}
begin begin
{$ENDIF} {$ENDIF}
end; end;
{$IFDEF windows}
function TSettings.FGetSendtoShortcutPath: WideString;
var
PIDL: PItemIDList;
InFolder: array[0..MAX_PATH] of Char;
begin
SHGetSpecialFolderLocation(0, CSIDL_SENDTO, PIDL);
SHGetPathFromIDList(PIDL, InFolder);
Result := InFolder + PathDelim + UTF8ToSys(sSendtoShortcut)+'.lnk';
end;
procedure TSettings.FCreateSendtoShortcut;
var
IObject: IUnknown;
ISLink: IShellLink;
IPFile: IPersistFile;
TargetPath: string;
begin
{ Creates an instance of IShellLink }
IObject := CreateComObject(CLSID_ShellLink);
ISLink := IObject as IShellLink;
IPFile := IObject as IPersistFile;
TargetPath := ParamStr(0);
ISLink.SetPath(pChar(TargetPath));
ISLink.SetArguments(pChar(''));
ISLink.SetWorkingDirectory(pChar(ExtractFilePath(TargetPath)));
{ Create the link }
IPFile.Save(PWChar(FGetSendtoShortcutPath), false);
end;
function TSettings.FSendtoShortcutExists: Boolean;
begin
Result := FileExists(FGetSendtoShortcutPath);
end;
{$ENDIF}
procedure TSettings.FTranspModeWrite(Value: Integer); procedure TSettings.FTranspModeWrite(Value: Integer);
begin begin
FIniFile.WriteInteger(sMain, 'TranspMode', Value); FIniFile.WriteInteger(sMain, 'TranspMode', Value);

View File

@@ -7,6 +7,9 @@ uses
const const
cTIMMagic = $10; cTIMMagic = $10;
cCLTMagic = $11;
cPXLMagic = $12;
cMagics = [cTIMMagic, cCLTMagic, cPXLMagic];
cTIM4C = $08; cTIM4C = $08;
cTIM4NC = $00; cTIM4NC = $00;
cTIM4 = [cTIM4C, cTIM4NC]; cTIM4 = [cTIM4C, cTIM4NC];
@@ -19,12 +22,16 @@ const
cTIM24C = $0B; cTIM24C = $0B;
cTIM24NC = $03; cTIM24NC = $03;
cTIM24 = [cTIM24C, cTIM24NC]; cTIM24 = [cTIM24C, cTIM24NC];
cTIMMix = $04; cTIMMixC = $0C;
cTIMMixNC = $04;
cTIMMix = [cTIMMixC, cTIMMixNC];
cTIMVersions = [$00, $01]; cTIMVersions = [$00, $01];
cTIMWrongBads = [cTIM4NC, cTIM8NC, cTIMMix]; cTIMWrongBads = [cTIM4NC, cTIM8NC];
cTIMCLUT = [cTIM4C, cTIM8C, cTIM16C, cTIM24C]; cTIMGoodCLTs = [cTIM16NC];
cTIMNOCLUT = [cTIM4NC, cTIM8NC, cTIM16NC, cTIM24NC, cTIMMix]; cTIMGoodPXLs = [cTIM4NC, cTIM8NC];
cTIMBpp = [cTIM4C, cTIM8C, cTIM16C, cTIM24C, cTIM4NC, cTIM8NC, cTIM16NC, cTIM24NC, cTIMMix]; cTIMCLUT = [cTIM4C, cTIM8C, cTIM16C, cTIM24C, cTIMMixC];
cTIMNOCLUT = [cTIM4NC, cTIM8NC, cTIM16NC, cTIM24NC, cTIMMixNC];
cTIMBpp = [cTIM4C, cTIM8C, cTIM16C, cTIM24C, cTIMMixC, cTIM4NC, cTIM8NC, cTIM16NC, cTIM24NC, cTIMMixNC];
type type
TTIMHeader = packed record // TIM Header (8 bytes) TTIMHeader = packed record // TIM Header (8 bytes)
@@ -34,7 +41,7 @@ type
bReserved2: byte; // Reserved byte 2 (1 byte) bReserved2: byte; // Reserved byte 2 (1 byte)
bBPP: Integer; // Bit per Pixel (4 bytes) bBPP: Integer; // Bit per Pixel (4 bytes)
// variants: // variants:
// [$08, $09, $0A, $0B, $02, $03, $00, $01] // [$08, $09, $0A, $0B, $0C, $00, $01, $02, $03, $04]
end; end;
PTIMHeader = ^TTIMHeader; PTIMHeader = ^TTIMHeader;
@@ -112,6 +119,7 @@ function GetTimRealWidth(TIM: PTIM): word;
function GetTimHeight(TIM: PTIM): word; function GetTimHeight(TIM: PTIM): word;
function TIMIsGood(TIM: PTIM): Boolean; function TIMIsGood(TIM: PTIM): Boolean;
function TIMIsGoodStr(TIM: PTIM): string; function TIMIsGoodStr(TIM: PTIM): string;
function TIMTypeStr(Magic: Byte): string;
function LoadTimFromBuf(BUFFER: pointer; var TIM: PTIM; var Position: Integer): Boolean; function LoadTimFromBuf(BUFFER: pointer; var TIM: PTIM; var Position: Integer): Boolean;
function LoadTimFromFile(const FileName: string; var Position: Integer; ImageScan: Boolean; dwSize: Integer): PTIM; function LoadTimFromFile(const FileName: string; var Position: Integer; ImageScan: Boolean; dwSize: Integer): PTIM;
procedure SaveTimToFile(const FileName: string; TIM: PTIM); procedure SaveTimToFile(const FileName: string; TIM: PTIM);
@@ -198,7 +206,6 @@ end;
function GetTIMCLUTSize(TIM: PTIM): Integer; function GetTIMCLUTSize(TIM: PTIM): Integer;
begin begin
Result := 0; Result := 0;
if not TIMHasCLUT(TIM) then Exit; if not TIMHasCLUT(TIM) then Exit;
Result := TIM^.CLUT^.wColorsCount * TIM^.CLUT^.wClutsCount * 2 + SizeOf(TCLUTHeader); Result := TIM^.CLUT^.wColorsCount * TIM^.CLUT^.wClutsCount * 2 + SizeOf(TCLUTHeader);
end; end;
@@ -220,7 +227,7 @@ end;
function CheckMagic(TIM: PTIM): Boolean; function CheckMagic(TIM: PTIM): Boolean;
begin begin
Result := (TIM^.HEAD^.bMagic = cTIMMagic); Result := (TIM^.HEAD^.bMagic in cMagics);
end; end;
function CheckBpp(TIM: PTIM): Boolean; function CheckBpp(TIM: PTIM): Boolean;
@@ -263,7 +270,7 @@ begin
case TIM^.HEAD^.bBPP of case TIM^.HEAD^.bBPP of
cTIM4C, cTIM4NC: Result := (TIM^.IMAGE^.wWidth * 4) and $FFFF; cTIM4C, cTIM4NC: Result := (TIM^.IMAGE^.wWidth * 4) and $FFFF;
cTIM8C, cTIM8NC: Result := (TIM^.IMAGE^.wWidth * 2) and $FFFF; cTIM8C, cTIM8NC: Result := (TIM^.IMAGE^.wWidth * 2) and $FFFF;
cTIM16C, cTIM16NC, cTIMMix: Result := TIM^.IMAGE^.wWidth; cTIM16C, cTIM16NC, cTIMMixC, cTIMMixNC: Result := TIM^.IMAGE^.wWidth;
cTIM24C, cTIM24NC: Result := (Round(TIM^.IMAGE^.wWidth * 2 / 3)) and $FFFF; cTIM24C, cTIM24NC: Result := (Round(TIM^.IMAGE^.wWidth * 2 / 3)) and $FFFF;
else else
Result := 0; Result := 0;
@@ -280,6 +287,11 @@ begin
Result := CheckCLUTColors(TIM) and CheckCLUTCount(TIM) and CheckCLUTVramX(TIM) and CheckCLUTVramY(TIM); Result := CheckCLUTColors(TIM) and CheckCLUTCount(TIM) and CheckCLUTVramX(TIM) and CheckCLUTVramY(TIM);
end; end;
function TIMIsNotWrongBad(TIM: PTIM): Boolean;
begin
Result := (not(TIM^.HEAD^.bBPP in cTIMWrongBads)) or TIMIsGood(TIM);
end;
function CheckTIMSize(TIM: PTIM): Boolean; function CheckTIMSize(TIM: PTIM): Boolean;
begin begin
Result := (GetTIMSize(TIM) <= cTIMMaxSize); Result := (GetTIMSize(TIM) <= cTIMMaxSize);
@@ -313,8 +325,26 @@ end;
function CheckIMAGE(TIM: PTIM): Boolean; function CheckIMAGE(TIM: PTIM): Boolean;
begin begin
Result := CheckIMAGEWidth(TIM) and CheckIMAGEHeight(TIM) and CheckIMAGEVramX(TIM) and CheckIMAGEVramY(TIM); Result := CheckIMAGEWidth(TIM) and CheckIMAGEHeight(TIM) and CheckIMAGEVramX(TIM) and CheckIMAGEVramY(TIM);
end;
Result := Result and ((not(TIM^.HEAD^.bBPP in cTIMWrongBads)) or TIMIsGood(TIM)); function CheckTIM(TIM: PTIM): Boolean;
begin
Result := (TIM^.HEAD^.bMagic = cTIMMagic);
end;
function CheckCLT(TIM: PTIM): Boolean;
begin
Result := (TIM^.HEAD^.bMagic = cCLTMagic) and (TIM^.HEAD^.bBPP in cTIMGoodCLTs);
end;
function CheckPXL(TIM: PTIM): Boolean;
begin
Result := (TIM^.HEAD^.bMagic = cPXLMagic) and (TIM^.HEAD^.bBPP in cTIMGoodPXLs);
end;
function CheckTimCltPxl(TIM: PTIM): Boolean;
begin
Result := (CheckTIM(TIM) or CheckCLT(TIM) or CheckPXL(TIM)) and CheckIMAGE(TIM) and TIMIsNotWrongBad(TIM);
end; end;
procedure ClearTIM(TIM: PTIM); procedure ClearTIM(TIM: PTIM);
@@ -330,6 +360,17 @@ begin
if TIMIsGood(TIM) then Result := 'Yes' else Result := 'No'; if TIMIsGood(TIM) then Result := 'Yes' else Result := 'No';
end; end;
function TIMTypeStr(Magic: Byte): string;
begin
case Magic of
cTIMMagic: Result := 'tim';
cCLTMagic: Result := 'clt';
cPXLMagic: Result := 'pxl';
else
Result := 'unk';
end;
end;
function LoadTimFromBuf(BUFFER: pointer; var TIM: PTIM; var Position: Integer): Boolean; function LoadTimFromBuf(BUFFER: pointer; var TIM: PTIM; var Position: Integer): Boolean;
var var
P: Integer; P: Integer;
@@ -356,7 +397,7 @@ begin
Move(PBytesArray(BUFFER)^[P], TIM^.IMAGE^, SizeOf(TIMAGEHeader)); Move(PBytesArray(BUFFER)^[P], TIM^.IMAGE^, SizeOf(TIMAGEHeader));
if not CheckIMAGE(TIM) then Exit; if not CheckTimCltPxl(TIM) then Exit;
if not CheckTIMSize(TIM) then Exit; if not CheckTIMSize(TIM) then Exit;
TIM^.dwSize := GetTIMSize(TIM); TIM^.dwSize := GetTIMSize(TIM);
@@ -527,7 +568,7 @@ begin
Result := 24; Result := 24;
Exit; Exit;
end; end;
if (TIM^.HEAD^.bBPP = cTIMMix) then if (TIM^.HEAD^.bBPP in cTIMMix) then
begin begin
Result := 16; Result := 16;
Exit; Exit;