UPD: Use GifView component instead GifAnim (fixes #814)

This commit is contained in:
Alexander Koblov 2025-06-30 22:46:59 +03:00
commit ceb271de20
27 changed files with 4436 additions and 1855 deletions

View file

@ -13,7 +13,7 @@ lazbuild doublecmd\doublecmd_common.lpk %DC_ARCH%
lazbuild Image32\Image32.lpk %DC_ARCH%
lazbuild KASToolBar\kascomp.lpk %DC_ARCH%
lazbuild viewer\viewerpackage.lpk %DC_ARCH%
lazbuild gifanim\pkg_gifanim.lpk %DC_ARCH%
lazbuild gifview\gifview.lpk %DC_ARCH%
lazbuild synunihighlighter\synuni.lpk %DC_ARCH%
lazbuild virtualterminal\virtualterminal.lpk %DC_ARCH%
popd

View file

@ -31,7 +31,7 @@ $lazbuild doublecmd/doublecmd_common.lpk $DC_ARCH
$lazbuild Image32/Image32.lpk $DC_ARCH
$lazbuild KASToolBar/kascomp.lpk $DC_ARCH
$lazbuild viewer/viewerpackage.lpk $DC_ARCH
$lazbuild gifanim/pkg_gifanim.lpk $DC_ARCH
$lazbuild gifview/gifview.lpk $DC_ARCH
$lazbuild synunihighlighter/synuni.lpk $DC_ARCH
$lazbuild virtualterminal/virtualterminal.lpk $DC_ARCH
cd $basedir

View file

@ -1,370 +0,0 @@
Index: gifanim.pas
===================================================================
--- gifanim.pas (revision none)
+++ gifanim.pas (working copy)
@@ -26,7 +26,7 @@
uses
Classes, LCLProc, Lresources, SysUtils, Controls, Graphics, ExtCtrls,
- IntfGraphics, FPimage, Contnrs, GraphType, dialogs;
+ IntfGraphics, FPimage, Contnrs, GraphType, dialogs, types;
const
@@ -193,7 +193,7 @@
procedure DoAutoSize; override;
procedure DoStartAnim;
procedure DoStopAnim;
- class function GetControlClassDefaultSize: TPoint; override;
+ class function GetControlClassDefaultSize: TSize; override;
procedure GifChanged;
procedure LoadFromFile(const Filename: string); virtual;
procedure Paint; override;
@@ -203,6 +203,8 @@
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
+ procedure NextFrame;
+ procedure PriorFrame;
property Empty: boolean Read FEmpty;
property GifBitmaps: TGifList Read FGifBitmaps;
property GifIndex: integer Read FCurrentImage;
@@ -237,28 +239,9 @@
implementation
-uses LazIDEIntf, propedits;
-Type
- TGifFileNamePropertyEditor=class(TFileNamePropertyEditor)
- protected
- function GetFilter: String; override;
- function GetInitialDirectory: string; override;
- end;
-function TGifFileNamePropertyEditor.GetFilter: String;
-begin
- Result := 'GIF|*.gif';
-end;
-
-function TGifFileNamePropertyEditor.GetInitialDirectory: string;
-begin
- Result:= ExtractFilePath(LazarusIDE.ActiveProject.ProjectInfoFile);
-end;
-
procedure Register;
begin
RegisterComponents('Wile64', [TGifAnim]);
- RegisterPropertyEditor(TypeInfo(String),
- TGifAnim, 'FileName', TGifFileNamePropertyEditor);
end;
{ TGifAnim }
@@ -268,7 +251,7 @@
inherited Create(AOwner);
ControlStyle := [csCaptureMouse, csClickEvents, csDoubleClicks];
AutoSize := True;
- SetInitialBounds(0, 0, GetControlClassDefaultSize.X, GetControlClassDefaultSize.Y);
+ SetInitialBounds(0, 0, GetControlClassDefaultSize.CX, GetControlClassDefaultSize.CY);
FEmpty := True;
FCurrentImage := 0;
CurrentView := TBitmap.Create;
@@ -295,6 +278,59 @@
CurrentView.Free;
end;
+procedure TGifAnim.NextFrame;
+begin
+ if (not FEmpty) and Visible and (not FAnimate) then
+ begin
+ if FCurrentImage >= GifBitmaps.Count - 1 then
+ FCurrentImage := 0
+ else
+ Inc(FCurrentImage);
+ if Assigned(FOnFrameChanged) then
+ FOnFrameChanged(Self);
+ Repaint;
+ end;
+end;
+
+procedure TGifAnim.PriorFrame;
+var
+ DesiredImage: Integer;
+begin
+ if (not FEmpty) and Visible and (not FAnimate) then
+ begin
+ if FCurrentImage = 0 then
+ DesiredImage:= GifBitmaps.Count - 1
+ else
+ DesiredImage:= FCurrentImage - 1;
+ // For proper display repaint image from first frame to desired frame
+ FCurrentImage:= 0;
+ while FCurrentImage < DesiredImage do
+ begin
+ with GifBitmaps.Items[FCurrentImage] do
+ begin
+ BufferImg.Canvas.Brush.Color := (Self.Color);
+ if FCurrentImage = 0 then
+ BufferImg.Canvas.FillRect(Rect(0, 0, Width, Height));
+ if Delay <> 0 then
+ FWait.Interval := Delay * 10;
+ BufferImg.Canvas.Draw(PosX, PosY, Bitmap);
+ case Method of
+ //0 : Not specified...
+ //1 : No change Background
+ 2: BufferImg.Canvas.FillRect(
+ Rect(PosX, PosY, Bitmap.Width + PosX, Bitmap.Height + PosY));
+
+ 3: BufferImg.Canvas.FillRect(Rect(0, 0, Width, Height));
+ end;
+ end;
+ Inc(FCurrentImage);
+ end;
+ if Assigned(FOnFrameChanged) then
+ FOnFrameChanged(Self);
+ Repaint;
+ end;
+end;
+
function TGifAnim.LoadFromLazarusResource(const ResName: String): boolean;
var
GifLoader: TGifLoader;
@@ -340,12 +376,13 @@
begin
if (not Empty) and Visible then
begin
- if FCurrentImage > GifBitmaps.Count - 1 then
- FCurrentImage := 0;
- if assigned(FOnFrameChanged) then
- FOnFrameChanged(self);
- Paint;
- Inc(FCurrentImage);
+ if FCurrentImage >= GifBitmaps.Count - 1 then
+ FCurrentImage := 0
+ else
+ Inc(FCurrentImage);
+ if Assigned(FOnFrameChanged) then
+ FOnFrameChanged(Self);
+ Repaint;
end;
end;
@@ -365,27 +402,12 @@
end;
procedure TGifAnim.SetFileName(const AValue: string);
-var
- fn: string;
begin
-
- if (FFileName = AValue) then
- exit;
+ if (FFileName = AValue) then Exit;
FFileName := AValue;
ResetImage;
- if (FFileName = '') then exit;
- if (csDesigning in ComponentState) then
- begin
- fn:= ExtractFileName(AValue);
- FFileName:= ExtractFilePath(AValue);
- FFileName:= ExtractRelativepath(ExtractFilePath(LazarusIDE.ActiveProject.ProjectInfoFile) ,FFileName);
- FFileName:=FFileName+fn;
- LoadFromFile(FFileName+fn);
- end
- else begin
- FFileName := AValue;
- LoadFromFile(FFileName);
- end;
+ if (FFileName = '') then Exit;
+ LoadFromFile(FFileName);
if not Empty then
GifChanged;
end;
@@ -441,10 +463,10 @@
end;
end;
-class function TGifAnim.GetControlClassDefaultSize: TPoint;
+class function TGifAnim.GetControlClassDefaultSize: TSize;
begin
- Result.X := 90;
- Result.Y := 90;
+ Result.CX := 90;
+ Result.CY := 90;
end;
procedure TGifAnim.GifChanged;
Index: gifanimdsgn.pas
===================================================================
--- gifanimdsgn.pas (revision 0)
+++ gifanimdsgn.pas (revision 0)
@@ -0,0 +1,41 @@
+unit GifAnimDsgn;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ LazIDEIntf, PropEdits;
+
+Type
+ TGifFileNamePropertyEditor = class(TFileNamePropertyEditor)
+ protected
+ function GetFilter: String; override;
+ function GetInitialDirectory: string; override;
+ end;
+
+procedure Register;
+
+implementation
+
+uses
+ SysUtils, GifAnim;
+
+function TGifFileNamePropertyEditor.GetFilter: String;
+begin
+ Result := 'GIF|*.gif';
+end;
+
+function TGifFileNamePropertyEditor.GetInitialDirectory: string;
+begin
+ Result:= ExtractFilePath(LazarusIDE.ActiveProject.ProjectInfoFile);
+end;
+
+procedure Register;
+begin
+ RegisterPropertyEditor(TypeInfo(String), TGifAnim,
+ 'FileName', TGifFileNamePropertyEditor);
+end;
+
+end.
+
Index: pkg_gifanim.lpk
===================================================================
--- pkg_gifanim.lpk (revision none)
+++ pkg_gifanim.lpk (working copy)
@@ -1,15 +1,21 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
- <Package Version="3">
+ <Package Version="4">
<PathDelim Value="\"/>
<Name Value="pkg_gifanim"/>
+ <AddToProjectUsesSection Value="True"/>
<Author Value="Laurent Jacques"/>
<CompilerOptions>
- <Version Value="8"/>
+ <Version Value="11"/>
<PathDelim Value="\"/>
<SearchPaths>
- <OtherUnitFiles Value="$(LazarusDir)\ide\"/>
+ <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
+ <Linking>
+ <Debugging>
+ <DebugInfoType Value="dsDwarf2Set"/>
+ </Debugging>
+ </Linking>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
@@ -33,15 +39,16 @@
<Type Value="RunAndDesignTime"/>
<RequiredPkgs Count="2">
<Item1>
- <PackageName Value="FCL"/>
+ <PackageName Value="LCL"/>
<MinVersion Major="1" Valid="True"/>
</Item1>
<Item2>
- <PackageName Value="IDEIntf"/>
+ <PackageName Value="FCL"/>
+ <MinVersion Major="1" Valid="True"/>
</Item2>
</RequiredPkgs>
<UsageOptions>
- <UnitPath Value="$(PkgOutDir)\"/>
+ <UnitPath Value="$(PkgOutDir)"/>
</UsageOptions>
<PublishOptions>
<Version Value="2"/>
Index: pkg_gifanim_dsgn.lpk
===================================================================
--- pkg_gifanim_dsgn.lpk (revision 0)
+++ pkg_gifanim_dsgn.lpk (revision 0)
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<CONFIG>
+ <Package Version="4">
+ <PathDelim Value="\"/>
+ <Name Value="pkg_gifanim_dsgn"/>
+ <CompilerOptions>
+ <Version Value="11"/>
+ <PathDelim Value="\"/>
+ <SearchPaths>
+ <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
+ </SearchPaths>
+ <Linking>
+ <Debugging>
+ <DebugInfoType Value="dsDwarf2Set"/>
+ </Debugging>
+ </Linking>
+ <Other>
+ <CompilerMessages>
+ <MsgFileName Value=""/>
+ </CompilerMessages>
+ <CompilerPath Value="$(CompPath)"/>
+ </Other>
+ </CompilerOptions>
+ <License Value="GPL"/>
+ <Version Major="1" Minor="4"/>
+ <Files Count="1">
+ <Item1>
+ <Filename Value="gifanimdsgn.pas"/>
+ <HasRegisterProc Value="True"/>
+ <UnitName Value="GifAnimDsgn"/>
+ </Item1>
+ </Files>
+ <Type Value="DesignTime"/>
+ <RequiredPkgs Count="2">
+ <Item1>
+ <PackageName Value="IDEIntf"/>
+ </Item1>
+ <Item2>
+ <PackageName Value="pkg_gifanim"/>
+ </Item2>
+ </RequiredPkgs>
+ <UsageOptions>
+ <UnitPath Value="$(PkgOutDir)"/>
+ </UsageOptions>
+ <PublishOptions>
+ <Version Value="2"/>
+ </PublishOptions>
+ </Package>
+</CONFIG>
Index: pkg_gifanim_dsgn.pas
===================================================================
--- pkg_gifanim_dsgn.pas (revision 0)
+++ pkg_gifanim_dsgn.pas (revision 0)
@@ -0,0 +1,21 @@
+{ This file was automatically created by Lazarus. Do not edit!
+ This source is only used to compile and install the package.
+ }
+
+unit pkg_gifanim_dsgn;
+
+interface
+
+uses
+ GifAnimDsgn, LazarusPackageIntf;
+
+implementation
+
+procedure Register;
+begin
+ RegisterUnit('GifAnimDsgn', @GifAnimDsgn.Register);
+end;
+
+initialization
+ RegisterPackage('pkg_gifanim_dsgn', @Register);
+end.

View file

@ -1,25 +0,0 @@
LazarusResources.Add('tgifanim','XPM',[
'/* XPM */'#13#10'static char * gifanim_xpm[] = {'#13#10'"24 24 31 1",'#13#10
+'" '#9'c None",'#13#10'".'#9'c #959595",'#13#10'"+'#9'c #E1E1E1",'#13#10'"@'
+#9'c #919191",'#13#10'"#'#9'c #848484",'#13#10'"$'#9'c #888888",'#13#10'"%'#9
+'c #EEEEEE",'#13#10'"&'#9'c #E6E9EC",'#13#10'"*'#9'c #D6DFE8",'#13#10'"='#9
+'c #FFFFFF",'#13#10'"-'#9'c #E7F0F9",'#13#10'";'#9'c #3783CE",'#13#10'">'#9
+'c #FFF7F7",'#13#10'",'#9'c #FFEFEF",'#13#10'"'''#9'c #F7F2F5",'#13#10'")'#9
+'c #F7FAFD",'#13#10'"!'#9'c #FF5757",'#13#10'"~'#9'c #FFDFDF",'#13#10'"{'#9
+'c #FF4F4F",'#13#10'"]'#9'c #FFD7D7",'#13#10'"^'#9'c #FF4747",'#13#10'"/'#9
+'c #FF3F3F",'#13#10'"('#9'c #8D8D8D",'#13#10'"_'#9'c #EEE6E6",'#13#10'":'#9
+'c #EED6D6",'#13#10'"<'#9'c #EECECE",'#13#10'"['#9'c #FAFAFA",'#13#10'"}'#9
+'c #F2F2F2",'#13#10'"|'#9'c #F6F6F6",'#13#10'"1'#9'c #A2A2A2",'#13#10'"2'#9
+'c #FAF2F2",'#13#10'" .++@ @++. ",'#13#10'" @@@##$$$$$$$$$$$$##'
+'@@@ ",'#13#10'" .++$#$$$$$$$$$$$$#$++. ",'#13#10'" .++@+%%&**&&**&%%+@++. "'
+','#13#10'" @@@@%==-;;--;;-==%@@@@ ",'#13#10'" .++.%==-;;--;;-==%.++. ",'#13
+#10'" .++.%>,''--))--'',>%.++. ",'#13#10'" @@@@%,!~>====>~!,%@@@@ ",'#13#10
+'" .++.%>~{]~~~~]{~>%.++. ",'#13#10'" .++.%=>~^////^~>=%.++. ",'#13#10'" @@@'
+'(+%%_:<<<<:_%%+(@@@ ",'#13#10'" .++$#$$$$$$$$$$$$#$++. ",'#13#10'" .++$#$$$'
+'$$$$$$$$$#$++. ",'#13#10'" @@@(+%%&**&%%%%%%+(@@@ ",'#13#10'" .++.%==-;;-[}'
+'}[==%.++. ",'#13#10'" .++.%==-;;-|11|==%.++. ",'#13#10'" @@@@%>,''--)[}}2,>'
+'%@@@@ ",'#13#10'" .++.%,!~>====>~!,%.++. ",'#13#10'" .++.%>~{]~~~~]{~>%.++.'
+' ",'#13#10'" @@@@%=>~^////^~>=%@@@@ ",'#13#10'" .++@+%%_:<<<<:_%%+@++. ",'
+#13#10'" .++$#$$$$$$$$$$$$#$++. ",'#13#10'" @@@##$$$$$$$$$$$$##@@@ ",'#13#10
+'" .++@ @++. "};'#13#10
]);

File diff suppressed because it is too large Load diff

View file

@ -1,41 +0,0 @@
unit GifAnimDsgn;
{$mode objfpc}{$H+}
interface
uses
LazIDEIntf, PropEdits;
Type
TGifFileNamePropertyEditor = class(TFileNamePropertyEditor)
protected
function GetFilter: String; override;
function GetInitialDirectory: string; override;
end;
procedure Register;
implementation
uses
SysUtils, GifAnim;
function TGifFileNamePropertyEditor.GetFilter: String;
begin
Result := 'GIF|*.gif';
end;
function TGifFileNamePropertyEditor.GetInitialDirectory: string;
begin
Result:= ExtractFilePath(LazarusIDE.ActiveProject.ProjectInfoFile);
end;
procedure Register;
begin
RegisterPropertyEditor(TypeInfo(String), TGifAnim,
'FileName', TGifFileNamePropertyEditor);
end;
end.

View file

@ -1,58 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<Package Version="4">
<PathDelim Value="\"/>
<Name Value="pkg_gifanim"/>
<AddToProjectUsesSection Value="True"/>
<Author Value="Laurent Jacques"/>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<SearchPaths>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Debugging>
<DebugInfoType Value="dsDwarf2Set"/>
</Debugging>
</Linking>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Description Value="Show Gif Animation
"/>
<License Value="GPL
"/>
<Version Major="1" Minor="5"/>
<Files Count="2">
<Item1>
<Filename Value="gifanim.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="GifAnim"/>
</Item1>
<Item2>
<Filename Value="gifanim.lrs"/>
<Type Value="LRS"/>
</Item2>
</Files>
<Type Value="RunAndDesignTime"/>
<RequiredPkgs Count="2">
<Item1>
<PackageName Value="LCL"/>
<MinVersion Major="1" Valid="True"/>
</Item1>
<Item2>
<PackageName Value="FCL"/>
<MinVersion Major="1" Valid="True"/>
</Item2>
</RequiredPkgs>
<UsageOptions>
<UnitPath Value="$(PkgOutDir)"/>
</UsageOptions>
<PublishOptions>
<Version Value="2"/>
<IgnoreBinaries Value="False"/>
</PublishOptions>
</Package>
</CONFIG>

View file

@ -1,21 +0,0 @@
{ This file was automatically created by Lazarus. Do not edit!
This source is only used to compile and install the package.
}
unit pkg_gifanim;
interface
uses
GifAnim, LazarusPackageIntf;
implementation
procedure Register;
begin
RegisterUnit('GifAnim', @GifAnim.Register);
end;
initialization
RegisterPackage('pkg_gifanim', @Register);
end.

View file

@ -1,49 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<Package Version="4">
<PathDelim Value="\"/>
<Name Value="pkg_gifanim_dsgn"/>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<SearchPaths>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Debugging>
<DebugInfoType Value="dsDwarf2Set"/>
</Debugging>
</Linking>
<Other>
<CompilerMessages>
<MsgFileName Value=""/>
</CompilerMessages>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<License Value="GPL"/>
<Version Major="1" Minor="4"/>
<Files Count="1">
<Item1>
<Filename Value="gifanimdsgn.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="GifAnimDsgn"/>
</Item1>
</Files>
<Type Value="DesignTime"/>
<RequiredPkgs Count="2">
<Item1>
<PackageName Value="IDEIntf"/>
</Item1>
<Item2>
<PackageName Value="pkg_gifanim"/>
</Item2>
</RequiredPkgs>
<UsageOptions>
<UnitPath Value="$(PkgOutDir)"/>
</UsageOptions>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
</Package>
</CONFIG>

View file

@ -1,21 +0,0 @@
{ This file was automatically created by Lazarus. Do not edit!
This source is only used to compile and install the package.
}
unit pkg_gifanim_dsgn;
interface
uses
GifAnimDsgn, LazarusPackageIntf;
implementation
procedure Register;
begin
RegisterUnit('GifAnimDsgn', @GifAnimDsgn.Register);
end;
initialization
RegisterPackage('pkg_gifanim_dsgn', @Register);
end.

View file

@ -1,5 +0,0 @@
GifAnim
http://wile64.perso.neuf.fr/download/download.php?cat=4&id=8
Version 1.4 (14/09/2009)
Some modifications done for Double Commander (see doublecmd.diff).

View file

@ -1,28 +0,0 @@
1) Gif in ressource file
-------------------------
- Create ressource file with lazres ex : lazres mygif.lrs gif1.gif gif2.gif
- Put TGifAnim on your form
- In the FormCreate add (see down)
[code]
procedure TForm1.FormCreate(Sender: TObject);
begin
GifAnim1.LoadFromLazarusResource('gif1');
GifAnim2.LoadFromLazarusResource('gif2');
end;
[/code]
- And insert ressouce file in initialization section (see down)
[code]
initialization
{$I unit1.lrs}
{$I mesgif.lrs}
[/code]

