Fixed opening of paths with on Latin chars. Fixed All PNGs saving.

This commit is contained in:
meffi@lab313.ru
2014-04-16 23:44:19 +00:00
parent db601dcd85
commit 180cf642d6
8 changed files with 128 additions and 116 deletions

View File

@@ -118,20 +118,7 @@
<OtherUnitFiles Value="bgrabitmap"/> <OtherUnitFiles Value="bgrabitmap"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths> </SearchPaths>
<CodeGeneration>
<SmartLinkUnit Value="True"/>
<RelocatableUnit Value="True"/>
<TargetCPU Value="x86_64"/>
<TargetOS Value="linux"/>
<Optimizations>
<OptimizationLevel Value="3"/>
</Optimizations>
</CodeGeneration>
<Linking> <Linking>
<Debugging>
<GenerateDebugInfo Value="False"/>
</Debugging>
<LinkSmart Value="True"/>
<Options> <Options>
<Win32> <Win32>
<GraphicApplication Value="True"/> <GraphicApplication Value="True"/>

View File

@@ -12,7 +12,7 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<CursorPos X="37" Y="11"/> <CursorPos X="37" Y="11"/>
<UsageCount Value="46"/> <UsageCount Value="47"/>
</Unit0> </Unit0>
<Unit1> <Unit1>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
@@ -23,9 +23,9 @@
<UnitName Value="umain"/> <UnitName Value="umain"/>
<EditorIndex Value="0"/> <EditorIndex Value="0"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="718"/> <TopLine Value="940"/>
<CursorPos X="27" Y="736"/> <CursorPos X="85" Y="952"/>
<UsageCount Value="46"/> <UsageCount Value="47"/>
<Loaded Value="True"/> <Loaded Value="True"/>
<LoadedDesigner Value="True"/> <LoadedDesigner Value="True"/>
</Unit1> </Unit1>
@@ -36,7 +36,7 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="42"/> <TopLine Value="42"/>
<CursorPos X="88" Y="20"/> <CursorPos X="88" Y="20"/>
<UsageCount Value="46"/> <UsageCount Value="47"/>
</Unit2> </Unit2>
<Unit3> <Unit3>
<Filename Value="ecc.pas"/> <Filename Value="ecc.pas"/>
@@ -45,37 +45,41 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<CursorPos X="6" Y="11"/> <CursorPos X="6" Y="11"/>
<UsageCount Value="46"/> <UsageCount Value="47"/>
</Unit3> </Unit3>
<Unit4> <Unit4>
<Filename Value="ucommon.pas"/> <Filename Value="ucommon.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="ucommon"/> <UnitName Value="ucommon"/>
<IsVisibleTab Value="True"/> <IsVisibleTab Value="True"/>
<EditorIndex Value="2"/> <EditorIndex Value="5"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<CursorPos X="35" Y="6"/> <CursorPos X="35" Y="6"/>
<UsageCount Value="46"/> <UsageCount Value="47"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit4> </Unit4>
<Unit5> <Unit5>
<Filename Value="utim.pas"/> <Filename Value="utim.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="utim"/> <UnitName Value="utim"/>
<EditorIndex Value="2"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="165"/> <TopLine Value="442"/>
<CursorPos X="85" Y="179"/> <CursorPos X="3" Y="456"/>
<UsageCount Value="46"/> <UsageCount Value="47"/>
<Loaded Value="True"/>
</Unit5> </Unit5>
<Unit6> <Unit6>
<Filename Value="ucdimage.pas"/> <Filename Value="ucdimage.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="ucdimage"/> <UnitName Value="ucdimage"/>
<EditorIndex Value="3"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="12"/> <TopLine Value="70"/>
<CursorPos X="11" Y="37"/> <CursorPos X="65" Y="78"/>
<UsageCount Value="46"/> <UsageCount Value="47"/>
<Loaded Value="True"/>
</Unit6> </Unit6>
<Unit7> <Unit7>
<Filename Value="usettings.pas"/> <Filename Value="usettings.pas"/>
@@ -84,7 +88,7 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="52"/> <TopLine Value="52"/>
<CursorPos X="87" Y="71"/> <CursorPos X="87" Y="71"/>
<UsageCount Value="46"/> <UsageCount Value="47"/>
</Unit7> </Unit7>
<Unit8> <Unit8>
<Filename Value="uscanresult.pas"/> <Filename Value="uscanresult.pas"/>
@@ -93,38 +97,40 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="26"/> <TopLine Value="26"/>
<CursorPos X="1" Y="66"/> <CursorPos X="1" Y="66"/>
<UsageCount Value="45"/> <UsageCount Value="46"/>
</Unit8> </Unit8>
<Unit9> <Unit9>
<Filename Value="uscanthread.pas"/> <Filename Value="uscanthread.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="uscanthread"/> <UnitName Value="uscanthread"/>
<EditorIndex Value="1"/> <EditorIndex Value="4"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="41"/> <TopLine Value="1"/>
<CursorPos X="54" Y="62"/> <CursorPos X="78" Y="20"/>
<UsageCount Value="45"/> <UsageCount Value="46"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit9> </Unit9>
<Unit10> <Unit10>
<Filename Value="ucpucount.pas"/> <Filename Value="ucpucount.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="ucpucount"/> <UnitName Value="ucpucount"/>
<EditorIndex Value="3"/> <EditorIndex Value="6"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<CursorPos X="23" Y="8"/> <CursorPos X="23" Y="8"/>
<UsageCount Value="44"/> <UsageCount Value="45"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit10> </Unit10>
<Unit11> <Unit11>
<Filename Value="udrawtim.pas"/> <Filename Value="udrawtim.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="udrawtim"/> <UnitName Value="udrawtim"/>
<EditorIndex Value="1"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="187"/> <TopLine Value="110"/>
<CursorPos X="35" Y="203"/> <CursorPos X="1" Y="127"/>
<UsageCount Value="31"/> <UsageCount Value="32"/>
<Loaded Value="True"/>
</Unit11> </Unit11>
<Unit12> <Unit12>
<Filename Value="bgrabitmap\bgrabitmap.pas"/> <Filename Value="bgrabitmap\bgrabitmap.pas"/>
@@ -133,7 +139,7 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="55"/> <TopLine Value="55"/>
<CursorPos X="3" Y="69"/> <CursorPos X="3" Y="69"/>
<UsageCount Value="21"/> <UsageCount Value="22"/>
</Unit12> </Unit12>
<Unit13> <Unit13>
<Filename Value="l2sq_table.pas"/> <Filename Value="l2sq_table.pas"/>
@@ -357,99 +363,127 @@
<General> <General>
<ActiveWindowIndexAtStart Value="0"/> <ActiveWindowIndexAtStart Value="0"/>
</General> </General>
<JumpHistory Count="23" HistoryIndex="22"> <JumpHistory Count="30" HistoryIndex="29">
<Position1> <Position1>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="876" Column="31" TopLine="861"/> <Caret Line="390" Column="1" TopLine="373"/>
</Position1> </Position1>
<Position2> <Position2>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="888" Column="26" TopLine="879"/> <Caret Line="391" Column="1" TopLine="373"/>
</Position2> </Position2>
<Position3> <Position3>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="894" Column="32" TopLine="880"/> <Caret Line="393" Column="1" TopLine="377"/>
</Position3> </Position3>
<Position4> <Position4>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="897" Column="9" TopLine="883"/> <Caret Line="394" Column="1" TopLine="377"/>
</Position4> </Position4>
<Position5> <Position5>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="894" Column="1" TopLine="883"/> <Caret Line="395" Column="1" TopLine="377"/>
</Position5> </Position5>
<Position6> <Position6>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="894" Column="1" TopLine="883"/> <Caret Line="396" Column="1" TopLine="377"/>
</Position6> </Position6>
<Position7> <Position7>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="895" Column="1" TopLine="883"/> <Caret Line="398" Column="1" TopLine="383"/>
</Position7> </Position7>
<Position8> <Position8>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="894" Column="59" TopLine="883"/> <Caret Line="399" Column="1" TopLine="383"/>
</Position8> </Position8>
<Position9> <Position9>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="896" Column="23" TopLine="883"/> <Caret Line="400" Column="1" TopLine="383"/>
</Position9> </Position9>
<Position10> <Position10>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="883" Column="47" TopLine="871"/> <Caret Line="401" Column="1" TopLine="383"/>
</Position10> </Position10>
<Position11> <Position11>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="204" Column="30" TopLine="192"/> <Caret Line="403" Column="75" TopLine="383"/>
</Position11> </Position11>
<Position12> <Position12>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="131" Column="21" TopLine="117"/> <Caret Line="404" Column="9" TopLine="383"/>
</Position12> </Position12>
<Position13> <Position13>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="518" Column="1" TopLine="504"/> <Caret Line="382" Column="1" TopLine="367"/>
</Position13> </Position13>
<Position14> <Position14>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="519" Column="1" TopLine="504"/> <Caret Line="404" Column="1" TopLine="391"/>
</Position14> </Position14>
<Position15> <Position15>
<Filename Value="umain.pas"/> <Filename Value="udrawtim.pas"/>
<Caret Line="892" Column="41" TopLine="875"/> <Caret Line="122" Column="1" TopLine="107"/>
</Position15> </Position15>
<Position16> <Position16>
<Filename Value="umain.pas"/> <Filename Value="udrawtim.pas"/>
<Caret Line="519" Column="1" TopLine="504"/> <Caret Line="123" Column="1" TopLine="107"/>
</Position16> </Position16>
<Position17> <Position17>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="871" Column="41" TopLine="862"/> <Caret Line="404" Column="1" TopLine="385"/>
</Position17> </Position17>
<Position18> <Position18>
<Filename Value="ucommon.pas"/> <Filename Value="udrawtim.pas"/>
<Caret Line="6" Column="50" TopLine="1"/> <Caret Line="125" Column="1" TopLine="110"/>
</Position18> </Position18>
<Position19> <Position19>
<Filename Value="umain.pas"/> <Filename Value="udrawtim.pas"/>
<Caret Line="524" Column="48" TopLine="516"/> <Caret Line="127" Column="1" TopLine="110"/>
</Position19> </Position19>
<Position20> <Position20>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="468" Column="104" TopLine="455"/> <Caret Line="396" Column="73" TopLine="385"/>
</Position20> </Position20>
<Position21> <Position21>
<Filename Value="umain.pas"/> <Filename Value="umain.pas"/>
<Caret Line="704" Column="37" TopLine="695"/> <Caret Line="404" Column="1" TopLine="385"/>
</Position21> </Position21>
<Position22> <Position22>
<Filename Value="umain.pas"/> <Filename Value="udrawtim.pas"/>
<Caret Line="736" Column="83" TopLine="718"/> <Caret Line="122" Column="1" TopLine="110"/>
</Position22> </Position22>
<Position23> <Position23>
<Filename Value="uscanthread.pas"/> <Filename Value="udrawtim.pas"/>
<Caret Line="197" Column="22" TopLine="173"/> <Caret Line="123" Column="1" TopLine="110"/>
</Position23> </Position23>
<Position24>
<Filename Value="umain.pas"/>
<Caret Line="388" Column="17" TopLine="385"/>
</Position24>
<Position25>
<Filename Value="umain.pas"/>
<Caret Line="405" Column="1" TopLine="385"/>
</Position25>
<Position26>
<Filename Value="udrawtim.pas"/>
<Caret Line="122" Column="1" TopLine="110"/>
</Position26>
<Position27>
<Filename Value="udrawtim.pas"/>
<Caret Line="123" Column="1" TopLine="110"/>
</Position27>
<Position28>
<Filename Value="udrawtim.pas"/>
<Caret Line="125" Column="1" TopLine="110"/>
</Position28>
<Position29>
<Filename Value="udrawtim.pas"/>
<Caret Line="127" Column="1" TopLine="110"/>
</Position29>
<Position30>
<Filename Value="umain.pas"/>
<Caret Line="394" Column="94" TopLine="385"/>
</Position30>
</JumpHistory> </JumpHistory>
</ProjectSession> </ProjectSession>
<EditorMacros Count="0"/> <EditorMacros Count="0"/>

