Debug fixes. Not for update.

This commit is contained in:
meffi@lab313.ru
2014-04-26 12:59:46 +00:00
parent b954de5b12
commit 5d477f135b
7 changed files with 314 additions and 72 deletions

View File

@@ -24,7 +24,7 @@
<AutoIncrementBuild Value="True"/> <AutoIncrementBuild Value="True"/>
<MajorVersionNr Value="1"/> <MajorVersionNr Value="1"/>
<RevisionNr Value="67"/> <RevisionNr Value="67"/>
<BuildNr Value="4"/> <BuildNr Value="5"/>
<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="1"> <BuildModes Count="1">
@@ -131,7 +131,6 @@
</Target> </Target>
<SearchPaths> <SearchPaths>
<IncludeFiles Value="$(ProjOutDir);bgrabitmap"/> <IncludeFiles Value="$(ProjOutDir);bgrabitmap"/>
<Libraries Value="$(LazarusDir)\..\binLibraries\$(TargetCPU)-$(TargetOS)"/>
<OtherUnitFiles Value="bgrabitmap"/> <OtherUnitFiles Value="bgrabitmap"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths> </SearchPaths>
@@ -140,7 +139,17 @@
<UseAnsiStrings Value="False"/> <UseAnsiStrings Value="False"/>
</SyntaxOptions> </SyntaxOptions>
</Parsing> </Parsing>
<CodeGeneration>
<Checks>
<RangeChecks Value="True"/>
<OverflowChecks Value="True"/>
</Checks>
<VerifyObjMethodCallValidity Value="True"/>
</CodeGeneration>
<Linking> <Linking>
<Debugging>
<UseHeaptrc Value="True"/>
</Debugging>
<Options> <Options>
<Win32> <Win32>
<GraphicApplication Value="True"/> <GraphicApplication Value="True"/>

View File