View file

@ -1,58 +0,0 @@
/* XPM */
static char * gifanim_xpm[] = {
"24 24 31 1",
" c None",
". c #959595",
"+ c #E1E1E1",
"@ c #919191",
"# c #848484",
"$ c #888888",
"% c #EEEEEE",
"& c #E6E9EC",
"* c #D6DFE8",
"= c #FFFFFF",
"- c #E7F0F9",
"; c #3783CE",
"> c #FFF7F7",
", c #FFEFEF",
"' c #F7F2F5",
") c #F7FAFD",
"! c #FF5757",
"~ c #FFDFDF",
"{ c #FF4F4F",
"] c #FFD7D7",
"^ c #FF4747",
"/ c #FF3F3F",
"( c #8D8D8D",
"_ c #EEE6E6",
": c #EED6D6",
"< c #EECECE",
"[ c #FAFAFA",
"} c #F2F2F2",
"| c #F6F6F6",
"1 c #A2A2A2",
"2 c #FAF2F2",
" .++@ @++. ",
" @@@##$$$$$$$$$$$$##@@@ ",
" .++$#$$$$$$$$$$$$#$++. ",
" .++@+%%&**&&**&%%+@++. ",
" @@@@%==-;;--;;-==%@@@@ ",
" .++.%==-;;--;;-==%.++. ",
" .++.%>,'--))--',>%.++. ",
" @@@@%,!~>====>~!,%@@@@ ",
" .++.%>~{]~~~~]{~>%.++. ",
" .++.%=>~^////^~>=%.++. ",
" @@@(+%%_:<<<<:_%%+(@@@ ",
" .++$#$$$$$$$$$$$$#$++. ",
" .++$#$$$$$$$$$$$$#$++. ",
" @@@(+%%&**&%%%%%%+(@@@ ",
" .++.%==-;;-[}}[==%.++. ",
" .++.%==-;;-|11|==%.++. ",
" @@@@%>,'--)[}}2,>%@@@@ ",
" .++.%,!~>====>~!,%.++. ",
" .++.%>~{]~~~~]{~>%.++. ",
" @@@@%=>~^////^~>=%@@@@ ",
" .++@+%%_:<<<<:_%%+@++. ",
" .++$#$$$$$$$$$$$$#$++. ",
" @@@##$$$$$$$$$$$$##@@@ ",
" .++@ @++. "};