View File

@@ -40,7 +40,7 @@ procedure ReplaceTimInFileFromMemory(const FileName: string; TIM: PTIM;
implementation implementation
uses uses
ucommon, ecc, edc, classes, FileUtil, sysutils; ucommon, ecc, edc, classes, FileUtil, sysutils, lazutf8classes;
function bin2bcd(P: Integer): byte; function bin2bcd(P: Integer): byte;
begin begin
@@ -69,7 +69,7 @@ const
var var
Sz: cardinal; Sz: cardinal;
pFile: PBytesArray; pFile: PBytesArray;
tmp: TFileStream; tmp: TFileStreamUTF8;
begin begin
Result := False; Result := False;
Sz := FileSize(FileName); Sz := FileSize(FileName);
@@ -80,7 +80,7 @@ begin
pFile := GetMemory(cSectorHeaderSize); pFile := GetMemory(cSectorHeaderSize);
try try
tmp := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite); tmp := TFileStreamUTF8.Create(FileName, fmOpenRead or fmShareDenyWrite);
tmp.Read(pFile^[0], cSectorHeaderSize); tmp.Read(pFile^[0], cSectorHeaderSize);
Result := ((Sz mod cSectorSize) = 0) and (CompareMem(@cSectorHeader, pFile, cSectorHeaderSize)); Result := ((Sz mod cSectorSize) = 0) and (CompareMem(@cSectorHeader, pFile, cSectorHeaderSize));
finally finally
@@ -94,7 +94,7 @@ procedure ReplaceTimInFileFromMemory(const FileName: string; TIM: PTIM;
type type
TSecAddrAndMode = array [0 .. cSectorAddressSize + cSectorModeSize - 1] of byte; TSecAddrAndMode = array [0 .. cSectorAddressSize + cSectorModeSize - 1] of byte;
var var
sImageStream: TFileStream; sImageStream: TFileStreamUTF8;
TimOffsetInSector, FirstPartSize, LastPartSize: Integer; TimOffsetInSector, FirstPartSize, LastPartSize: Integer;
TimSectorNumber, TimStartSectorPos: Integer; TimSectorNumber, TimStartSectorPos: Integer;
Sector: TCDSector; Sector: TCDSector;
@@ -102,8 +102,7 @@ var
P, TIM_FULL_SECTORS: Integer; P, TIM_FULL_SECTORS: Integer;
SecAddrAndMode: TSecAddrAndMode; SecAddrAndMode: TSecAddrAndMode;
begin begin
sImageStream := TFileStream.Create(FileName, fmOpenReadWrite or sImageStream := TFileStreamUTF8.Create(FileName, fmOpenReadWrite or fmShareDenyWrite);
fmShareDenyWrite);
if not ImageScan then if not ImageScan then
begin begin

View File

@@ -3,7 +3,7 @@ unit ucommon;
interface interface
const const
cProgramName = 'Tim2View SVN.r61 by [Lab 313] (for ' + cProgramName = 'Tim2View SVN.r62 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}
@@ -29,7 +29,6 @@ type
TBytesArray = array [0 .. cMaxFileSize - 1] of byte; TBytesArray = array [0 .. cMaxFileSize - 1] of byte;
PBytesArray = ^TBytesArray; PBytesArray = ^TBytesArray;
function ExtractJustName(const Path: string): string;
function Min(A, B: Integer): Integer; function Min(A, B: Integer): Integer;
function Max(A, B: Integer): Integer; function Max(A, B: Integer): Integer;
@@ -53,10 +52,4 @@ begin
Result := B; Result := B;
end; end;
function ExtractJustName(const Path: string): string;
begin
Result := ExtractFileName(Path);
Result := Copy(Result, 1, Length(Result) - Length(ExtractFileExt(Result)));
end;
end. end.

View File

@@ -122,7 +122,7 @@ begin
RW := GetTimRealWidth(TIM); RW := GetTimRealWidth(TIM);
RH := GetTimHeight(TIM); RH := GetTimHeight(TIM);
if Surf^ <> nil then Surf^.Free; if (Surf^ <> nil) then Surf^.Free;
Surf^ := TBGRABitmap.Create(RW, RH); Surf^ := TBGRABitmap.Create(RW, RH);

View File

@@ -204,7 +204,7 @@ begin
if not dlgSavePNG.Execute then Exit; if not dlgSavePNG.Execute then Exit;
Surf^.SaveToFile(dlgSavePNG.FileName); Surf^.SaveToFileUTF8(dlgSavePNG.FileName);
end; end;
procedure TfrmMain.actTimInfoExecute(Sender: TObject); procedure TfrmMain.actTimInfoExecute(Sender: TObject);
@@ -314,10 +314,10 @@ begin
reg.WriteString('', 'Tim File Format'); reg.WriteString('', 'Tim File Format');
reg.CloseKey; reg.CloseKey;
reg.OpenKey('Software\Classes\TimFile\DefaultIcon', True); reg.OpenKey('Software\Classes\TimFile\DefaultIcon', True);
reg.WriteString('', '"' + ParamStr(0) +'",0'); reg.WriteString('', '"' + ParamStrUTF8(0) +'",0');
reg.CloseKey; reg.CloseKey;
reg.OpenKey('Software\Classes\TimFile\shell\Open\Command', True); reg.OpenKey('Software\Classes\TimFile\shell\Open\Command', True);
reg.WriteString('', '"' + ParamStr(0) + '" "%1"'); reg.WriteString('', '"' + ParamStrUTF8(0) + '" "%1"');
reg.CloseKey; reg.CloseKey;
finally finally
reg.Free; reg.Free;
@@ -385,6 +385,7 @@ begin
IsImage := SelectedScanResult.IsImage; IsImage := SelectedScanResult.IsImage;
New(Surf_); New(Surf_);
Surf_^ := nil;
pbProgress.Position := 0; pbProgress.Position := 0;
pbProgress.Max := SelectedScanResult.Count; pbProgress.Max := SelectedScanResult.Count;
@@ -395,16 +396,17 @@ begin
SIZE := ScanTim.Size; SIZE := ScanTim.Size;
BIT_MODE := ScanTim.BitMode; BIT_MODE := ScanTim.BitMode;
Path := IncludeTrailingPathDelimiter(ExtractFilePath(ParamStr(0)) + cExtractedPngsDir); Path := IncludeTrailingPathDelimiter(ExtractFilePath(ParamStrUTF8(0)) + cExtractedPngsDir);
CreateDir(Path); CreateDirUTF8(Path);
Path := IncludeTrailingPathDelimiter(Path + ExtractFileName(FName)); Path := IncludeTrailingPathDelimiter(Path + ExtractFileName(FName));
CreateDir(Path); CreateDirUTF8(Path);
TIM := LoadTimFromFile(FName, OFFSET, IsImage, SIZE); TIM := LoadTimFromFile(FName, OFFSET, IsImage, SIZE);
TimToPNG(TIM, cbbCLUT.ItemIndex, Surf_, cbbTranspMode.ItemIndex); TimToPNG(TIM, cbbCLUT.ItemIndex, Surf_, cbbTranspMode.ItemIndex);
Surf_^.SaveToFile(Path + FormatPngName(FName, I - 1, BIT_MODE, 0)); Surf_^.SaveToFileUTF8(Path + FormatPngName(FName, I - 1, BIT_MODE, 0));
Surf_^.Free; Surf_^.Free;
Surf_^ := nil;
FreeTIM(TIM); FreeTIM(TIM);
@@ -451,10 +453,10 @@ begin
SIZE := ScanTim.Size; SIZE := ScanTim.Size;
BIT_MODE := ScanTim.BitMode; BIT_MODE := ScanTim.BitMode;
Path := IncludeTrailingPathDelimiter(ExtractFilePath(ParamStr(0)) + cExtractedTimsDir); Path := IncludeTrailingPathDelimiter(ExtractFilePath(ParamStrUTF8(0)) + cExtractedTimsDir);
CreateDir(Path); CreateDirUTF8(Path);
Path := IncludeTrailingPathDelimiter(Path + ExtractFileName(FName)); Path := IncludeTrailingPathDelimiter(Path + ExtractFileName(FName));
CreateDir(Path); CreateDirUTF8(Path);
TIM := LoadTimFromFile(FName, OFFSET, IsImage, SIZE); TIM := LoadTimFromFile(FName, OFFSET, IsImage, SIZE);
SaveTimToFile(Path + FormatTimName(FName, I - 1, BIT_MODE), TIM); SaveTimToFile(Path + FormatTimName(FName, I - 1, BIT_MODE), TIM);
@@ -528,7 +530,7 @@ var
begin begin
{$IFnDEF Windows}mnOptions.Enabled := False;{$IFEND} {$IFnDEF Windows}mnOptions.Enabled := False;{$IFEND}
Settings := TSettings.Create(ExtractFilePath(ParamStr(0))); Settings := TSettings.Create(ExtractFilePath(ParamStrUTF8(0)));
actStretch.Checked := Settings.StretchMode; actStretch.Checked := Settings.StretchMode;
cbbTranspMode.ItemIndex := Settings.TranspMode; cbbTranspMode.ItemIndex := Settings.TranspMode;
@@ -552,7 +554,7 @@ begin
CheckButtonsAndMainMenu; CheckButtonsAndMainMenu;
if ParamCount > 0 then ScanPath(ParamStr(1)); if ParamCount > 0 then ScanPath(ParamStrUTF8(1));
end; end;
procedure TfrmMain.FormDropFiles(Sender: TObject; procedure TfrmMain.FormDropFiles(Sender: TObject;
@@ -722,7 +724,7 @@ begin
btnStopScan.Enabled := True; btnStopScan.Enabled := True;
btnStopScan.Tag := NativeInt(False); btnStopScan.Tag := NativeInt(False);
if FileExists(Path) then if FileExistsUTF8(Path) then
ScanFile(Path) ScanFile(Path)
else else
ScanDirectory(Path); ScanDirectory(Path);
@@ -762,7 +764,7 @@ var
Dir: string; Dir: string;
begin begin
Dir := IncludeTrailingPathDelimiter(Directory); Dir := IncludeTrailingPathDelimiter(Directory);
isFound := FindFirst(Dir + '*', faAnyFile, sRec) = 0; isFound := FindFirstUTF8(Dir + '*', faAnyFile, sRec) = 0;
while isFound do while isFound do
begin begin
if (sRec.Name <> '.') and (sRec.Name <> '..') then if (sRec.Name <> '.') and (sRec.Name <> '..') then
@@ -773,9 +775,9 @@ begin
ScanFile(Dir + sRec.Name); ScanFile(Dir + sRec.Name);
end; end;
Application.ProcessMessages; Application.ProcessMessages;
isFound := FindNext(sRec) = 0; isFound := FindNextUTF8(sRec) = 0;
end; end;
FindClose(sRec); FindCloseUTF8(sRec);
end; end;
procedure TfrmMain.CheckButtonsAndMainMenu; procedure TfrmMain.CheckButtonsAndMainMenu;
@@ -949,13 +951,13 @@ end;
function TfrmMain.FormatTimName(const FileName: string; ListIdx_, function TfrmMain.FormatTimName(const FileName: string; ListIdx_,
BitMode: Integer): string; BitMode: Integer): string;
begin begin
Result := Format(cAutoExtractionTimFormat, [ExtractJustName(FileName), ListIdx_ + 1, BitMode]); Result := Format(cAutoExtractionTimFormat, [ExtractFileNameWithoutExt(FileName), ListIdx_ + 1, BitMode]);
end; end;
function TfrmMain.FormatPngName(const FileName: string; ListIdx_, BitMode, function TfrmMain.FormatPngName(const FileName: string; ListIdx_, BitMode,
Clut: Integer): string; Clut: Integer): string;
begin begin
Result := Format(cAutoExtractionPngFormat, [ExtractJustName(FileName), ListIdx_ + 1, BitMode, Clut + 1]); Result := Format(cAutoExtractionPngFormat, [ExtractFileNameWithoutExt(FileName), ListIdx_ + 1, BitMode, Clut + 1]);
end; end;
procedure TfrmMain.ShowTim; procedure TfrmMain.ShowTim;

View File

@@ -3,7 +3,7 @@ unit uscanthread;
interface interface
uses uses
ucommon, utim, uscanresult, classes, fgl; ucommon, utim, uscanresult, classes, fgl, lazutf8classes;
type type
TScanThread = class(TThread) TScanThread = class(TThread)
@@ -16,7 +16,7 @@ type
pClearBufferPosition: Integer; pClearBufferPosition: Integer;
pClearBufferSize: Integer; pClearBufferSize: Integer;
pSectorBufferSize: Integer; pSectorBufferSize: Integer;
pSrcFileStream: TFileStream; pSrcFileStream: TFileStreamUTF8;
pStopScan: boolean; pStopScan: boolean;
procedure SetStatusText; procedure SetStatusText;
procedure StartScan; procedure StartScan;
@@ -39,8 +39,7 @@ uses
umain, ucdimage, sysutils, FileUtil; umain, ucdimage, sysutils, FileUtil;
const const
cClearBufferSize = ((cTIMMaxSize div cSectorDataSize) + 1) * cClearBufferSize = ((cTIMMaxSize div cSectorDataSize) + 1) * cSectorDataSize * 2;
cSectorDataSize * 2;
cSectorBufferSize = (cClearBufferSize div cSectorDataSize) * cSectorSize; cSectorBufferSize = (cClearBufferSize div cSectorDataSize) * cSectorSize;
{ TScanThread } { TScanThread }
@@ -101,8 +100,7 @@ begin
SectorBuffer := GetMemory(pSectorBufferSize); SectorBuffer := GetMemory(pSectorBufferSize);
ClearBuffer := GetMemory(pClearBufferSize); ClearBuffer := GetMemory(pClearBufferSize);
pSrcFileStream := TFileStream.Create(pScanResult.ScanFile, fmOpenRead or pSrcFileStream := TFileStreamUTF8.Create(pScanResult.ScanFile, fmOpenRead or fmShareDenyWrite);
fmShareDenyWrite);
pSrcFileStream.Position := 0; pSrcFileStream.Position := 0;

View File

@@ -145,7 +145,7 @@ function ConvertCLUTColor(COLOR: TCLUT_COLOR): word;
implementation implementation
uses uses
ucdimage, classes, sysutils; ucdimage, classes, sysutils, lazutf8classes;
function ConvertTIMColor(COLOR: word): TCLUT_COLOR; function ConvertTIMColor(COLOR: word): TCLUT_COLOR;
begin begin
@@ -366,12 +366,12 @@ var
TimOffsetInSector, FirstPartSize, LastPartSize: Integer; TimOffsetInSector, FirstPartSize, LastPartSize: Integer;
TimSectorNumber, TimStartSectorPos: Integer; TimSectorNumber, TimStartSectorPos: Integer;
TIM_BUF: PTIMDataArray; TIM_BUF: PTIMDataArray;
sImageStream: TFileStream; sImageStream: TFileStreamUTF8;
Sector: TCDSector; Sector: TCDSector;
P, TIM_FULL_SECTORS: Integer; P, TIM_FULL_SECTORS: Integer;
begin begin
try try
sImageStream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite); sImageStream := TFileStreamUTF8.Create(FileName, fmOpenRead or fmShareDenyWrite);
TimSectorNumber := Position div cSectorSize + 1; TimSectorNumber := Position div cSectorSize + 1;
TimOffsetInSector := Position mod cSectorSize - cSectorInfoSize; TimOffsetInSector := Position mod cSectorSize - cSectorInfoSize;
@@ -451,12 +451,12 @@ end;
function LoadTimFromFile(const FileName: string; var Position: Integer; function LoadTimFromFile(const FileName: string; var Position: Integer;
ImageScan: Boolean; dwSize: Integer): PTIM; ImageScan: Boolean; dwSize: Integer): PTIM;
var var
sTIM: TFileStream; sTIM: TFileStreamUTF8;
begin begin
if not ImageScan then if not ImageScan then
begin begin
try try
sTIM := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite); sTIM := TFileStreamUTF8.Create(FileName, fmOpenRead or fmShareDenyWrite);
Result := LoadTimFromStream(sTIM, Position, dwSize); Result := LoadTimFromStream(sTIM, Position, dwSize);
finally finally
sTIM.Free; sTIM.Free;
@@ -469,13 +469,12 @@ end;
procedure SaveTimToFile(const FileName: string; TIM: PTIM); procedure SaveTimToFile(const FileName: string; TIM: PTIM);
var var
tmp: TMemoryStream; tmp: TFileStreamUTF8;
begin begin
if TIM = nil then Exit; if TIM = nil then Exit;
tmp := TMemoryStream.Create; tmp := TFileStreamUTF8.Create(FileName, fmOpenWrite or fmCreate, fmShareDenyRead);
tmp.Write(TIM^.DATA^[0], TIM^.dwSize); tmp.Write(TIM^.DATA^[0], TIM^.dwSize);
tmp.SaveToFile(FileName);
tmp.Free; tmp.Free;
end; end;