Check-in [fb041e1ec0]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added wrapper units for FreeImage (version 3.16)
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: fb041e1ec0ca287b7bbffcf3f3b9380be0d9796f
User & Date: tinus 2014-11-07 22:48:17
Context
2014-11-07
23:06
Start using FreeImage to load images. Added DataModule to host the tray icon and its menu. Main form can now show a scaled version of the desktop, and allows for selection of separate monitors. check-in: aeddb28d5f user: tinus tags: trunk
22:48
Added wrapper units for FreeImage (version 3.16) check-in: fb041e1ec0 user: tinus tags: trunk
22:48
Added wrapper units for FreeImage (version 3.16) check-in: 5243a1a4e2 user: tinus tags: trunk
Changes

Added src/FreeImage/FreeUtils.pas.





















































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
unit FreeUtils;

// ==========================================================
//
// Delphi wrapper for FreeImage 3
//
// Design and implementation by
// - Anatoliy Pulyaevskiy (xvel84@rambler.ru)
//
// Contributors:
// - Enzo Costantini (enzocostantini@libero.it)
// - Armindo (tech1.yxendis@wanadoo.fr)
// - Lorenzo Monti (LM)  lomo74@gmail.com
//
// Revision history
// When        Who   What
// ----------- ----- -----------------------------------------------------------
// 2010-07-14  LM    made RAD2010 compliant (unicode)
//
// This file is part of FreeImage 3
//
// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
// THAT THE COVERED CODE 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
// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
// THE INITIAL DEVELOPER OR ANY OTHER 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 CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
// THIS DISCLAIMER.
//
// Use at your own risk!
//
// ==========================================================

interface

{$I 'Version.inc'}

uses
  {$IFDEF DELPHI2010}AnsiStrings,{$ENDIF} SysUtils, Classes, FreeImage;

function FIU_GetFIFType(filename: AnsiString): FREE_IMAGE_FORMAT;

// returns FIF (plugin) description string
function FIU_GetFIFDescription(fif: FREE_IMAGE_FORMAT): AnsiString;

procedure FIU_GetAllDescriptions(var Descriptions: TStringList);

// returns file extentions for FIF (e.g. '*.tif;*.tiff)
function FIU_GetFIFExtList(fif: FREE_IMAGE_FORMAT): AnsiString;

// returns file extentions for all plugins
function FIU_GetFullExtList: AnsiString;

// returns "Description + | + ExtList" for specified FIF
function FIU_GetFIFFilter(fif: FREE_IMAGE_FORMAT): AnsiString;

// All supported formats + Full filter list for FIFs
function FIU_GetAllFilters: AnsiString;

//Filter for OpenDialogs
function FIU_GetAllOpenFilters: AnsiString;

//Filter for SaveDialogs
function FIU_GetAllSaveFilters: AnsiString;

implementation

const
  FIF_START = FIF_UNKNOWN;
  FIF_END = FIF_XPM;

function FIU_GetFIFType(filename: AnsiString): FREE_IMAGE_FORMAT;
begin
  Result := FreeImage_GetFileType(PAnsiChar(filename), 0);
end;

function FIU_GetFIFDescription(fif: FREE_IMAGE_FORMAT): AnsiString;
begin
  Result := FreeImage_GetFIFDescription(fif)
end;

procedure FIU_GetAllDescriptions(var Descriptions: TStringList);
var
  fif: FREE_IMAGE_FORMAT;
begin
  Descriptions.Clear;
  for fif := FIF_START to FIF_END do
    Descriptions.Add(string(FreeImage_GetFIFDescription(fif)) + ' (' +
                     string(FIu_GetFIFExtList(fif)) + ')');
end;

function FIU_GetFIFExtList(fif: FREE_IMAGE_FORMAT): AnsiString;
var
  ExtList: AnsiString;
  I: Smallint;
  C: AnsiChar;
begin
  Result := '*.';
  ExtList := FreeImage_GetFIFExtensionList(fif);
  for I := 1 to Length(ExtList) do
  begin
    C := ExtList[i];
    if C <> ',' then
      Result := Result + C
    else
      Result := Result + ';*.';
  end
end;

function FIU_GetFullExtList: AnsiString;
var
  fif: FREE_IMAGE_FORMAT;
begin
  Result := FIU_GetFIFExtList(FIF_START);
  for fif := FIF_START to FIF_END do
    Result := Result + ';' + FIU_GetFIFExtList(fif)
end;

function FIU_GetFIFFilter(fif: FREE_IMAGE_FORMAT): AnsiString;
var
  Text, ExtList: AnsiString;
begin
  Result := '';
  if fif <> FIF_UNKNOWN then
  begin
    Text := {$IFDEF DELPHI2010}AnsiStrings.{$ENDIF}Trim(FreeImage_GetFIFDescription(fif));
    ExtList := FIU_GetFIFExtList(fif);
    Result := Text + '(' + ExtList + ')' + '|' + ExtList
  end
end;

function FIU_GetAllFilters: AnsiString;
var
  fif: FREE_IMAGE_FORMAT;
begin
  Result := 'All supported formats|' + FIU_GetFullExtList;
  for fif := FIF_START to FIF_END do
  begin
    Result := Result + '|' + FIU_GetFIFFilter(fif)
  end;
end;

function FIU_GetAllOpenFilters: AnsiString;
var
  fif: FREE_IMAGE_FORMAT;
begin
  Result := 'All supported formats|' + FIU_GetFullExtList;
  for fif := FIF_START to FIF_END do
    if FreeImage_FIFSupportsReading(fif) then
      begin
        Result := Result + '|' + FIU_GetFIFFilter(fif)
      end;
end;

function FIU_GetAllSaveFilters: AnsiString;
var
  ExtList: AnsiString;
  I: Smallint;
  C: AnsiChar;
  fif: FREE_IMAGE_FORMAT;
  s: AnsiString;
begin
  result := '';
  for fif := FIF_START to FIF_END do
    if FreeImage_FIFSupportsWriting(fif) then
      begin
        ExtList := FreeImage_GetFIFExtensionList(fif);
        s := '';
        for I := 1 to Length(ExtList) do
          begin
            C := ExtList[i];
            if C <> ',' then
              S := S + C
            else
              begin
                result := Result + FreeImage_GetFIFDescription(fif) + ' (' + UpperCase(s) + ')|*.' + s + '|';
                s := '';
              end;
          end;
        result := Result + FreeImage_GetFIFDescription(fif) + ' (' + UpperCase(s) + ')|*.' + s + '|';
      end;
end;

end.