@@ -4,15 +4,15 @@
<PathDelim Value="\"/> <PathDelim Value="\"/>
<Version Value="9"/> <Version Value="9"/>
<BuildModes Active="Default"/> <BuildModes Active="Default"/>
<Units Count="15"> <Units Count="19">
<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="15"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<CursorPos X="46" Y="14"/> <CursorPos X="46" Y="15"/>
<UsageCount Value="816"/> <UsageCount Value="816"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit0> </Unit0>
@@ -23,11 +23,10 @@
<HasResources Value="True"/> <HasResources Value="True"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<UnitName Value="umain"/> <UnitName Value="umain"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="0"/> <EditorIndex Value="0"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="384"/> <TopLine Value="912"/>
<CursorPos X="28" Y="384"/> <CursorPos X="48" Y="918"/>
<UsageCount Value="816"/> <UsageCount Value="816"/>
<Loaded Value="True"/> <Loaded Value="True"/>
<LoadedDesigner Value="True"/> <LoadedDesigner Value="True"/>
@@ -66,8 +65,8 @@
<UnitName Value="utim"/> <UnitName Value="utim"/>
<EditorIndex Value="7"/> <EditorIndex Value="7"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="193"/> <TopLine Value="130"/>
<CursorPos X="67" Y="195"/> <CursorPos X="1" Y="148"/>
<UsageCount Value="816"/> <UsageCount Value="816"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit5> </Unit5>
@@ -77,8 +76,8 @@
<UnitName Value="ucdimage"/> <UnitName Value="ucdimage"/>
<EditorIndex Value="1"/> <EditorIndex Value="1"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="129"/> <TopLine Value="189"/>
<CursorPos X="74" Y="143"/> <CursorPos X="1" Y="204"/>
<UsageCount Value="816"/> <UsageCount Value="816"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit6> </Unit6>
@@ -97,10 +96,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="16"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="16"/> <TopLine Value="51"/>
<CursorPos X="64" Y="25"/> <CursorPos X="1" Y="67"/>
<UsageCount Value="816"/> <UsageCount Value="816"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit8> </Unit8>
@@ -110,8 +109,8 @@
<UnitName Value="uscanthread"/> <UnitName Value="uscanthread"/>
<EditorIndex Value="6"/> <EditorIndex Value="6"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1"/> <TopLine Value="79"/>
<CursorPos X="53" Y="88"/> <CursorPos X="76" Y="98"/>
<UsageCount Value="816"/> <UsageCount Value="816"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit9> </Unit9>
@@ -130,10 +129,11 @@
<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="8"/> <EditorIndex Value="8"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="91"/> <TopLine Value="177"/>
<CursorPos X="36" Y="23"/> <CursorPos X="51" Y="198"/>
<UsageCount Value="816"/> <UsageCount Value="816"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit11> </Unit11>
@@ -141,12 +141,15 @@
<Filename Value="bgrabitmap\bgrabitmap.pas"/> <Filename Value="bgrabitmap\bgrabitmap.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="BGRABitmap"/> <UnitName Value="BGRABitmap"/>
<WindowIndex Value="0"/>
<TopLine Value="54"/>
<CursorPos X="3" Y="69"/>
<UsageCount Value="816"/> <UsageCount Value="816"/>
</Unit12> </Unit12>
<Unit13> <Unit13>
<Filename Value="todos.inc"/> <Filename Value="todos.inc"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<EditorIndex Value="10"/> <EditorIndex Value="14"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<CursorPos X="31" Y="2"/> <CursorPos X="31" Y="2"/>
@@ -157,20 +160,60 @@
<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="10"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<CursorPos X="26" Y="12"/> <CursorPos X="76" Y="22"/>
<UsageCount Value="29"/> <UsageCount Value="41"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit14> </Unit14>
<Unit15>
<Filename Value="bgrabitmap\bgrabitmaptypes.pas"/>
<UnitName Value="BGRABitmapTypes"/>
<EditorIndex Value="12"/>
<WindowIndex Value="0"/>
<TopLine Value="1336"/>
<CursorPos X="1" Y="1343"/>
<UsageCount Value="16"/>
<Loaded Value="True"/>
</Unit15>
<Unit16>
<Filename Value="bgrabitmap\bgradefaultbitmap.pas"/>
<UnitName Value="BGRADefaultBitmap"/>
<EditorIndex Value="9"/>
<WindowIndex Value="0"/>
<TopLine Value="548"/>
<CursorPos X="1" Y="570"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
</Unit16>
<Unit17>
<Filename Value="C:\Lazarus\fpc\2.6.4\source\packages\fcl-image\src\fpreadpng.pp"/>
<UnitName Value="FPReadPNG"/>
<EditorIndex Value="11"/>
<WindowIndex Value="0"/>
<TopLine Value="241"/>
<CursorPos X="46" Y="17"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit17>
<Unit18>
<Filename Value="bgrabitmap\bgrareadpng.pas"/>
<UnitName Value="BGRAReadPng"/>
<EditorIndex Value="13"/>
<WindowIndex Value="0"/>
<TopLine Value="141"/>
<CursorPos X="1" Y="161"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit18>
</Units> </Units>
<General> <General>
<ActiveWindowIndexAtStart Value="0"/> <ActiveWindowIndexAtStart Value="0"/>
</General> </General>
</ProjectSession> </ProjectSession>
<Debugging> <Debugging>
<BreakPoints Count="1"> <BreakPoints Count="4">
<Item1> <Item1>
<Kind Value="bpkSource"/> <Kind Value="bpkSource"/>
<WatchScope Value="wpsLocal"/> <WatchScope Value="wpsLocal"/>
@@ -178,6 +221,27 @@
<Source Value="c:\Lazarus\fpc\2.6.2\source\packages\fcl-image\src\fpimage.inc"/> <Source Value="c:\Lazarus\fpc\2.6.2\source\packages\fcl-image\src\fpimage.inc"/>
<Line Value="350"/> <Line Value="350"/>
</Item1> </Item1>
<Item2>
<Kind Value="bpkSource"/>
<WatchScope Value="wpsLocal"/>
<WatchKind Value="wpkWrite"/>
<Source Value="umain.pas"/>
<Line Value="503"/>
</Item2>
<Item3>
<Kind Value="bpkSource"/>
<WatchScope Value="wpsLocal"/>
<WatchKind Value="wpkWrite"/>
<Source Value="c:\Lazarus\fpc\2.6.2\source\packages\fcl-image\src\fppalette.inc"/>
<Line Value="159"/>
</Item3>
<Item4>
<Kind Value="bpkSource"/>
<WatchScope Value="wpsLocal"/>
<WatchKind Value="wpkWrite"/>
<Source Value="udrawtim.pas"/>
<Line Value="258"/>
</Item4>
</BreakPoints> </BreakPoints>
</Debugging> </Debugging>
<EditorMacros Count="0"/> <EditorMacros Count="0"/>

Binary file not shown.

View File

