mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-26 15:14:06 +02:00
Icons_to_html: protect against image file reading errors. Patch by Roland Hahn.
This commit is contained in:
parent
0631c5f508
commit
464d4133cc
@ -11,6 +11,7 @@ object MainForm: TMainForm
|
||||
Constraints.MinWidth = 700
|
||||
Position = poScreenCenter
|
||||
ShowHint = True
|
||||
LCLVersion = '4.99.0.0'
|
||||
OnClose = FormClose
|
||||
OnCreate = FormCreate
|
||||
OnDropFiles = FormDropFiles
|
||||
@ -21,9 +22,9 @@ object MainForm: TMainForm
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Control = sbtnLastDirs
|
||||
Left = 10
|
||||
Height = 27
|
||||
Height = 23
|
||||
Hint = 'Folder with images for which the HTML preview should be created'
|
||||
Top = 8
|
||||
Top = 10
|
||||
Width = 655
|
||||
ShowHidden = False
|
||||
ButtonWidth = 23
|
||||
@ -47,8 +48,8 @@ object MainForm: TMainForm
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = bbtnClose
|
||||
Left = 0
|
||||
Height = 423
|
||||
Top = 45
|
||||
Height = 426
|
||||
Top = 43
|
||||
Width = 700
|
||||
BorderSpacing.Top = 10
|
||||
BorderSpacing.Bottom = 10
|
||||
@ -554,10 +555,10 @@ object MainForm: TMainForm
|
||||
AnchorSideTop.Control = bbtnClose
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 15
|
||||
Height = 21
|
||||
Height = 19
|
||||
Hint = 'Create HTML page with dark background'
|
||||
Top = 481
|
||||
Width = 89
|
||||
Top = 483
|
||||
Width = 76
|
||||
BorderSpacing.Left = 15
|
||||
Caption = 'Dark Mode'
|
||||
TabOrder = 2
|
||||
@ -584,10 +585,10 @@ object MainForm: TMainForm
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = Owner
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 627
|
||||
Height = 27
|
||||
Top = 478
|
||||
Width = 63
|
||||
Left = 614
|
||||
Height = 26
|
||||
Top = 479
|
||||
Width = 76
|
||||
Anchors = [akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Right = 10
|
||||
@ -605,11 +606,11 @@ object MainForm: TMainForm
|
||||
AnchorSideTop.Control = bbtnClose
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Control = bbtnClose
|
||||
Left = 561
|
||||
Height = 27
|
||||
Left = 535
|
||||
Height = 26
|
||||
Hint = 'Save created HTML page as "IconTable.html" file in the specified folder'
|
||||
Top = 478
|
||||
Width = 58
|
||||
Top = 479
|
||||
Width = 71
|
||||
Anchors = [akTop, akRight]
|
||||
AutoSize = True
|
||||
BorderSpacing.Right = 8
|
||||
@ -625,11 +626,11 @@ object MainForm: TMainForm
|
||||
AnchorSideTop.Control = bbtnPreview
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Control = bbtnPreview
|
||||
Left = 361
|
||||
Height = 27
|
||||
Left = 316
|
||||
Height = 26
|
||||
Hint = 'Create HTML page for images found in the selected directory'
|
||||
Top = 478
|
||||
Width = 108
|
||||
Top = 479
|
||||
Width = 116
|
||||
Anchors = [akTop, akRight]
|
||||
AutoSize = True
|
||||
BorderSpacing.Right = 8
|
||||
@ -645,10 +646,10 @@ object MainForm: TMainForm
|
||||
object bbtnPreview: TBitBtn
|
||||
AnchorSideTop.Control = bbtnSave
|
||||
AnchorSideRight.Control = bbtnSave
|
||||
Left = 477
|
||||
Height = 27
|
||||
Top = 478
|
||||
Width = 76
|
||||
Left = 440
|
||||
Height = 26
|
||||
Top = 479
|
||||
Width = 87
|
||||
Anchors = [akTop, akRight]
|
||||
AutoSize = True
|
||||
BorderSpacing.Right = 8
|
||||
|
@ -61,13 +61,13 @@ implementation
|
||||
resourcestring
|
||||
rsInformation = 'Information';
|
||||
rsError = 'Error';
|
||||
rsTheConfigurationCouldNotBeSaved = 'Configuration file could not be saved.';
|
||||
rsTheTempFileCouldNotBeDeleted = 'Temporary file could not be deleted.';
|
||||
rsTheConfigurationCouldNotBeSaved = 'The configuration file could not be saved.';
|
||||
rsTheTempFileCouldNotBeDeleted = 'The temp file could not be deleted.';
|
||||
rsTheFileCouldNotBeSavedAs = 'The file could not be saved as: %s';
|
||||
rsSavedAs = 'Saved as: %s';
|
||||
rsNoPngImageFilesFoundIn = 'No PNG image files found in %s';
|
||||
rsNoMatchingPngImageFilesFoundIn = 'No matching PNG image files found in %s';
|
||||
rsTheFolderDoesNotExist = 'Folder "%s" does not exist or is currently not available.'+LineEnding+LineEnding+'Should it be removed from the list?';
|
||||
rsNoPngImageFilesFoundIn = 'No png image files found in %s';
|
||||
rsNoMatchingPngImageFilesFoundIn = 'No matching png image files found in %s';
|
||||
rsTheFolderDoesNotExist = 'The folder [%s] does not exist or is currently not available.'#13#13'Should it be removed from the list?';
|
||||
rsThisFolderContains = 'This folder contains %0:d icons in %1:d icon groups with %2:d icon sizes.';
|
||||
rsSize = 'Size';
|
||||
rsName = 'Name';
|
||||
@ -289,25 +289,32 @@ begin
|
||||
AllFileList.Sort;
|
||||
for i := 0 to AllFileList.Count - 1 do
|
||||
begin
|
||||
IcoFile := ChangeFileExt(ExtractFileName(AllFileList.Strings[i]), '');
|
||||
GetPixSize(AllFileList.Strings[i], IcoWidth, IcoHeight);
|
||||
IcoSize := IntToStr(IcoWidth);
|
||||
try
|
||||
GetPixSize(AllFileList.Strings[i], IcoWidth, IcoHeight);
|
||||
IcoSize := IntToStr(IcoWidth);
|
||||
except
|
||||
IcoSize := '';
|
||||
end;
|
||||
|
||||
DPos := LastDelimiter('_', IcoFile);
|
||||
if TryStrToInt(RightStr(IcoFile, Utf8Length(IcoFile) - DPos), IntDummy) then
|
||||
IcoName := Utf8Copy(IcoFile, 1, DPos - 1)
|
||||
else
|
||||
IcoName := IcoFile;
|
||||
if IcoSize <> '' then
|
||||
begin
|
||||
IcoFile := ChangeFileExt(ExtractFileName(AllFileList.Strings[i]), '');
|
||||
DPos := LastDelimiter('_', IcoFile);
|
||||
if TryStrToInt(RightStr(IcoFile, Utf8Length(IcoFile) - DPos), IntDummy) then
|
||||
IcoName := Utf8Copy(IcoFile, 1, DPos - 1)
|
||||
else
|
||||
IcoName := IcoFile;
|
||||
|
||||
if Preview then
|
||||
IcoFileList.Add('file:///' + ImgDirectory + IcoFile)
|
||||
else
|
||||
IcoFileList.Add(IcoFile);
|
||||
if Preview then
|
||||
IcoFileList.Add('file:///' + ImgDirectory + IcoFile)
|
||||
else
|
||||
IcoFileList.Add(IcoFile);
|
||||
|
||||
IcoNameList.Add(IcoName);
|
||||
IcoSizeList.Add(IcoSize);
|
||||
if PixSizeList.IndexOf(IcoSize) = -1 then
|
||||
PixSizeList.Add(IcoSize);
|
||||
IcoNameList.Add(IcoName);
|
||||
IcoSizeList.Add(IcoSize);
|
||||
if PixSizeList.IndexOf(IcoSize) = -1 then
|
||||
PixSizeList.Add(IcoSize);
|
||||
end;
|
||||
end;
|
||||
PixSizeList.CustomSort(@CustomSortProc);
|
||||
|
||||
@ -510,7 +517,7 @@ var
|
||||
begin
|
||||
stream := TFileStream.Create(FileName, fmOpenRead + fmShareDenyWrite);
|
||||
try
|
||||
reader := TFPCustomImage.FindReaderFromStream(stream);
|
||||
reader := TFPCustomImage.FindReaderFromStream(stream);
|
||||
with reader.ImageSize(stream) do
|
||||
begin
|
||||
PixWidth := X;
|
||||
|
Loading…
Reference in New Issue
Block a user