690 lines
21 KiB
Plaintext
690 lines
21 KiB
Plaintext
(* ------------------------------------------------------------------------------
|
|
ResourceExtractor : 1.0
|
|
Copyright © 1986-2012 : Copyright Adirondack Software & Graphics
|
|
Last Modification : 04-05-2012
|
|
Source File : uViewIcons.pas
|
|
Compiler : Delphi 2010
|
|
Operating System : Windows 7
|
|
This file is copyright (C) W W Miller, 1986-2012.
|
|
It may be used without restriction. This code distributed on an "AS IS"
|
|
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
|
|
------------------------------------------------------------------------------ *)
|
|
unit uViewIcons;
|
|
//
|
|
{$WARN SYMBOL_PLATFORM OFF}
|
|
{$WARN UNIT_PLATFORM OFF}
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
Dialogs, StdCtrls, ExtCtrls, ComCtrls, ShellCtrls, Buttons, Menus,
|
|
IEView, ImageENView, ImageENIO, hyieutils, iexBitmaps, hyiedefs, iesettings,
|
|
iexLayers, iexRulers;
|
|
|
|
type
|
|
TFormViewIcons = class( TForm )
|
|
ShellTreeView1: TShellTreeView;
|
|
ShellListView1: TShellListView;
|
|
Splitter1: TSplitter;
|
|
Splitter2: TSplitter;
|
|
ImageEnView1: TImageEnView;
|
|
StatusBar1: TStatusBar;
|
|
Panel1: TPanel;
|
|
Ok1: TButton;
|
|
Panel2: TPanel;
|
|
IncFrame1: TSpeedButton;
|
|
DecFrame1: TSpeedButton;
|
|
Frames1: TLabel;
|
|
Frame1: TLabel;
|
|
Dimensions1: TLabel;
|
|
Colors1: TLabel;
|
|
Panel3: TPanel;
|
|
ListViewFrames1: TListView;
|
|
Splitter3: TSplitter;
|
|
Zoom1: TComboBox;
|
|
PopupMenuShellListView1: TPopupMenu;
|
|
Icon1: TMenuItem;
|
|
SmallIcon1: TMenuItem;
|
|
List1: TMenuItem;
|
|
Report1: TMenuItem;
|
|
procedure ShellListView1Change( Sender: TObject; Item: TListItem; Change: TItemChange );
|
|
procedure ShellTreeView1Change( Sender: TObject; Node: TTreeNode );
|
|
procedure IncFrame1Click( Sender: TObject );
|
|
procedure DecFrame1Click( Sender: TObject );
|
|
procedure FormCreate( Sender: TObject );
|
|
procedure ListViewFrames1SelectItem( Sender: TObject; Item: TListItem; Selected: Boolean );
|
|
procedure FormDestroy( Sender: TObject );
|
|
procedure FormShow( Sender: TObject );
|
|
procedure Zoom1Change( Sender: TObject );
|
|
procedure Icon1Click( Sender: TObject );
|
|
procedure SmallIcon1Click( Sender: TObject );
|
|
procedure List1Click( Sender: TObject );
|
|
procedure Report1Click( Sender: TObject );
|
|
procedure ShellTreeView1KeyPress( Sender: TObject; var Key: Char );
|
|
procedure ShellTreeView1MouseDown( Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer );
|
|
private
|
|
{ Private declarations }
|
|
FIniFileFilename: string;
|
|
FState: Integer;
|
|
FStartupFolder: string;
|
|
FSelectedFolder: string;
|
|
FFrame: Integer;
|
|
procedure ReadIni( IniFilename: string );
|
|
procedure WriteIni( IniFilename: string );
|
|
public
|
|
{ Public declarations }
|
|
end;
|
|
|
|
var
|
|
FormViewIcons: TFormViewIcons;
|
|
|
|
implementation
|
|
|
|
{$R *.dfm}
|
|
|
|
uses FileCtrl, ShlObj, IniFiles;
|
|
|
|
function AddThousandSeparator( const S: string; const C: Char ): string;
|
|
// Adds a specified thousand separator in the correct location in a string
|
|
var
|
|
i: Integer; // loops through separator position
|
|
begin
|
|
Result := S;
|
|
i := Length( S ) - 2;
|
|
while i > 1 do
|
|
begin
|
|
Insert( C, Result, i );
|
|
i := i - 3;
|
|
end;
|
|
end;
|
|
|
|
function AddDefThousandSeparator( const S: string ): string;
|
|
// Adds the thousands separator from the default locale in the correct location in a string
|
|
begin
|
|
// Note: FormatSettings.ThousandSeparator in XE8 or Newer
|
|
Result := AddThousandSeparator( S, SysUtils.ThousandSeparator );
|
|
end;
|
|
|
|
function IntegerToString( const Value: Integer ): string;
|
|
// Convert value into a string with thousandsseperator
|
|
begin
|
|
Result := AddDefThousandSeparator( IntToStr( Value ) );
|
|
end;
|
|
|
|
function LocalAppDataFolder: string;
|
|
// Find LocalAppData folder location
|
|
var
|
|
i: Bool;
|
|
iPath: array [ 0 .. MAX_PATH ] of Char;
|
|
begin
|
|
i := ShGetSpecialFolderPath( 0, iPath, CSIDL_LOCAL_APPDATA, False );
|
|
if not i then
|
|
raise Exception.Create( 'Could not find LocalAppData folder location.' );
|
|
Result := iPath;
|
|
end;
|
|
|
|
function AppDataFolder: string;
|
|
// Find AppData folder location
|
|
var
|
|
i: Bool;
|
|
iPath: array [ 0 .. MAX_PATH ] of Char;
|
|
begin
|
|
i := ShGetSpecialFolderPath( 0, iPath, CSIDL_APPDATA, False );
|
|
if not i then
|
|
raise Exception.Create( 'Could not find AppData folder location.' );
|
|
Result := iPath;
|
|
end;
|
|
|
|
function WindowsFolder: string;
|
|
// Returns path to Windows folder
|
|
begin
|
|
SetLength( Result, Windows.MAX_PATH );
|
|
SetLength( Result, Windows.GetWindowsDirectory( PChar( Result ), Windows.MAX_PATH ) );
|
|
end;
|
|
|
|
function ProfileFolder: string;
|
|
// Find Profile folder location
|
|
var
|
|
i: Bool;
|
|
iPath: array [ 0 .. MAX_PATH ] of Char;
|
|
begin
|
|
i := ShGetSpecialFolderPath( 0, iPath, CSIDL_PROFILE, False );
|
|
if not i then
|
|
raise Exception.Create( 'Could not find Profile folder location.' );
|
|
Result := iPath;
|
|
end;
|
|
|
|
function DocumentsFolder: string;
|
|
// Find Documents folder location
|
|
var
|
|
i: Bool;
|
|
iPath: array [ 0 .. MAX_PATH ] of Char;
|
|
begin
|
|
i := ShGetSpecialFolderPath( 0, iPath, CSIDL_PERSONAL, False );
|
|
if not i then
|
|
raise Exception.Create( 'Could not find Documents folder location.' );
|
|
Result := iPath;
|
|
end;
|
|
|
|
function DesktopFolder: string;
|
|
// Find Desktop folder location
|
|
var
|
|
i: Bool;
|
|
iPath: array [ 0 .. MAX_PATH ] of Char;
|
|
begin
|
|
i := ShGetSpecialFolderPath( 0, iPath, CSIDL_DESKTOP, False );
|
|
if not i then
|
|
raise Exception.Create( 'Could not find Documents folder location.' );
|
|
Result := iPath;
|
|
end;
|
|
|
|
procedure TFormViewIcons.ReadIni( IniFilename: string );
|
|
// Read viewicons form settings from inifile
|
|
var
|
|
iIniFile: TIniFile;
|
|
begin
|
|
iIniFile := TIniFile.Create( IniFilename );
|
|
try
|
|
|
|
with iIniFile do
|
|
begin
|
|
Left := ReadInteger( 'ViewIcons', 'Left', 0 );
|
|
Top := ReadInteger( 'ViewIcons', 'Top', 0 );
|
|
Width := ReadInteger( 'ViewIcons', 'Width', 940 );
|
|
Height := ReadInteger( 'ViewIcons', 'Height', 475 );
|
|
FState := ReadInteger( 'ViewIcons', 'State', 0 );
|
|
|
|
// If no window coordinates then set position to poDesktopCenter else poDesigned
|
|
if ( Left = 0 ) and ( Top = 0 ) then
|
|
Position := poOwnerFormCenter
|
|
else
|
|
Position := poDesigned;
|
|
|
|
WindowState := TWindowState( FState );
|
|
FStartupFolder := ReadString( 'ViewIcons', 'StartupFolder', DesktopFolder );
|
|
end;
|
|
|
|
finally
|
|
iIniFile.Free;
|
|
end;
|
|
end;
|
|
|
|
procedure TFormViewIcons.WriteIni( IniFilename: string );
|
|
// Write viewicons form settings to inifile
|
|
var
|
|
iIniFile: TIniFile;
|
|
begin
|
|
iIniFile := TIniFile.Create( IniFilename );
|
|
try
|
|
|
|
with iIniFile do
|
|
begin
|
|
WriteInteger( 'ViewIcons', 'Left', Left );
|
|
WriteInteger( 'ViewIcons', 'Top', Top );
|
|
WriteInteger( 'ViewIcons', 'Width', Width );
|
|
WriteInteger( 'ViewIcons', 'Height', Height );
|
|
FState := Ord( WindowState );
|
|
WriteInteger( 'ViewIcons', 'State', FState );
|
|
WriteString( 'ViewIcons', 'StartupFolder', FStartupFolder );
|
|
end;
|
|
|
|
finally
|
|
iIniFile.Free;
|
|
end;
|
|
|
|
end;
|
|
|
|
procedure TFormViewIcons.Report1Click( Sender: TObject );
|
|
// Set the shelllistview viewstyle to report
|
|
begin
|
|
ShellListView1.ViewStyle := vsReport;
|
|
if DirectoryExists( FSelectedFolder ) then
|
|
ShellTreeView1.Path := FSelectedFolder;
|
|
end;
|
|
|
|
procedure TFormViewIcons.Zoom1Change( Sender: TObject );
|
|
// Respond to zoom change
|
|
const
|
|
iZoomVal: array [ 0 .. 6 ] of double = ( 0, 25, 50, 100, 200, 400, 800 );
|
|
begin
|
|
if Zoom1.ItemIndex = 0 then
|
|
begin
|
|
ImageEnView1.AutoFit := True;
|
|
ImageEnView1.Update;
|
|
end
|
|
else
|
|
begin
|
|
ImageEnView1.AutoFit := False;
|
|
ImageEnView1.Zoom := iZoomVal[ Zoom1.ItemIndex ];
|
|
end;
|
|
|
|
end;
|
|
|
|
procedure TFormViewIcons.FormCreate( Sender: TObject );
|
|
begin
|
|
FFrame := 0;
|
|
FIniFileFilename := IncludeTrailingBackslash( LocalAppDataFolder ) + 'ASG\ResourceExtractor\' + 'ViewIcons.ini';
|
|
ForceDirectories( IncludeTrailingBackslash( LocalAppDataFolder ) + 'ASG\ResourceExtractor' );
|
|
ReadIni( FIniFileFilename );
|
|
ImageEnView1.Clear;
|
|
// View 32-bit bitmaps with alphachannel
|
|
ImageEnView1.IO.Params.BMP_HandleTransparency := True;
|
|
end;
|
|
|
|
procedure TFormViewIcons.FormDestroy( Sender: TObject );
|
|
begin
|
|
WriteIni( FIniFileFilename );
|
|
end;
|
|
|
|
procedure TFormViewIcons.FormShow( Sender: TObject );
|
|
begin
|
|
if DirectoryExists( FStartupFolder ) then
|
|
begin
|
|
ShellTreeView1.Path := FStartupFolder;
|
|
FSelectedFolder := FStartupFolder;
|
|
end;
|
|
end;
|
|
|
|
procedure TFormViewIcons.ShellListView1Change( Sender: TObject; Item: TListItem; Change: TItemChange );
|
|
// Respond to ShellListView change
|
|
var
|
|
i: Integer;
|
|
iFilePath: string;
|
|
iFileName: string;
|
|
iPath: string;
|
|
iWidth: Integer;
|
|
iHeight: Integer;
|
|
iBitDepth: Integer;
|
|
iDimensions: string;
|
|
iSmallDimensions: string;
|
|
iColors: string;
|
|
iFrame: Integer;
|
|
iFrames: Integer;
|
|
iListItem: TListItem;
|
|
begin
|
|
|
|
if Assigned( ShellListView1.Selected ) then
|
|
begin
|
|
|
|
iFilePath := ShellListView1.SelectedFolder.PathName;
|
|
|
|
if FileExists( iFilePath ) then
|
|
begin
|
|
|
|
iFileName := ExtractFileName( iFilePath );
|
|
iPath := ExtractFileDir( iFilePath );
|
|
|
|
ListViewFrames1.Clear;
|
|
|
|
iFrames := IEGetFileFramesCount( ShellListView1.SelectedFolder.PathName );
|
|
|
|
for i := 0 to iFrames - 1 do
|
|
begin
|
|
|
|
ImageEnView1.IO.Params.ImageIndex := i;
|
|
ImageEnView1.IO.LoadFromFile( iFilePath );
|
|
|
|
iWidth := ImageEnView1.IEBitmap.Width;
|
|
iHeight := ImageEnView1.IEBitmap.Height;
|
|
iBitDepth := ImageEnView1.IO.Params.BitsPerSample * ImageEnView1.IO.Params.SamplesPerPixel;
|
|
iDimensions := IntegerToString( iWidth ) + ' pixels x ' + IntegerToString( iHeight ) + ' pixels';
|
|
iSmallDimensions := IntegerToString( iWidth ) + ' x ' + IntegerToString( iHeight );
|
|
|
|
if iBitDepth = 32 then
|
|
iColors := 'RGBA ' + IntToStr( iBitDepth ) + ' bit'
|
|
else
|
|
iColors := 'RGB ' + IntToStr( iBitDepth ) + ' bit';
|
|
|
|
Caption := ' View Icons- ' + iFilePath;
|
|
Dimensions1.Caption := 'Dimensions: ' + iSmallDimensions;
|
|
Colors1.Caption := 'Colors: ' + iColors;
|
|
|
|
// Fill Listview
|
|
iListItem := ListViewFrames1.Items.Add;
|
|
iListItem.Caption := IntToStr( i + 1 );
|
|
iListItem.SubItems.Add( iSmallDimensions );
|
|
if iBitDepth = 32 then
|
|
begin
|
|
iColors := 'RGBA ' + IntToStr( iBitDepth ) + ' bit';
|
|
ImageEnView1.Background := clBtnFace;
|
|
ImageEnView1.BackgroundStyle := iebsChessboard;
|
|
ImageEnView1.SetChessboardStyle( 8 );
|
|
end
|
|
else
|
|
begin
|
|
iColors := 'RGB ' + IntToStr( iBitDepth ) + ' bit';
|
|
ImageEnView1.Background := clWindow;
|
|
ImageEnView1.BackgroundStyle := iebsSolid;
|
|
end;
|
|
iListItem.SubItems.Add( iColors );
|
|
|
|
ListViewFrames1.ItemIndex := 0;
|
|
ListViewFrames1.Items[ 0 ].Selected := True;
|
|
IncFrame1.Visible := ListViewFrames1.Items.Count > 1;
|
|
DecFrame1.Visible := ListViewFrames1.Items.Count > 1;
|
|
end;
|
|
|
|
if iFrames = 0 then
|
|
begin
|
|
ImageEnView1.IO.LoadFromFile( iFilePath );
|
|
|
|
iWidth := ImageEnView1.IEBitmap.Width;
|
|
iHeight := ImageEnView1.IEBitmap.Height;
|
|
iBitDepth := ImageEnView1.IO.Params.BitsPerSample * ImageEnView1.IO.Params.SamplesPerPixel;
|
|
iDimensions := IntegerToString( iWidth ) + ' pixels x ' + IntegerToString( iHeight ) + ' pixels';
|
|
iSmallDimensions := IntegerToString( iWidth ) + ' x ' + IntegerToString( iHeight );
|
|
|
|
if iBitDepth = 32 then
|
|
iColors := 'RGBA ' + IntToStr( iBitDepth ) + ' bit'
|
|
else
|
|
iColors := 'RGB ' + IntToStr( iBitDepth ) + ' bit';
|
|
|
|
Caption := 'Icon Viewer- ' + iFilePath;
|
|
Dimensions1.Caption := 'Dimensions: ' + iSmallDimensions;
|
|
Colors1.Caption := 'Colors: ' + iColors;
|
|
|
|
// Fill Listview
|
|
iListItem := ListViewFrames1.Items.Add;
|
|
iListItem.Caption := IntToStr( 1 );
|
|
iListItem.SubItems.Add( iSmallDimensions );
|
|
if iBitDepth = 32 then
|
|
begin
|
|
iColors := 'RGBA ' + IntToStr( iBitDepth ) + ' bit';
|
|
ImageEnView1.Background := clBtnFace;
|
|
ImageEnView1.BackgroundStyle := iebsChessboard;
|
|
ImageEnView1.SetChessboardStyle( 8 );
|
|
end
|
|
else
|
|
begin
|
|
iColors := 'RGB ' + IntToStr( iBitDepth ) + ' bit';
|
|
ImageEnView1.Background := clWindow;
|
|
ImageEnView1.BackgroundStyle := iebsSolid;
|
|
end;
|
|
iListItem.SubItems.Add( iColors );
|
|
|
|
ListViewFrames1.ItemIndex := 0;
|
|
ListViewFrames1.Items[ 0 ].Selected := True;
|
|
|
|
IncFrame1.Visible := False;
|
|
DecFrame1.Visible := False;
|
|
end;
|
|
|
|
FFrame := 0;
|
|
iFrame := 0;
|
|
|
|
if iFrames = 0 then
|
|
Frames1.Caption := 'Frames: ' + IntegerToString( iFrames + 1 )
|
|
else
|
|
Frames1.Caption := 'Frames: ' + IntegerToString( iFrames );
|
|
|
|
Frame1.Caption := 'Frame: ' + IntegerToString( iFrame + 1 );
|
|
|
|
if iFrames = 0 then
|
|
begin
|
|
IncFrame1.Visible := False;
|
|
DecFrame1.Visible := False;
|
|
end
|
|
else
|
|
begin
|
|
IncFrame1.Visible := True;
|
|
DecFrame1.Visible := True;
|
|
end;
|
|
|
|
StatusBar1.Panels[ 0 ].Text := FileCtrl.MinimizeName( iPath, Canvas, 250 );
|
|
StatusBar1.Panels[ 1 ].Text := FileCtrl.MinimizeName( iFileName, Canvas, 225 );
|
|
StatusBar1.Panels[ 2 ].Text := iDimensions;
|
|
StatusBar1.Panels[ 3 ].Text := iColors;
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
procedure TFormViewIcons.ShellTreeView1Change( Sender: TObject; Node: TTreeNode );
|
|
// Respond to ShellTreeView Change
|
|
var
|
|
iPath: string;
|
|
begin
|
|
if Assigned( ShellTreeView1.Selected ) then
|
|
begin
|
|
if ShellTreeView1.SelectedFolder <> nil then
|
|
begin
|
|
iPath := ShellTreeView1.SelectedFolder.PathName;
|
|
FStartupFolder := iPath;
|
|
Caption := 'View Icons- ' + iPath;
|
|
StatusBar1.Panels[ 0 ].Text := FileCtrl.MinimizeName( iPath, Canvas, 250 );
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TFormViewIcons.ShellTreeView1KeyPress( Sender: TObject; var Key: Char );
|
|
// Respond to ShellTreeView keypress
|
|
begin
|
|
if Assigned( ShellTreeView1.Selected ) then
|
|
begin
|
|
if ShellTreeView1.SelectedFolder <> nil then
|
|
begin
|
|
FSelectedFolder := ShellTreeView1.SelectedFolder.PathName;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TFormViewIcons.ShellTreeView1MouseDown( Sender: TObject; Button: TMouseButton; Shift: TShiftState;
|
|
X, Y: Integer );
|
|
// Respond to ShellTreeView mousedown
|
|
begin
|
|
if Assigned( ShellTreeView1.Selected ) then
|
|
begin
|
|
if ShellTreeView1.SelectedFolder <> nil then
|
|
begin
|
|
FSelectedFolder := ShellTreeView1.SelectedFolder.PathName;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TFormViewIcons.SmallIcon1Click( Sender: TObject );
|
|
// Set the shelllistview viewstyle to smallicon
|
|
begin
|
|
ShellListView1.ViewStyle := vsSmallIcon;
|
|
if DirectoryExists( FSelectedFolder ) then
|
|
ShellTreeView1.Path := FSelectedFolder;
|
|
end;
|
|
|
|
procedure TFormViewIcons.Icon1Click( Sender: TObject );
|
|
// Set the shelllistview viewstyle to icon
|
|
begin
|
|
ShellListView1.ViewStyle := vsIcon;
|
|
if DirectoryExists( FSelectedFolder ) then
|
|
ShellTreeView1.Path := FSelectedFolder;
|
|
end;
|
|
|
|
procedure TFormViewIcons.IncFrame1Click( Sender: TObject );
|
|
// respond to next frame button
|
|
var
|
|
iWidth: Integer;
|
|
iHeight: Integer;
|
|
iBitDepth: Integer;
|
|
iDimensions: string;
|
|
iSmallDimensions: string;
|
|
iColors: string;
|
|
iFrames: Integer;
|
|
begin
|
|
if Assigned( ShellListView1.Selected ) then
|
|
begin
|
|
iFrames := IEGetFileFramesCount( ShellListView1.SelectedFolder.PathName ) - 1;
|
|
if FFrame = iFrames then
|
|
FFrame := 0
|
|
else
|
|
Inc( FFrame );
|
|
Frame1.Caption := 'Frame: ' + IntegerToString( FFrame + 1 );
|
|
ImageEnView1.IO.Params.ImageIndex := FFrame;
|
|
ImageEnView1.IO.LoadFromFile( ShellListView1.SelectedFolder.PathName );
|
|
ImageEnView1.Update;
|
|
|
|
iBitDepth := ImageEnView1.IO.Params.BitsPerSample * ImageEnView1.IO.Params.SamplesPerPixel;
|
|
if iBitDepth = 32 then
|
|
begin
|
|
ImageEnView1.Background := clBtnFace;
|
|
ImageEnView1.BackgroundStyle := iebsChessboard;
|
|
ImageEnView1.SetChessboardStyle( 8 );
|
|
end
|
|
else
|
|
begin
|
|
ImageEnView1.Background := clWindow;
|
|
ImageEnView1.BackgroundStyle := iebsSolid;
|
|
end;
|
|
|
|
iWidth := ImageEnView1.IEBitmap.Width;
|
|
iHeight := ImageEnView1.IEBitmap.Height;
|
|
iDimensions := IntegerToString( iWidth ) + ' pixels x ' + IntegerToString( iHeight ) + ' pixels';
|
|
iSmallDimensions := IntegerToString( iWidth ) + ' x ' + IntegerToString( iHeight );
|
|
|
|
if iBitDepth = 32 then
|
|
iColors := 'RGBA ' + IntToStr( iBitDepth ) + ' bit'
|
|
else
|
|
iColors := 'RGB ' + IntToStr( iBitDepth ) + ' bit';
|
|
|
|
Dimensions1.Caption := 'Dimensions: ' + iSmallDimensions;
|
|
Colors1.Caption := 'Colors: ' + iColors;
|
|
StatusBar1.Panels[ 2 ].Text := iDimensions;
|
|
StatusBar1.Panels[ 3 ].Text := iColors;
|
|
if ListViewFrames1.ItemIndex + 1 < ListViewFrames1.Items.Count then
|
|
begin
|
|
ListViewFrames1.ItemIndex := ListViewFrames1.ItemIndex + 1;
|
|
ListViewFrames1.Items[ FFrame ].Selected := True;
|
|
end
|
|
else if ListViewFrames1.ItemIndex = ListViewFrames1.Items.Count - 1 then
|
|
begin
|
|
FFrame := 0;
|
|
ListViewFrames1.ItemIndex := 0;
|
|
ListViewFrames1.Items[ FFrame ].Selected := True;
|
|
end;
|
|
end;
|
|
|
|
end;
|
|
|
|
procedure TFormViewIcons.List1Click( Sender: TObject );
|
|
// Set the shelllistview viewstyle to list
|
|
begin
|
|
ShellListView1.ViewStyle := vsList;
|
|
if DirectoryExists( FSelectedFolder ) then
|
|
ShellTreeView1.Path := FSelectedFolder;
|
|
end;
|
|
|
|
procedure TFormViewIcons.ListViewFrames1SelectItem( Sender: TObject; Item: TListItem; Selected: Boolean );
|
|
// Respond to ListviewFrames selection
|
|
var
|
|
iWidth: Integer;
|
|
iHeight: Integer;
|
|
iBitDepth: Integer;
|
|
iDimensions: string;
|
|
iSmallDimensions: string;
|
|
iColors: string;
|
|
begin
|
|
if Selected then
|
|
begin
|
|
|
|
Frame1.Caption := 'Frame: ' + IntegerToString( Item.Index + 1 );
|
|
ImageEnView1.IO.Params.ImageIndex := Item.Index;
|
|
ImageEnView1.IO.LoadFromFile( ShellListView1.SelectedFolder.PathName );
|
|
ImageEnView1.Update;
|
|
|
|
iBitDepth := ImageEnView1.IO.Params.BitsPerSample * ImageEnView1.IO.Params.SamplesPerPixel;
|
|
if iBitDepth = 32 then
|
|
begin
|
|
ImageEnView1.Background := clBtnFace;
|
|
ImageEnView1.BackgroundStyle := iebsChessboard;
|
|
ImageEnView1.SetChessboardStyle( 4 );
|
|
end
|
|
else
|
|
begin
|
|
ImageEnView1.Background := clWindow;
|
|
ImageEnView1.BackgroundStyle := iebsSolid;
|
|
end;
|
|
|
|
iWidth := ImageEnView1.IEBitmap.Width;
|
|
iHeight := ImageEnView1.IEBitmap.Height;
|
|
iDimensions := IntegerToString( iWidth ) + ' pixels x ' + IntegerToString( iHeight ) + ' pixels';
|
|
iSmallDimensions := IntegerToString( iWidth ) + ' x ' + IntegerToString( iHeight );
|
|
|
|
if iBitDepth = 32 then
|
|
iColors := 'RGBA ' + IntToStr( iBitDepth ) + ' bit'
|
|
else
|
|
iColors := 'RGB ' + IntToStr( iBitDepth ) + ' bit';
|
|
|
|
FFrame := Item.Index;
|
|
Dimensions1.Caption := 'Dimensions: ' + iSmallDimensions;
|
|
Colors1.Caption := 'Colors: ' + iColors;
|
|
StatusBar1.Panels[ 2 ].Text := iDimensions;
|
|
StatusBar1.Panels[ 3 ].Text := iColors;
|
|
end;
|
|
end;
|
|
|
|
procedure TFormViewIcons.DecFrame1Click( Sender: TObject );
|
|
// Respond to previous button click
|
|
var
|
|
iWidth: Integer;
|
|
iHeight: Integer;
|
|
iBitDepth: Integer;
|
|
iDimensions: string;
|
|
iSmallDimensions: string;
|
|
iColors: string;
|
|
iFrames: Integer;
|
|
begin
|
|
if Assigned( ShellListView1.Selected ) then
|
|
begin
|
|
iFrames := IEGetFileFramesCount( ShellListView1.SelectedFolder.PathName ) - 1;
|
|
if FFrame > 1 then
|
|
Dec( FFrame )
|
|
else
|
|
FFrame := iFrames;
|
|
Frame1.Caption := 'Frame: ' + IntegerToString( FFrame + 1 );
|
|
ImageEnView1.IO.Params.ImageIndex := FFrame;
|
|
ImageEnView1.IO.LoadFromFile( ShellListView1.SelectedFolder.PathName );
|
|
ImageEnView1.Update;
|
|
|
|
iBitDepth := ImageEnView1.IO.Params.BitsPerSample * ImageEnView1.IO.Params.SamplesPerPixel;
|
|
if iBitDepth = 32 then
|
|
begin
|
|
ImageEnView1.Background := clBtnFace;
|
|
ImageEnView1.BackgroundStyle := iebsChessboard;
|
|
ImageEnView1.SetChessboardStyle( 8 );
|
|
end
|
|
else
|
|
begin
|
|
ImageEnView1.Background := clWindow;
|
|
ImageEnView1.BackgroundStyle := iebsSolid;
|
|
end;
|
|
|
|
iWidth := ImageEnView1.IEBitmap.Width;
|
|
iHeight := ImageEnView1.IEBitmap.Height;
|
|
iDimensions := IntegerToString( iWidth ) + ' pixels x ' + IntegerToString( iHeight ) + ' pixels';
|
|
iSmallDimensions := IntegerToString( iWidth ) + ' x ' + IntegerToString( iHeight );
|
|
|
|
if iBitDepth = 32 then
|
|
iColors := 'RGBA ' + IntToStr( iBitDepth ) + ' bit'
|
|
else
|
|
iColors := 'RGB ' + IntToStr( iBitDepth ) + ' bit';
|
|
|
|
Dimensions1.Caption := 'Dimensions: ' + iSmallDimensions;
|
|
Colors1.Caption := 'Colors: ' + iColors;
|
|
StatusBar1.Panels[ 2 ].Text := iDimensions;
|
|
StatusBar1.Panels[ 3 ].Text := iColors;
|
|
|
|
if ListViewFrames1.ItemIndex = 0 then
|
|
begin
|
|
FFrame := ListViewFrames1.Items.Count - 1;
|
|
ListViewFrames1.ItemIndex := FFrame;
|
|
ListViewFrames1.Items[ FFrame ].Selected := True;
|
|
end
|
|
else if ListViewFrames1.ItemIndex <> 0 then
|
|
begin
|
|
ListViewFrames1.ItemIndex := ListViewFrames1.ItemIndex - 1;
|
|
ListViewFrames1.Items[ FFrame ].Selected := True;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
end.
|