@@ -11,7 +11,8 @@ type
PDrawGrid = ^TDrawGrid; PDrawGrid = ^TDrawGrid;
procedure Tim2Png(TIM: PTIM; CLUT_NUM: Integer; Surf: PDrawSurf; TranspMode: Byte; ForExport: Boolean); procedure Tim2Png(TIM: PTIM; CLUT_NUM: Integer; Surf: PDrawSurf; TranspMode: Byte);
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);
procedure ClearCanvas(ACanvas: PCanvas; Rect: TRect); procedure ClearCanvas(ACanvas: PCanvas; Rect: TRect);
@@ -52,7 +53,23 @@ begin
end; end;
end; end;
procedure PrepareClut(TIM: PTIM; CLUT_NUM: Integer; Pal: PFPPalette; TranspMode: Integer; ForExport: Boolean); function StpFromAlpha(C: PFPColor): Byte;
begin
Result := 0;
if (C^.red + C^.green + C^.blue) = 0 then
case C^.alpha of
$0000: Result := 0;
$FFFF: Result := 1;
end
else
case C^.alpha of
$FFFF: Result := 0;
$8080: Result := 1;
end
end;
procedure PrepareClut(TIM: PTIM; CLUT_NUM: Integer; Pal: PFPPalette; TranspMode: Integer);
var var
I, COUNT: Integer; I, COUNT: Integer;
CC: TCLUT_COLOR; CC: TCLUT_COLOR;
@@ -88,14 +105,6 @@ begin
A := 1; A := 1;
end; end;
if ForExport then
begin
R := R + (((I - 1) and $03) shl 1) + A;
G := G + (((I - 1) and $1C) shr 2);
B := B + (((I - 1) and $E0) shr 5);
A := 255;
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);
@@ -107,25 +116,27 @@ var
I, OFFSET: Integer; I, OFFSET: Integer;
RW: Word; RW: Word;
P24: Integer; P24: Integer;
WH: Integer;
begin begin
New(Result); New(Result);
OFFSET := SizeOf(TTIMHeader) + GetTIMCLUTSize(TIM) + SizeOf(TIMAGEHeader); OFFSET := SizeOf(TTIMHeader) + GetTIMCLUTSize(TIM) + SizeOf(TIMAGEHeader);
RW := GetTimRealWidth(TIM); RW := GetTimRealWidth(TIM);
WH := TIM^.IMAGE^.wWidth * TIM^.IMAGE^.wHeight;
case TIM^.HEAD^.bBPP of case TIM^.HEAD^.bBPP of
cTIM4C, cTIM4NC: cTIM4C, cTIM4NC:
for I := 1 to TIM^.IMAGE^.wWidth * TIM^.IMAGE^.wHeight * 2 do for I := 1 to WH * 2 do
begin begin
Result^[(I - 1) * 2] := TIM^.DATA^[OFFSET + I - 1] and $F; Result^[(I - 1) * 2] := TIM^.DATA^[OFFSET + I - 1] and $F;
Result^[(I - 1) * 2 + 1] := (TIM^.DATA^[OFFSET + I - 1] and $F0) shr 4; Result^[(I - 1) * 2 + 1] := (TIM^.DATA^[OFFSET + I - 1] and $F0) shr 4;
end; end;
cTIM8C, cTIM8NC: cTIM8C, cTIM8NC:
for I := 1 to TIM^.IMAGE^.wWidth * TIM^.IMAGE^.wHeight * 2 do for I := 1 to WH * 2 do
Result^[I - 1] := TIM^.DATA^[OFFSET + I - 1]; Result^[I - 1] := TIM^.DATA^[OFFSET + I - 1];
cTIM16C, cTIM16NC: cTIM16C, cTIM16NC:
for I := 1 to TIM^.IMAGE^.wWidth * TIM^.IMAGE^.wHeight do for I := 1 to WH do
Move(TIM^.DATA^[OFFSET + (I - 1) * 2], Result^[I - 1], 2); Move(TIM^.DATA^[OFFSET + (I - 1) * 2], Result^[I - 1], 2);
cTIM24C, cTIM24NC: cTIM24C, cTIM24NC:
@@ -133,14 +144,13 @@ begin
I := 1; I := 1;
P24 := 0; P24 := 0;
while I <= (TIM^.IMAGE^.wWidth * TIM^.IMAGE^.wHeight * 2) do while I <= (WH * 2) do
begin begin
Result^[P24] := 0; Result^[P24] := 0;
Move(TIM^.DATA^[OFFSET + (I - 1)], Result^[P24], 3); Move(TIM^.DATA^[OFFSET + (I - 1)], Result^[P24], 3);
Inc(I, 3); Inc(I, 3);
if Odd(RW) and (((P24 + 1) mod RW) = 0) then if Odd(RW) and (((P24 + 1) mod RW) = 0) then Inc(OFFSET);
Inc(OFFSET);
Inc(P24); Inc(P24);
end; end;
@@ -165,7 +175,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; ForExport: Boolean); procedure Tim2Png(TIM: PTIM; CLUT_NUM: Integer; Surf: PDrawSurf; TranspMode: Byte);
var var
RW, RH, CW: Word; RW, RH, CW: Word;
INDEXES: PIMAGE_INDEXES; INDEXES: PIMAGE_INDEXES;
@@ -185,7 +195,7 @@ begin
PAL := @(Surf^.Palette); PAL := @(Surf^.Palette);
PrepareClut(TIM, CLUT_NUM, PAL, TranspMode, ForExport); PrepareClut(TIM, CLUT_NUM, PAL, TranspMode);
INDEXES := PrepareIMAGE(TIM); INDEXES := PrepareIMAGE(TIM);
COLORS := GetTimColorsCount(TIM); COLORS := GetTimColorsCount(TIM);
@@ -202,11 +212,12 @@ begin
cTIM4C, cTIM4NC, cTIM8C, cTIM8NC: Surf^.Pixels[X - 1, Y - 1] := INDEXES^[IDX] mod COLORS; cTIM4C, cTIM4NC, cTIM8C, cTIM8NC: Surf^.Pixels[X - 1, Y - 1] := INDEXES^[IDX] mod COLORS;
cTIM16C, cTIM16NC, cTIMMix: cTIM16C, cTIM16NC, cTIMMix:
begin begin
CW := 0;
Move(INDEXES^[IDX], CW, 2); Move(INDEXES^[IDX], CW, 2);
CC := ConvertTIMColor(CW); CC := ConvertTIMColor(CW);
FC := BGRAToFPColor(BGRA(CC.R + CC.STP, CC.G, CC.B)); FC := BGRAToFPColor(BGRA(CC.R, CC.G, CC.B, CC.STP));
if (not ForExport) then AlphaForMode(@FC, TranspMode); AlphaForMode(@FC, TranspMode);
Surf^.Colors[X - 1, Y - 1] := FC; Surf^.Colors[X - 1, Y - 1] := FC;
end; end;
@@ -228,6 +239,78 @@ begin
Dispose(INDEXES); Dispose(INDEXES);
end; end;
procedure Png2Tim(Image: PDrawSurf; Dest: PTIM);
var
IW, IH, X, Y, CW: Word;
TData: PTIMDataArray;
IDX, POS, C: Integer;
CC: TCLUT_COLOR;
PC: TBGRAPixel;
FC: TFPColor;
CD: DWord;
begin
IW := Image^.Width;
IH := Image^.Height;
TData := @Dest^.DATA^[SizeOf(TTIMHeader) + GetTIMCLUTSize(Dest) + SizeOf(TIMAGEHeader)];
{ TODO : Fix colors finding. }
POS := 0;
for Y := 1 to IH do
case Dest^.HEAD^.bBPP of
cTIM4C, cTIM4NC:
for X := 1 to (IW div 2) do
begin
IDX := Image^.Pixels[X - 1, Y - 1];
TData^[POS] := (IDX and $F);
IDX := Image^.Pixels[X, Y - 1];
TData^[POS] := TData^[0] + (IDX and $F0);
Inc(POS);
end;
cTIM8C, cTIM8NC:
for X := 1 to IW do
begin
C := Image^.Pixels[X - 1, Y - 1];
TData^[POS] := Byte(C);
Inc(POS);
end;
cTIM16C, cTIM16NC:
for X := 1 to IW do
begin
FC := Image^.Colors[X - 1, Y - 1];
CC.STP := StpFromAlpha(@FC);
PC := FPColorToBGRA(FC);
CC.R := PC.red;
CC.G := PC.green;
CC.B := PC.blue;
CW := ConvertCLUTColor(CC);
Move(CW, TData^[POS], 2);
Inc(POS, 2);
end;
cTIM24C, cTIM24NC:
for X := 1 to IW do
begin
FC := Image^.Colors[X - 1, Y - 1];
PC := FPColorToBGRA(FC);
CD := (PC.blue shl 16) + (PC.green shl 8) + PC.red;
Move(CD, TData^[POS], 3);
Inc(POS, 3);
if Odd(IW) and ((IW - X) = 0) then
begin
TData^[POS] := 0;
Inc(POS);
end;
end;
end;
end;
procedure DrawClutCell(TIM: PTIM; CLUT_NUM: Integer; Grid: PDrawGrid; X, Y: Integer); procedure DrawClutCell(TIM: PTIM; CLUT_NUM: Integer; Grid: PDrawGrid; X, Y: Integer);
var var
CLUT_COLOR: PCLUT_COLOR; CLUT_COLOR: PCLUT_COLOR;

