View Issue Details

IDProjectCategoryView StatusLast Update
0023433LazarusPatchpublic2012-12-05 10:18
ReporterBigChimpAssigned ToMaxim Ganetsky 
PrioritynormalSeveritytrivialReproducibilityalways
Status closedResolutionfixed 
Platformx64 (with x86 compiler)OSWindowsOS VersionVista
Product Version1.1 (SVN)Product Build 
Target VersionFixed in Version1.1 (SVN) 
Summary0023433: [Patch] Imgview demo: TIFF, cross-platform fix
Description- added tiff support
- fixed Windows only path error
- synched some leftover debug+release build mode differences
- minor fixes
TagsNo tags attached.
Fixed in Revision39439
LazTarget-
Widgetset
Attached Files
  • tiff.diff (3,126 bytes)
    Index: examples/imgviewer/frmmain.pas
    ===================================================================
    --- examples/imgviewer/frmmain.pas	(revision 39437)
    +++ examples/imgviewer/frmmain.pas	(working copy)
    @@ -26,7 +26,8 @@
     
     uses
       LCLIntf, SysUtils, Classes, Graphics, Controls, Forms, FileUtil,
    -  Dialogs, StdCtrls, ComCtrls, ExtCtrls, ActnList, Menus, LCLType;
    +  Dialogs, StdCtrls, ComCtrls, ExtCtrls, ActnList, Menus, LCLType,
    +  fpreadtiff {adds TIFF format read support to TImage};
     
     type
     
    @@ -123,7 +124,7 @@
     {$R *.lfm}
     
     const
    -  ImageTypes = '.jpg.jpeg.bmp.xpm.png';
    +  ImageTypes = '|.jpg|.jpeg|.bmp|.xpm|.png';
     
     resourcestring
       SSelectImageDir = 'Select directory to add images from';
    @@ -147,7 +148,7 @@
     end;
     
     procedure TMainForm.AddFile(FileName: string; ShowFile: boolean);
    -
    +// Adds a file to the listbox and displays it if ShowFile is true
     var
       Index: integer;
     
    @@ -159,7 +160,7 @@
     end;
     
     procedure TMainForm.ShowFile(Index: integer);
    -
    +// Loads file and displays it into the IMain TImage
     var
       LoadOK: boolean;
     
    @@ -177,15 +178,18 @@
             Imain.Stretch := false;
             FImageScale := 1.0;
             IMain.Picture.LoadFromFile(LBFiles.Items[Index]);
    -        Caption := SImageViewer + '(' + LBFiles.Items[Index] + ')';
    +        Caption := SImageViewer + ' (' + LBFiles.Items[Index] + ')';
             LoadOK := true;
           except
    +        // If we can't load the image, try next file unless we're at the end
             if Index < LBFiles.Items.Count - 1 then
               Inc(Index)
             else
               Index := -1;
           end
         until LoadOK or (Index = -1);
    +
    +  // Now synchronize our listbox to the file we loaded:
       with LBFiles do
       begin
         if Index <> ItemIndex then
    @@ -228,12 +232,14 @@
       Info: TSearchRec;
       Ext: string;
     begin
    -  Directory := IncludeTrailingBackslash(Directory);
    +  Directory := IncludeTrailingPathDelimiter(Directory);
       if FindFirstUTF8(Directory + '*.*', 0, Info) = 0 then
         try
           repeat
             Ext := ExtractFileExt(Info.Name);
    -        if Pos(Ext, ImageTypes) <> 0 then
    +        // Support opening tiff files as well as the built-in image types.
    +        // Note: requires fpreadtiff in the uses clause to work.
    +        if Pos(lowercase('|'+Ext+'|'), ImageTypes+'|tif|tiff') <> 0 then
               AddFile(Directory + Info.Name, false);
           until (FindNextUTF8(Info) <> 0)
         finally
    Index: examples/imgviewer/imgview.lpi
    ===================================================================
    --- examples/imgviewer/imgview.lpi	(revision 39437)
    +++ examples/imgviewer/imgview.lpi	(working copy)
    @@ -19,8 +19,12 @@
           <Item2 Name="debug">
             <CompilerOptions>
               <Version Value="11"/>
    +          <Target>
    +            <Filename Value="imgviewer"/>
    +          </Target>
               <SearchPaths>
    -            <SrcPath Value="$(LazarusDir)/lcl;$(LazarusDir)/lcl/interfaces/$(LCLWidgetType)"/>
    +            <IncludeFiles Value="$(ProjOutDir)"/>
    +            <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
               </SearchPaths>
               <Parsing>
                 <SyntaxOptions>
    
    tiff.diff (3,126 bytes)

Activities

2012-12-04 16:22

 

tiff.diff (3,126 bytes)
Index: examples/imgviewer/frmmain.pas
===================================================================
--- examples/imgviewer/frmmain.pas	(revision 39437)
+++ examples/imgviewer/frmmain.pas	(working copy)
@@ -26,7 +26,8 @@
 
 uses
   LCLIntf, SysUtils, Classes, Graphics, Controls, Forms, FileUtil,