View file

@ -0,0 +1,373 @@
Mozilla Public License Version 2.0
==================================
1. Definitions
--------------
1.1. "Contributor"
means each individual or legal entity that creates, contributes to
the creation of, or owns Covered Software.
1.2. "Contributor Version"
means the combination of the Contributions of others (if any) used
by a Contributor and that particular Contributor's Contribution.
1.3. "Contribution"
means Covered Software of a particular Contributor.
1.4. "Covered Software"
means Source Code Form to which the initial Contributor has attached
the notice in Exhibit A, the Executable Form of such Source Code
Form, and Modifications of such Source Code Form, in each case
including portions thereof.
1.5. "Incompatible With Secondary Licenses"
means
(a) that the initial Contributor has attached the notice described
in Exhibit B to the Covered Software; or
(b) that the Covered Software was made available under the terms of
version 1.1 or earlier of the License, but not also under the
terms of a Secondary License.
1.6. "Executable Form"
means any form of the work other than Source Code Form.
1.7. "Larger Work"
means a work that combines Covered Software with other material, in
a separate file or files, that is not Covered Software.
1.8. "License"
means this document.
1.9. "Licensable"
means having the right to grant, to the maximum extent possible,
whether at the time of the initial grant or subsequently, any and
all of the rights conveyed by this License.
1.10. "Modifications"
means any of the following:
(a) any file in Source Code Form that results from an addition to,
deletion from, or modification of the contents of Covered
Software; or
(b) any new file in Source Code Form that contains any Covered
Software.
1.11. "Patent Claims" of a Contributor
means any patent claim(s), including without limitation, method,
process, and apparatus claims, in any patent Licensable by such
Contributor that would be infringed, but for the grant of the
License, by the making, using, selling, offering for sale, having
made, import, or transfer of either its Contributions or its
Contributor Version.
1.12. "Secondary License"
means either the GNU General Public License, Version 2.0, the GNU
Lesser General Public License, Version 2.1, the GNU Affero General
Public License, Version 3.0, or any later versions of those
licenses.
1.13. "Source Code Form"
means the form of the work preferred for making modifications.
1.14. "You" (or "Your")
means an individual or a legal entity exercising rights under this
License. For legal entities, "You" includes any entity that
controls, is controlled by, or is under common control with You. For
purposes of this definition, "control" means (a) the power, direct
or indirect, to cause the direction or management of such entity,
whether by contract or otherwise, or (b) ownership of more than
fifty percent (50%) of the outstanding shares or beneficial
ownership of such entity.
2. License Grants and Conditions
--------------------------------
2.1. Grants
Each Contributor hereby grants You a world-wide, royalty-free,
non-exclusive license:
(a) under intellectual property rights (other than patent or trademark)
Licensable by such Contributor to use, reproduce, make available,
modify, display, perform, distribute, and otherwise exploit its
Contributions, either on an unmodified basis, with Modifications, or
as part of a Larger Work; and
(b) under Patent Claims of such Contributor to make, use, sell, offer
for sale, have made, import, and otherwise transfer either its
Contributions or its Contributor Version.
2.2. Effective Date
The licenses granted in Section 2.1 with respect to any Contribution
become effective for each Contribution on the date the Contributor first
distributes such Contribution.
2.3. Limitations on Grant Scope
The licenses granted in this Section 2 are the only rights granted under
this License. No additional rights or licenses will be implied from the
distribution or licensing of Covered Software under this License.
Notwithstanding Section 2.1(b) above, no patent license is granted by a
Contributor:
(a) for any code that a Contributor has removed from Covered Software;
or
(b) for infringements caused by: (i) Your and any other third party's
modifications of Covered Software, or (ii) the combination of its
Contributions with other software (except as part of its Contributor
Version); or
(c) under Patent Claims infringed by Covered Software in the absence of
its Contributions.
This License does not grant any rights in the trademarks, service marks,
or logos of any Contributor (except as may be necessary to comply with
the notice requirements in Section 3.4).
2.4. Subsequent Licenses
No Contributor makes additional grants as a result of Your choice to
distribute the Covered Software under a subsequent version of this
License (see Section 10.2) or under the terms of a Secondary License (if
permitted under the terms of Section 3.3).
2.5. Representation
Each Contributor represents that the Contributor believes its
Contributions are its original creation(s) or it has sufficient rights
to grant the rights to its Contributions conveyed by this License.
2.6. Fair Use
This License is not intended to limit any rights You have under
applicable copyright doctrines of fair use, fair dealing, or other
equivalents.
2.7. Conditions
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
in Section 2.1.
3. Responsibilities
-------------------
3.1. Distribution of Source Form
All distribution of Covered Software in Source Code Form, including any
Modifications that You create or to which You contribute, must be under
the terms of this License. You must inform recipients that the Source
Code Form of the Covered Software is governed by the terms of this
License, and how they can obtain a copy of this License. You may not
attempt to alter or restrict the recipients' rights in the Source Code
Form.
3.2. Distribution of Executable Form
If You distribute Covered Software in Executable Form then:
(a) such Covered Software must also be made available in Source Code
Form, as described in Section 3.1, and You must inform recipients of
the Executable Form how they can obtain a copy of such Source Code
Form by reasonable means in a timely manner, at a charge no more
than the cost of distribution to the recipient; and
(b) You may distribute such Executable Form under the terms of this
License, or sublicense it under different terms, provided that the
license for the Executable Form does not attempt to limit or alter
the recipients' rights in the Source Code Form under this License.
3.3. Distribution of a Larger Work
You may create and distribute a Larger Work under terms of Your choice,
provided that You also comply with the requirements of this License for
the Covered Software. If the Larger Work is a combination of Covered
Software with a work governed by one or more Secondary Licenses, and the
Covered Software is not Incompatible With Secondary Licenses, this
License permits You to additionally distribute such Covered Software
under the terms of such Secondary License(s), so that the recipient of
the Larger Work may, at their option, further distribute the Covered
Software under the terms of either this License or such Secondary
License(s).
3.4. Notices
You may not remove or alter the substance of any license notices
(including copyright notices, patent notices, disclaimers of warranty,
or limitations of liability) contained within the Source Code Form of
the Covered Software, except that You may alter any license notices to
the extent required to remedy known factual inaccuracies.
3.5. Application of Additional Terms
You may choose to offer, and to charge a fee for, warranty, support,
indemnity or liability obligations to one or more recipients of Covered
Software. However, You may do so only on Your own behalf, and not on
behalf of any Contributor. You must make it absolutely clear that any
such warranty, support, indemnity, or liability obligation is offered by
You alone, and You hereby agree to indemnify every Contributor for any
liability incurred by such Contributor as a result of warranty, support,
indemnity or liability terms You offer. You may include additional
disclaimers of warranty and limitations of liability specific to any
jurisdiction.
4. Inability to Comply Due to Statute or Regulation
---------------------------------------------------
If it is impossible for You to comply with any of the terms of this
License with respect to some or all of the Covered Software due to
statute, judicial order, or regulation then You must: (a) comply with
the terms of this License to the maximum extent possible; and (b)
describe the limitations and the code they affect. Such description must
be placed in a text file included with all distributions of the Covered
Software under this License. Except to the extent prohibited by statute
or regulation, such description must be sufficiently detailed for a
recipient of ordinary skill to be able to understand it.
5. Termination
--------------
5.1. The rights granted under this License will terminate automatically
if You fail to comply with any of its terms. However, if You become
compliant, then the rights granted under this License from a particular
Contributor are reinstated (a) provisionally, unless and until such
Contributor explicitly and finally terminates Your grants, and (b) on an
ongoing basis, if such Contributor fails to notify You of the
non-compliance by some reasonable means prior to 60 days after You have
come back into compliance. Moreover, Your grants from a particular
Contributor are reinstated on an ongoing basis if such Contributor
notifies You of the non-compliance by some reasonable means, this is the
first time You have received notice of non-compliance with this License
from such Contributor, and You become compliant prior to 30 days after
Your receipt of the notice.
5.2. If You initiate litigation against any entity by asserting a patent
infringement claim (excluding declaratory judgment actions,
counter-claims, and cross-claims) alleging that a Contributor Version
directly or indirectly infringes any patent, then the rights granted to
You by any and all Contributors for the Covered Software under Section
2.1 of this License shall terminate.
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
end user license agreements (excluding distributors and resellers) which
have been validly granted by You or Your distributors under this License
prior to termination shall survive termination.
************************************************************************
* *
* 6. Disclaimer of Warranty *
* ------------------------- *
* *
* Covered Software is provided under this License on an "as is" *
* basis, without warranty of any kind, either expressed, implied, or *
* statutory, including, without limitation, warranties that the *
* Covered Software is free of defects, merchantable, fit for a *
* particular purpose or non-infringing. The entire risk as to the *
* quality and performance of the Covered Software is with You. *
* Should any Covered Software prove defective in any respect, You *
* (not any Contributor) assume the cost of any necessary servicing, *
* repair, or correction. This disclaimer of warranty constitutes an *
* essential part of this License. No use of any Covered Software is *
* authorized under this License except under this disclaimer. *
* *
************************************************************************
************************************************************************
* *
* 7. Limitation of Liability *
* -------------------------- *
* *
* Under no circumstances and under no legal theory, whether tort *
* (including negligence), contract, or otherwise, shall any *
* Contributor, or anyone who distributes Covered Software as *
* permitted above, be liable to You for any direct, indirect, *
* special, incidental, or consequential damages of any character *
* including, without limitation, damages for lost profits, loss of *
* goodwill, work stoppage, computer failure or malfunction, or any *
* and all other commercial damages or losses, even if such party *
* shall have been informed of the possibility of such damages. This *
* limitation of liability shall not apply to liability for death or *
* personal injury resulting from such party's negligence to the *
* extent applicable law prohibits such limitation. Some *
* jurisdictions do not allow the exclusion or limitation of *
* incidental or consequential damages, so this exclusion and *
* limitation may not apply to You. *
* *
************************************************************************
8. Litigation
-------------
Any litigation relating to this License may be brought only in the
courts of a jurisdiction where the defendant maintains its principal
place of business and such litigation shall be governed by laws of that
jurisdiction, without reference to its conflict-of-law provisions.
Nothing in this Section shall prevent a party's ability to bring
cross-claims or counter-claims.
9. Miscellaneous
----------------
This License represents the complete agreement concerning the subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. Any law or regulation which provides
that the language of a contract shall be construed against the drafter
shall not be used to construe this License against a Contributor.
10. Versions of the License
---------------------------
10.1. New Versions
Mozilla Foundation is the license steward. Except as provided in Section
10.3, no one other than the license steward has the right to modify or
publish new versions of this License. Each version will be given a
distinguishing version number.
10.2. Effect of New Versions
You may distribute the Covered Software under the terms of the version
of the License under which You originally received the Covered Software,
or under the terms of any subsequent version published by the license
steward.
10.3. Modified Versions
If you create software not governed by this License, and you want to
create a new license for such software, you may create and use a
modified version of this License if you rename the license and remove
any references to the name of the license steward (except to note that
such modified license differs from this License).
10.4. Distributing Source Code Form that is Incompatible With Secondary
Licenses
If You choose to distribute Source Code Form that is Incompatible With
Secondary Licenses under the terms of this version of the License, the
notice described in Exhibit B of this License must be attached.
Exhibit A - Source Code Form License Notice
-------------------------------------------
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
If it is not possible or desirable to put the notice in a particular
file, then You may include the notice in a location (such as a LICENSE
file in a relevant directory) where a recipient would be likely to look
for such a notice.
You may add additional accurate notices of copyright ownership.
Exhibit B - "Incompatible With Secondary Licenses" Notice
---------------------------------------------------------
This Source Code Form is "Incompatible With Secondary Licenses", as
defined by the Mozilla Public License, v. 2.0.