View File

@@ -2,13 +2,18 @@ unit uexportimport;
interface interface
uses FPWritePNG, zstream, udrawtim; uses
FPWritePNG, zstream, udrawtim;
procedure SaveImage(Surf: PDrawSurf; Indexed: Boolean; const FileName: string; PngWriter: TFPWriterPNG); procedure SaveImage(Surf: PDrawSurf; Indexed: Boolean; const FileName: string; PngWriter: TFPWriterPNG);
function LoadImage(const FileName: string; var Surf: PDrawSurf): Boolean;
function CreatePngWriter(ForExport: Boolean): TFPWriterPNG; function CreatePngWriter(ForExport: Boolean): TFPWriterPNG;
implementation implementation
uses
FPReadPNG, Classes, BGRABitmap, FileUtil, sysutils;
function CreatePngWriter(ForExport: Boolean): TFPWriterPNG; function CreatePngWriter(ForExport: Boolean): TFPWriterPNG;
begin begin
Result := TFPWriterPNG.Create; Result := TFPWriterPNG.Create;
@@ -23,5 +28,31 @@ begin
Surf^.SaveToFileUTF8(FileName, PngWriter); Surf^.SaveToFileUTF8(FileName, PngWriter);
end; end;
function LoadImage(const FileName: string; var Surf: PDrawSurf): Boolean;
var
Reader: TFPReaderPNG;
Image: TFileStream;
begin
Result := False;
try
Reader := TFPReaderPNG.Create;
Image := TFileStream.Create(UTF8ToSys(FileName), fmOpenRead or fmShareDenyWrite);
Result := Reader.CheckContents(Image);
if Result then
begin
New(Surf);
Surf^ := TBGRABitmap.Create;
Image.Position := 0;
Surf^.LoadFromStream(Image);
end;
finally
Image.Free;
Reader.Free;
end;
end;
end. end.