-  Dialogs, StdCtrls, ComCtrls, ExtCtrls, ActnList, Menus, LCLType;
+  Dialogs, StdCtrls, ComCtrls, ExtCtrls, ActnList, Menus, LCLType,
+  fpreadtiff {adds TIFF format read support to TImage};
 
 type
 
@@ -123,7 +124,7 @@
 {$R *.lfm}
 
 const
-  ImageTypes = '.jpg.jpeg.bmp.xpm.png';
+  ImageTypes = '|.jpg|.jpeg|.bmp|.xpm|.png';
 
 resourcestring
   SSelectImageDir = 'Select directory to add images from';
@@ -147,7 +148,7 @@
 end;
 
 procedure TMainForm.AddFile(FileName: string; ShowFile: boolean);
-
+// Adds a file to the listbox and displays it if ShowFile is true
 var
   Index: integer;
 
@@ -159,7 +160,7 @@
 end;
 
 procedure TMainForm.ShowFile(Index: integer);
-
+// Loads file and displays it into the IMain TImage
 var
   LoadOK: boolean;
 
@@ -177,15 +178,18 @@
         Imain.Stretch := false;
         FImageScale := 1.0;
         IMain.Picture.LoadFromFile(LBFiles.Items[Index]);
-        Caption := SImageViewer + '(' + LBFiles.Items[Index] + ')';
+        Caption := SImageViewer + ' (' + LBFiles.Items[Index] + ')';
         LoadOK := true;
       except
+        // If we can't load the image, try next file unless we're at the end
         if Index < LBFiles.Items.Count - 1 then
           Inc(Index)
         else
           Index := -1;
       end
     until LoadOK or (Index = -1);
+
+  // Now synchronize our listbox to the file we loaded:
   with LBFiles do
   begin
     if Index <> ItemIndex then
@@ -228,12 +232,14 @@
   Info: TSearchRec;
   Ext: string;
 begin
-  Directory := IncludeTrailingBackslash(Directory);
+  Directory := IncludeTrailingPathDelimiter(Directory);
   if FindFirstUTF8(Directory + '*.*', 0, Info) = 0 then
     try
       repeat
         Ext := ExtractFileExt(Info.Name);
-        if Pos(Ext, ImageTypes) <> 0 then
+        // Support opening tiff files as well as the built-in image types.
+        // Note: requires fpreadtiff in the uses clause to work.
+        if Pos(lowercase('|'+Ext+'|'), ImageTypes+'|tif|tiff') <> 0 then
           AddFile(Directory + Info.Name, false);
       until (FindNextUTF8(Info) <> 0)
     finally
Index: examples/imgviewer/imgview.lpi
===================================================================
--- examples/imgviewer/imgview.lpi	(revision 39437)
+++ examples/imgviewer/imgview.lpi	(working copy)
@@ -19,8 +19,12 @@
       <Item2 Name="debug">
         <CompilerOptions>
           <Version Value="11"/>
+          <Target>
+            <Filename Value="imgviewer"/>
+          </Target>
           <SearchPaths>
-            <SrcPath Value="$(LazarusDir)/lcl;$(LazarusDir)/lcl/interfaces/$(LCLWidgetType)"/>
+            <IncludeFiles Value="$(ProjOutDir)"/>
+            <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
           </SearchPaths>
           <Parsing>
             <SyntaxOptions>
tiff.diff (3,126 bytes)

Maxim Ganetsky

2012-12-04 21:41

developer   ~0064149

Applied, thanks.

I fixed format handling at line 242 of frmmain.pas.

Reinier Olislagers

2012-12-05 10:18

developer   ~0064152

Thanks for commit & fixing the format issue, Maxim... sloppy coding on my part!

Issue History

Date Modified Username Field Change
2012-12-04 16:22 Reinier Olislagers New Issue
2012-12-04 16:22 Reinier Olislagers File Added: tiff.diff
2012-12-04 16:22 Reinier Olislagers LazTarget => -
2012-12-04 16:22 Reinier Olislagers Widgetset => Win32/Win64
2012-12-04 20:58 Maxim Ganetsky Status new => assigned
2012-12-04 20:58 Maxim Ganetsky Assigned To => Maxim Ganetsky
2012-12-04 21:41 Maxim Ganetsky Fixed in Revision => 39439
2012-12-04 21:41 Maxim Ganetsky Widgetset Win32/Win64 =>
2012-12-04 21:41 Maxim Ganetsky Status assigned => resolved
2012-12-04 21:41 Maxim Ganetsky Fixed in Version => 1.1 (SVN)
2012-12-04 21:41 Maxim Ganetsky Resolution open => fixed
2012-12-04 21:41 Maxim Ganetsky Note Added: 0064149
2012-12-05 10:18 Reinier Olislagers Status resolved => closed
2012-12-05 10:18 Reinier Olislagers Note Added: 0064152