View file

@ -0,0 +1,15 @@
GifView
Animated GIF Viewer Component
Copyright (C) 2025 Alexander Koblov
License:
MPL 2.0
Based on:
TGIFViewer
https://github.com/jdelauney/TGIFViewer
Original author:
Copyright (C) 2018 J.Delauney (BeanzMaster)

View file

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<Package Version="5">
<PathDelim Value="\"/>
<Name Value="GifView"/>
<Type Value="RunAndDesignTime"/>
<Author Value="Jérôme Delauney (BeanzMaster), Alexander Koblov"/>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<SearchPaths>
<OtherUnitFiles Value="source"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Debugging>
<DebugInfoType Value="dsDwarf2Set"/>
</Debugging>
</Linking>
</CompilerOptions>
<Description Value="GIF Viewer"/>
<License Value="MPL-2.0"/>
<Version Major="1"/>
<Files>
<Item>
<Filename Value="source\GifViewerStrConsts.pas"/>
<UnitName Value="GifViewerStrConsts"/>
</Item>
<Item>
<Filename Value="source\uFastBitmap.pas"/>
<UnitName Value="uFastBitmap"/>
</Item>
<Item>
<Filename Value="source\uGifViewer.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="uGifViewer"/>
</Item>
</Files>
<RequiredPkgs>
<Item>
<PackageName Value="LCL"/>
<MinVersion Major="2" Minor="2" Valid="True"/>
</Item>
<Item>
<PackageName Value="FCL"/>
</Item>
</RequiredPkgs>
<UsageOptions>
<UnitPath Value="$(PkgOutDir)"/>
</UsageOptions>
<PublishOptions>
<Version Value="2"/>
<UseFileFilters Value="True"/>
</PublishOptions>
</Package>
</CONFIG>