View File

@@ -494,7 +494,7 @@ object frmMain: TfrmMain
OnCreate = FormCreate OnCreate = FormCreate
OnDropFiles = FormDropFiles OnDropFiles = FormDropFiles
Position = poScreenCenter Position = poScreenCenter
LCLVersion = '1.2.0.3' LCLVersion = '1.2.2.0'
object pnlStatus: TPanel object pnlStatus: TPanel
Left = 0 Left = 0
Height = 30 Height = 30
@@ -828,11 +828,11 @@ object frmMain: TfrmMain
DefaultExt = '.bin' DefaultExt = '.bin'
Filter = 'All Files (*.*)|*.*' Filter = 'All Files (*.*)|*.*'
Options = [ofHideReadOnly, ofNoChangeDir, ofAllowMultiSelect, ofNoNetworkButton, ofEnableSizing, ofForceShowHidden] Options = [ofHideReadOnly, ofNoChangeDir, ofAllowMultiSelect, ofNoNetworkButton, ofEnableSizing, ofForceShowHidden]
left = 664 left = 576
top = 448 top = 448
end end
object mmMain: TMainMenu object mmMain: TMainMenu
left = 600 left = 352
top = 448 top = 448
object mnFile: TMenuItem object mnFile: TMenuItem
Caption = '&File' Caption = '&File'
@@ -867,6 +867,15 @@ object frmMain: TfrmMain
Action = actTim2Png Action = actTim2Png
end end
end end
object mnEdit: TMenuItem
Caption = '&Edit'
object mnExportTim: TMenuItem
Action = actPngExport
end
object mnImport: TMenuItem
Action = actPngImport
end
end
object mnOptions: TMenuItem object mnOptions: TMenuItem
Caption = '&Options' Caption = '&Options'
object mnAssociate: TMenuItem object mnAssociate: TMenuItem
@@ -904,7 +913,7 @@ object frmMain: TfrmMain
DefaultExt = '.png' DefaultExt = '.png'
Filter = 'Portable Network Graphics (*.png)|*.png' Filter = 'Portable Network Graphics (*.png)|*.png'
Options = [ofHideReadOnly, ofNoChangeDir, ofNoNetworkButton, ofEnableSizing] Options = [ofHideReadOnly, ofNoChangeDir, ofNoNetworkButton, ofEnableSizing]
left = 696 left = 688
top = 448 top = 448
end end
object dlgSaveTIM: TSaveDialog object dlgSaveTIM: TSaveDialog
@@ -912,7 +921,7 @@ object frmMain: TfrmMain
DefaultExt = '.tim' DefaultExt = '.tim'
Filter = 'PSX TIM Files (*.tim)|*.tim|All Files (*.*)|*.*' Filter = 'PSX TIM Files (*.tim)|*.tim|All Files (*.*)|*.*'
Options = [ofOverwritePrompt, ofHideReadOnly, ofNoChangeDir, ofNoNetworkButton, ofEnableSizing] Options = [ofOverwritePrompt, ofHideReadOnly, ofNoChangeDir, ofNoNetworkButton, ofEnableSizing]
left = 568 left = 608
top = 448 top = 448
end end
object dlgColor: TColorDialog object dlgColor: TColorDialog
@@ -939,11 +948,11 @@ object frmMain: TfrmMain
'ColorS=F0FBFF' 'ColorS=F0FBFF'
'ColorT=A4A0A0' 'ColorT=A4A0A0'
) )
left = 536 left = 496
top = 448 top = 448
end end
object actList: TActionList object actList: TActionList
left = 504 left = 416
top = 448 top = 448
object actScanFile: TAction object actScanFile: TAction
Caption = 'Scan &File...' Caption = 'Scan &File...'
@@ -1034,9 +1043,17 @@ object frmMain: TfrmMain
Caption = '&Background Color' Caption = '&Background Color'
OnExecute = actChangeBackColorExecute OnExecute = actChangeBackColorExecute
end end
object actPngImport: TAction
Caption = '&Import PNG to TIM...'
OnExecute = actPngImportExecute
end
object actPngExport: TAction
Caption = '&Export TIM to PNG...'
OnExecute = actTim2PngExecute
end
end end
object pmList: TPopupMenu object pmList: TPopupMenu
left = 632 left = 448
top = 448 top = 448
object ExtractTIM1: TMenuItem object ExtractTIM1: TMenuItem
Action = actExtractTim Action = actExtractTim
@@ -1058,7 +1075,7 @@ object frmMain: TfrmMain
end end
end end
object pmImage: TPopupMenu object pmImage: TPopupMenu
left = 472 left = 384
top = 448 top = 448
object mnSaveAsPng: TMenuItem object mnSaveAsPng: TMenuItem
Action = actTim2Png Action = actTim2Png
@@ -1079,7 +1096,15 @@ object frmMain: TfrmMain
end end
object dlgSelectDir: TSelectDirectoryDialog object dlgSelectDir: TSelectDirectoryDialog
Options = [ofNoChangeDir, ofNoNetworkButton, ofEnableSizing, ofViewDetail] Options = [ofNoChangeDir, ofNoNetworkButton, ofEnableSizing, ofViewDetail]
left = 449 left = 528
top = 450 top = 448
end
object dlgOpenPNG: TOpenPictureDialog
Title = 'Please, select PNG...'
DefaultExt = '.png'
Filter = 'Portable Network Graphics (*.png)|*.png'
Options = [ofHideReadOnly, ofNoChangeDir, ofNoNetworkButton, ofEnableSizing]
left = 656
top = 448
end end
end end