View file

@ -0,0 +1,22 @@
{ This file was automatically created by Lazarus. Do not edit!
This source is only used to compile and install the package.
}
unit GifView;
{$warn 5023 off : no warning about unused units}
interface
uses
GifViewerStrConsts, uFastBitmap, uGifViewer, LazarusPackageIntf;
implementation
procedure Register;
begin
RegisterUnit('uGifViewer', @uGifViewer.Register);
end;
initialization
RegisterPackage('GifView', @Register);
end.

Binary file not shown.

View file

@ -0,0 +1,36 @@
Unit GifViewerStrConsts;
{$mode objfpc}{$H+}
Interface
ResourceString
// Messages d'erreurs ou de notifications
// Error or notification messages
//uGifViewer
rsScreenBadColorSize = 'Invalid number of colors in the global palette.';
rsImageBadColorSize = 'Number of colors is invalid in local palette.';
rsBadSignature = 'GIF invalid signature: %s';
rsBadScreenSize = 'Invalid image size: %dx%d';
rsEmptyColorMap = 'Error no palette of color available for this image!';
rsEmptyImage = 'The picture is empty';
rsUnknownVersion = 'Unknown GIF version';
rsFileNotFound = 'The file %s not found !';
rsResourceNotFound = 'Resource %s not found!';
rsBufferOverFlow = 'Image #%d: The decoder has been stopped to prevent a buffer overflow';
rsInvalidOutputBufferSize = 'Image #%d: The size of the output buffer is invalid (size < = 0)';
rsInvalidInputBufferSize = 'Image #%d: The size of the input buffer is invalid (size < = 0)';
rsInvalidBufferSize = 'Image #%d: The size of the input and output buffer are invalid (size < = 0)';
rsLZWInternalErrorOutputBufferOverflow = 'Output buffer overflow in the GIF LZW decoder buffer. Report this bug. This is a serious bug!';
rsLZWInternalErrorInputBufferOverflow = 'Input buffer overflow in the GIF LZW decoder. Report this bug. This is a serious bug!';
rsLZWInvalidInput = 'Image #%d: The decoder encountered an invalid entry (corrupted data)';
rsLZWOutputBufferTooSmall = 'Image #%d: The decoder could not decode all the data because the output buffer is too small';
rsAllFrameCorrupted = 'All images in the GIF are corrupted. Unable to display GIF file.';
//uFastBitmap
rsBitmapCreateError = 'An Error occured while creating TBitmap';
rsBitmapScanlineOutOfRange = 'Scanline : Index Out of range';
Implementation
End.

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 975 B

View file

@ -15,7 +15,7 @@ directory of DC sources. You must open each .lpk package file:
- multithreadprocs/multithreadprocslaz.lpk
- kascrypt/kascrypt.lpk
- doublecmd/doublecmd_common.lpk
- gifanim/pkg_gifanim.lpk
- gifview/gifview.lpk
- KASToolBar/kascomp.lpk
- synunihighlighter/synuni.lpk
- viewer/viewerpackage.lpk

View file

@ -19,7 +19,7 @@ const
'components\Image32\Image32.lpk',
'components\KASToolBar\kascomp.lpk',
'components\viewer\viewerpackage.lpk',
'components\gifanim\pkg_gifanim.lpk',
'components\gifview\gifview.lpk',
'components\synunihighlighter\synuni.lpk',
'components\virtualterminal\virtualterminal.lpk'
);

View file

@ -299,8 +299,7 @@ end;"/>
<MinVersion Valid="True"/>
</Item5>
<Item6>
<PackageName Value="pkg_gifanim"/>
<MinVersion Major="1" Minor="5" Valid="True"/>
<PackageName Value="GifView"/>
</Item6>
<Item7>
<PackageName Value="VirtualTerminal"/>

View file

@ -371,7 +371,6 @@ object frmViewer: TfrmViewer
ParentFont = False
TabOrder = 3
Visible = False
OnResize = pnlImageResize
object sboxImage: TScrollBox
Left = 0
Height = 307
@ -389,6 +388,7 @@ object frmViewer: TfrmViewer
OnMouseEnter = sboxImageMouseEnter
OnMouseLeave = sboxImageMouseLeave
OnMouseMove = sboxImageMouseMove
OnResize = sboxImageResize
object Image: TImage
Left = 56
Height = 288
@ -407,12 +407,22 @@ object frmViewer: TfrmViewer
OnMouseWheelUp = ImageMouseWheelUp
Proportional = True
end
object GifAnim: TGifAnim
object GifAnim: TGIFView
Left = 0
Height = 90
Top = 0
Width = 106
AutoSize = False
Border = False
BorderColor = clBlack
BorderWidth = 0
BevelOuter = bvNone
AutoPlay = False
Transparent = True
Center = False
AutoStretchMode = smManual
Stretch = True
DisplayInvalidFrames = False
AutoRemoveInvalidFrame = True
OnMouseDown = GifAnimMouseDown
OnMouseEnter = GifAnimMouseEnter
end