View File

@@ -28,6 +28,8 @@ type
actExtractTIMs: TAction; actExtractTIMs: TAction;
actChangeFile: TAction; actChangeFile: TAction;
actChangeBackColor: TAction; actChangeBackColor: TAction;
actPngExport: TAction;
actPngImport: TAction;
actStopScan: TAction; actStopScan: TAction;
actOpenLab: TAction; actOpenLab: TAction;
actOpenRepo: TAction; actOpenRepo: TAction;
@@ -55,6 +57,9 @@ type
imgTim: TImage; imgTim: TImage;
lblStatus: TLabel; lblStatus: TLabel;
lvList: TListView; lvList: TListView;
mnImport: TMenuItem;
mnExportTim: TMenuItem;
mnEdit: TMenuItem;
mnChangeBackColor2: TMenuItem; mnChangeBackColor2: TMenuItem;
N8: TMenuItem; N8: TMenuItem;
mnChangeBackColor: TMenuItem; mnChangeBackColor: TMenuItem;
@@ -85,6 +90,7 @@ type
N1: TMenuItem; N1: TMenuItem;
N3: TMenuItem; N3: TMenuItem;
N5: TMenuItem; N5: TMenuItem;
dlgOpenPNG: TOpenPictureDialog;
pnlClut: TPanel; pnlClut: TPanel;
pbProgress: TProgressBar; pbProgress: TProgressBar;
pnlExtractAll: TPanel; pnlExtractAll: TPanel;
@@ -113,6 +119,7 @@ type
procedure actExtractTIMsExecute(Sender: TObject); procedure actExtractTIMsExecute(Sender: TObject);
procedure actOpenLabExecute(Sender: TObject); procedure actOpenLabExecute(Sender: TObject);
procedure actOpenRepoExecute(Sender: TObject); procedure actOpenRepoExecute(Sender: TObject);
procedure actPngImportExecute(Sender: TObject);
procedure actReplaceTimExecute(Sender: TObject); procedure actReplaceTimExecute(Sender: TObject);
procedure actReturnFocusExecute(Sender: TObject); procedure actReturnFocusExecute(Sender: TObject);
procedure actScanDirExecute(Sender: TObject); procedure actScanDirExecute(Sender: TObject);
@@ -168,7 +175,7 @@ type
procedure ShowTim; procedure ShowTim;
procedure ShowTimInfo(ShowInfo: Boolean); procedure ShowTimInfo(ShowInfo: Boolean);
procedure RemoveGridSelection; procedure RemoveGridSelection;
procedure Update(Tim, Clut, ClutInfo: Boolean); procedure UpdateTim(Tim, Clut, ClutInfo: Boolean);
public public
{ public declarations } { public declarations }
ScanResults: TScanResultList; //List of finished scan results ScanResults: TScanResultList; //List of finished scan results
@@ -227,7 +234,7 @@ end;
procedure TfrmMain.actStretchExecute(Sender: TObject); procedure TfrmMain.actStretchExecute(Sender: TObject);
begin begin
Settings.StretchMode := actStretch.Checked; Settings.StretchMode := actStretch.Checked;
Update(True, False, False); UpdateTim(True, False, False);
end; end;
procedure TfrmMain.actTim2PngExecute(Sender: TObject); procedure TfrmMain.actTim2PngExecute(Sender: TObject);
@@ -242,7 +249,7 @@ begin
if not dlgSavePNG.Execute then Exit; if not dlgSavePNG.Execute then Exit;
Writer := CreatePngWriter(False); Writer := CreatePngWriter((Sender as TAction) = actPngExport);
SaveImage(Surf, TIMisIndexed(TIM), dlgSavePNG.FileName, Writer); SaveImage(Surf, TIMisIndexed(TIM), dlgSavePNG.FileName, Writer);
Writer.Free; Writer.Free;
FreeTIM(TIM); FreeTIM(TIM);
@@ -252,19 +259,19 @@ end;
procedure TfrmMain.btnShowClutClick(Sender: TObject); procedure TfrmMain.btnShowClutClick(Sender: TObject);
begin begin
pnlClut.Visible := not pnlClut.Visible; pnlClut.Visible := not pnlClut.Visible;
Update(False, True, False); UpdateTim(False, True, False);
actReturnFocus.Execute; actReturnFocus.Execute;
end; end;
procedure TfrmMain.cbbBitModeChange(Sender: TObject); procedure TfrmMain.cbbBitModeChange(Sender: TObject);
begin begin
Update(True, False, False); UpdateTim(True, False, False);
end; end;
procedure TfrmMain.cbbTranspModeChange(Sender: TObject); procedure TfrmMain.cbbTranspModeChange(Sender: TObject);
begin begin
Settings.TranspMode := cbbTranspMode.ItemIndex; Settings.TranspMode := cbbTranspMode.ItemIndex;
Update(True, False, False); UpdateTim(True, False, False);
end; end;
procedure TfrmMain.actChangeFileExecute(Sender: TObject); procedure TfrmMain.actChangeFileExecute(Sender: TObject);
@@ -325,7 +332,7 @@ end;
procedure TfrmMain.actChangeClutIdxExecute(Sender: TObject); procedure TfrmMain.actChangeClutIdxExecute(Sender: TObject);
begin begin
Update(True, True, False); UpdateTim(True, True, False);
end; end;
procedure TfrmMain.actCloseFileExecute(Sender: TObject); procedure TfrmMain.actCloseFileExecute(Sender: TObject);
@@ -337,7 +344,7 @@ begin
ShowTimInfo(False); ShowTimInfo(False);
SetTimsListCount(0); SetTimsListCount(0);
Update(True, True, True); UpdateTim(True, True, True);
cbbFiles.Items.Delete(cbbFiles.ItemIndex); cbbFiles.Items.Delete(cbbFiles.ItemIndex);
@@ -398,7 +405,7 @@ begin
CreateDirUTF8(Path); CreateDirUTF8(Path);
TIM := LoadTimFromFile(FName, OFFSET, IsImage, SIZE); TIM := LoadTimFromFile(FName, OFFSET, IsImage, SIZE);
Tim2Png(TIM, cbbCLUT.ItemIndex, Surf_, cbbTranspMode.ItemIndex, False); Tim2Png(TIM, cbbCLUT.ItemIndex, Surf_, cbbTranspMode.ItemIndex);
Path := Path + FormatPngName(FName, I - 1, BIT_MODE, 0); Path := Path + FormatPngName(FName, I - 1, BIT_MODE, 0);
SaveImage(Surf_, TIMisIndexed(TIM), Path, Writer); SaveImage(Surf_, TIMisIndexed(TIM), Path, Writer);
@@ -481,13 +488,37 @@ begin
OpenUrl('http://tim2view.googlecode.com'); OpenUrl('http://tim2view.googlecode.com');
end; end;
procedure TfrmMain.actPngImportExecute(Sender: TObject);
var
Image: PDrawSurf;
TIM: PTIM;
ScanRes: TScanResult;
begin
if not dlgOpenPNG.Execute then Exit;
if not LoadImage(dlgOpenPNG.FileName, Image) then Exit;
TIM := SelectedTim;
if TIM = nil then Exit;
Png2Tim(Image, TIM);
SaveTimToFile('test.tim', TIM);
ScanRes := SelectedScanResult;
ReplaceTimInFileFromMemory(ScanRes.ScanFile, TIM, SelectedTimInfo.Position, ScanRes.IsImage);
ShowTim;
FreeTIM(TIM);
Image^.Free;
Dispose(Image);
end;
procedure TfrmMain.actReplaceTimExecute(Sender: TObject); procedure TfrmMain.actReplaceTimExecute(Sender: TObject);
var
ScanRes: TScanResult;
begin begin
if not dlgOpenFile.Execute then Exit; if not dlgOpenFile.Execute then Exit;
if FileSize(dlgOpenFile.FileName) > cTIMMaxSize then Exit; if FileSize(dlgOpenFile.FileName) > cTIMMaxSize then Exit;
ReplaceTimInFile(SelectedScanResult.ScanFile, dlgOpenFile.FileName, SelectedTimInfo.Position, SelectedScanResult.IsImage); ScanRes := SelectedScanResult;
ReplaceTimInFile(ScanRes.ScanFile, dlgOpenFile.FileName, SelectedTimInfo.Position, ScanRes.IsImage);
ShowTim; ShowTim;
end; end;
@@ -615,7 +646,7 @@ begin
FreeTIM(TIM); FreeTIM(TIM);
Update(True, True, False); UpdateTim(True, True, False);
end; end;
procedure TfrmMain.grdClutDrawCell(Sender: TObject; aCol, aRow: Integer; procedure TfrmMain.grdClutDrawCell(Sender: TObject; aCol, aRow: Integer;
@@ -882,8 +913,7 @@ begin
Index := cbbCLUT.ItemIndex; Index := cbbCLUT.ItemIndex;
Tim2Png(TIM, Index, Surf, cbbTranspMode.ItemIndex, False); Tim2Png(TIM, Index, Surf, cbbTranspMode.ItemIndex);
imgTim.Picture.Bitmap := TBitmap.Create;
imgTim.Picture.Bitmap := Surf^.Bitmap; imgTim.Picture.Bitmap := Surf^.Bitmap;
FreeTIM(TIM); FreeTIM(TIM);
@@ -946,7 +976,7 @@ begin
{ TODO : Reset bitmode or not? } { TODO : Reset bitmode or not? }
//cbbBitMode.ItemIndex := 0; //cbbBitMode.ItemIndex := 0;
Update(True, True, True); UpdateTim(True, True, True);
ShowTimInfo(True); ShowTimInfo(True);
@@ -1007,7 +1037,7 @@ begin
grdClut.Selection := hGrid; grdClut.Selection := hGrid;
end; end;
procedure TfrmMain.Update(Tim, Clut, ClutInfo: Boolean); procedure TfrmMain.UpdateTim(Tim, Clut, ClutInfo: Boolean);
begin begin
if ClutInfo then UpdateCLUTInfo; if ClutInfo then UpdateCLUTInfo;
if Tim then DrawSelTim; if Tim then DrawSelTim;