View file

@ -58,7 +58,7 @@ interface
uses
SysUtils, Classes, Graphics, Controls, Forms, ExtCtrls, ComCtrls, LMessages,
LCLProc, Menus, Dialogs, ExtDlgs, StdCtrls, Buttons, SynEditHighlighter,
Grids, ActnList, viewercontrol, GifAnim, fFindView, WLXPlugin, uWLXModule,
Grids, ActnList, viewercontrol, uGifViewer, fFindView, WLXPlugin, uWLXModule,
uFileSource, fModView, Types, uThumbnails, uFormCommands, uOSForms,Clipbrd,
uExifReader, KASStatusBar, SynEdit, uShowForm, uRegExpr, uRegExprU,
Messages, fEditSearch, uMasks, uSearchTemplate, uFileSourceOperation,
@ -159,7 +159,7 @@ type
btnPrev1: TSpeedButton;
btnReload1: TSpeedButton;
DrawPreview: TDrawGrid;
GifAnim: TGifAnim;
GifAnim: TGIFView;
memFolder: TMemo;
mnuPlugins: TMenuItem;
miCode: TMenuItem;
@ -315,7 +315,6 @@ type
procedure miPenClick(Sender: TObject);
procedure miLookBookClick(Sender: TObject);
procedure pmEditMenuPopup(Sender: TObject);
procedure pnlImageResize(Sender: TObject);
procedure miPluginsClick(Sender: TObject);
procedure pnlTextMouseWheelUp(Sender: TObject; Shift: TShiftState;
@ -325,6 +324,7 @@ type
procedure sboxImageMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure btnNextGifFrameClick(Sender: TObject);
procedure sboxImageResize(Sender: TObject);
procedure SplitterChangeBounds;
procedure TimerReloadTimer(Sender: TObject);
procedure TimerScreenshotTimer(Sender: TObject);
@ -351,6 +351,7 @@ type
procedure UpdateImagePlacement;
procedure StartCalcFolderSize;
procedure StopCalcFolderSize;
procedure UpdateAnimState;
private
FFileName: String;
@ -2061,11 +2062,6 @@ begin
end;
end;
procedure TfrmViewer.pnlImageResize(Sender: TObject);
begin
if bImage then AdjustImageSize;
end;
procedure TfrmViewer.miPluginsClick(Sender: TObject);
var
ShowFlags: Integer;
@ -2117,10 +2113,27 @@ begin
end;
end;
procedure TfrmViewer.UpdateAnimState;
begin
btnPrevGifFrame.Enabled:= GifAnim.Paused and (GifAnim.CurrentFrameIndex > 0);
btnNextGifFrame.Enabled:= GifAnim.Paused and (GifAnim.CurrentFrameIndex < GifAnim.FrameCount - 1);
end;
procedure TfrmViewer.btnPrevGifFrameClick(Sender: TObject);
begin
GifAnim.PriorFrame;
UpdateAnimState;
end;
procedure TfrmViewer.btnNextGifFrameClick(Sender: TObject);
begin
GifAnim.Animate:=false;
GifAnim.NextFrame;
UpdateAnimState;
end;
procedure TfrmViewer.sboxImageResize(Sender: TObject);
begin
if bImage or bAnimation then AdjustImageSize;
end;
procedure TfrmViewer.SplitterChangeBounds;
@ -2289,6 +2302,10 @@ begin
UndoTmp;
end;
AdjustImageSize;
end
else if bAnimation then
begin
AdjustImageSize;
end;
end;
@ -2414,8 +2431,6 @@ begin
FixFormIcon(Handle);
GifAnim.Align:=alClient;
for Index:= 1 to 25 do
begin
MenuItem:= TMenuItem.Create(btnPenWidth);
@ -2521,24 +2536,26 @@ end;
procedure TfrmViewer.btnGifMoveClick(Sender: TObject);
begin
GifAnim.Animate:=not GifAnim.Animate;
btnNextGifFrame.Enabled:= not GifAnim.Animate;
btnPrevGifFrame.Enabled:= not GifAnim.Animate;
if GifAnim.Animate then
btnGifMove.ImageIndex:= 11
if GifAnim.Paused then
GifAnim.Start
else begin
btnGifMove.ImageIndex:= 12
GifAnim.Pause;
end;
if GifAnim.Paused then
btnGifMove.ImageIndex:= 12
else begin
btnGifMove.ImageIndex:= 11
end;
UpdateAnimState;
end;
procedure TfrmViewer.btnGifToBmpClick(Sender: TObject);
begin
GifAnim.Animate:=False;
Image.Picture.Bitmap.Create;
Image.Picture.Bitmap.Width := GifAnim.Width;
Image.Picture.Bitmap.Height := GifAnim.Height;
Image.Picture.Bitmap.Canvas.CopyRect(Rect(0,0,GifAnim.Width,GifAnim.Height),GifAnim.Canvas,Rect(0,0,GifAnim.Width,GifAnim.Height));
GifAnim.Pause;
btnGifMove.ImageIndex:= 12;
Image.Picture.Bitmap:= GifAnim.CurrentView;
cm_SaveAs(['']);
UpdateAnimState;
end;
procedure TfrmViewer.btnPaintHightlight(Sender: TObject);
@ -2602,12 +2619,6 @@ begin
btnPenMode.Down:= not btnPenMode.Down;
end;
procedure TfrmViewer.btnPrevGifFrameClick(Sender: TObject);
begin
GifAnim.Animate:=False;
GifAnim.PriorFrame;
end;
procedure TfrmViewer.btnRedEyeClick(Sender: TObject);
begin
RedEyes;
@ -2829,23 +2840,42 @@ procedure TfrmViewer.AdjustImageSize;
const
fmtImageInfo = '%dx%d (%.0f %%)';
var
AControl: TControl;
dScaleFactor : Double;
ImgWidth, ImgHeight : Integer;
iLeft, iTop, iWidth, iHeight : Integer;
begin
if (Image.Picture = nil) then Exit;
if (Image.Picture.Width = 0) or (Image.Picture.Height = 0) then Exit;
if not (bImage or bAnimation) then
Exit;
if bImage then
begin
if (Image.Picture = nil) then Exit;
ImgHeight:= Image.Picture.Height;
ImgWidth:= Image.Picture.Width;
AControl:= Image;
end
else if (bAnimation) then
begin
if GifAnim.CurrentView = nil then Exit;
ImgHeight:= GifAnim.CurrentView.Height;
ImgWidth:= GifAnim.CurrentView.Width;
AControl:= GifAnim;
end;
if (ImgWidth = 0) or (ImgHeight = 0) then Exit;
dScaleFactor:= FZoomFactor / 100;
// Place and resize image
if (FZoomFactor = 100) and (miStretch.Checked or miStretchOnlyLarge.Checked) then
begin
dScaleFactor:= Min(sboxImage.ClientWidth / Image.Picture.Width ,sboxImage.ClientHeight / Image.Picture.Height);
dScaleFactor:= Min(sboxImage.ClientWidth / ImgWidth, sboxImage.ClientHeight / ImgHeight);
dScaleFactor:= IfThen((miStretchOnlyLarge.Checked) and (dScaleFactor > 1.0), 1.0, dScaleFactor);
end;
iWidth:= Trunc(Image.Picture.Width * dScaleFactor);
iHeight:= Trunc(Image.Picture.Height * dScaleFactor);
iWidth:= Trunc(ImgWidth * dScaleFactor);
iHeight:= Trunc(ImgHeight * dScaleFactor);
if (miCenter.Checked) then
begin
iLeft:= (sboxImage.ClientWidth - iWidth) div 2;
@ -2856,7 +2886,7 @@ begin
iLeft:= 0;
iTop:= 0;
end;
Image.SetBounds(Max(iLeft,0), Max(iTop,0), iWidth , iHeight);
AControl.SetBounds(Max(iLeft,0), Max(iTop,0), iWidth , iHeight);
// Update scrollbars
// TODO: fix - calculations are correct but it seems like scroll bars
@ -2870,8 +2900,8 @@ begin
end;
// Update status bar
Status.Panels[sbpCurrentResolution].Text:= Format(fmtImageInfo, [iWidth,iHeight, 100.0 * dScaleFactor]);
Status.Panels[sbpFullResolution].Text:= Format(fmtImageInfo, [Image.Picture.Width,Image.Picture.Height, 100.0]);
Status.Panels[sbpCurrentResolution].Text:= Format(fmtImageInfo, [iWidth, iHeight, 100.0 * dScaleFactor]);
Status.Panels[sbpFullResolution].Text:= Format(fmtImageInfo, [ImgWidth, ImgHeight, 100.0]);
end;
function TfrmViewer.GetListerRect: TRect;
@ -2957,7 +2987,6 @@ function TfrmViewer.LoadGraphics(const sFileName:String): Boolean;
btnHightlight.Enabled:= bImage and (not miFullScreen.Checked);
btnPaint.Enabled:= bImage and (not miFullScreen.Checked);
btnResize.Enabled:= bImage and (not miFullScreen.Checked);
miImage.Visible:= bImage;
btnZoomIn.Enabled:= bImage;
btnZoomOut.Enabled:= bImage;
btn270.Enabled:= bImage;
@ -2973,23 +3002,13 @@ function TfrmViewer.LoadGraphics(const sFileName:String): Boolean;
var
sExt: String;
fsFileHandle: System.THandle;
fsFileStream: TFileStreamEx = nil;
gifHeader: array[0..5] of AnsiChar;
fsFileStream: TFileStreamEx;
begin
Result:= True;
FZoomFactor:= 100;
sExt:= ExtractOnlyFileExt(sFilename);
if SameText(sExt, 'gif') then
if not SameText(sExt, 'gif') then
begin
fsFileHandle:= mbFileOpen(sFileName, fmOpenRead or fmShareDenyNone);
if (fsFileHandle = feInvalidHandle) then Exit(False);
FileRead(fsFileHandle, gifHeader, SizeOf(gifHeader));
FileClose(fsFileHandle);
end;
// GifAnim supports only GIF89a
if gifHeader <> 'GIF89a' then
begin
Image.Visible:= True;
GifAnim.Visible:= False;
try
@ -3008,6 +3027,8 @@ begin
end;
end;
{$ENDIF}
bImage:= True;
bAnimation:= False;
UpdateToolbar(True);
finally
FreeAndNil(fsFileStream);
@ -3016,7 +3037,6 @@ begin
begin
if FExif.LoadFromFile(sFileName) then
begin
bImage:= True;
case FExif.Orientation of
2: cm_MirrorHorz([]);
3: cm_Rotate180([]);
@ -3040,8 +3060,18 @@ begin
GifAnim.Visible:= True;
Image.Visible:= False;
try
GifAnim.FileName:= sFileName;
UpdateToolbar(False);
fsFileStream:= TFileStreamEx.Create(sFileName, fmOpenRead or fmShareDenyNone);
try
GifAnim.LoadFromStream(fsFileStream);
bImage:= False;
bAnimation:= True;
UpdateToolbar(False);
AdjustImageSize;
GifAnim.Start;
UpdateAnimState;
finally
fsFileStream.Free;
end;
except
on E: Exception do
begin
@ -3591,7 +3621,7 @@ begin
miGraphics.Checked := (Panel = pnlImage);
miEncoding.Visible := (Panel = pnlText) or (Panel = pnlCode) or (bPlugin and FWlxModule.CanCommand);
miAutoReload.Visible := (Panel = pnlText);
miImage.Visible := (bImage or (bPlugin and FWlxModule.CanCommand));
miImage.Visible := (bImage or bAnimation or (bPlugin and FWlxModule.CanCommand));
miRotate.Visible := bImage;
miZoomIn.Visible := bImage;
miZoomOut.Visible := bImage;
@ -3968,7 +3998,7 @@ begin
if not bAnimation then
Clipboard.Assign(Image.Picture)
else
Clipboard.Assign(GifAnim.GifBitmaps[GifAnim.GifIndex].Bitmap);
Clipboard.Assign(GifAnim.CurrentView);
end else
ViewerControl.CopyToClipboard;
end;