blob: e00376349840984ea692fb646344dabc47254d3e (
plain)
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
|
/**
* Copyright: Mike Wey 2011
* License: zlib (See accompanying LICENSE file)
* Authors: Mike Wey
*/
module dmagick.CoderInfo;
import std.conv;
import std.string;
import dmagick.Exception;
import dmagick.c.magick;
/**
* This provides information about the image formats supported by
* Imagemagick. The MatchType determines if a coder should be returned
* in the array. MatchType.Any matches both MatchType.True
* and MatchType.True.
*
* Params:
* readable = Does the coder need to provide read support.
* writable = Does the coder need to provide write support.
* multiFrame = Does the coder need to provide multi frame support.
*/
CoderInfo[] coderInfoList(MatchType readable, MatchType writable, MatchType multiFrame)
{
size_t length;
CoderInfo[] list;
const(MagickInfo)*[] infoList =
GetMagickInfoList("*", &length, DMagickExceptionInfo())[0 .. length];
foreach ( info; infoList )
{
CoderInfo coder = CoderInfo(info);
if ( readable == MatchType.False && coder.readable )
continue;
if ( writable == MatchType.False && coder.writable )
continue;
if ( multiFrame == MatchType.False && coder.supportsMultiFrame )
continue;
list ~= coder;
}
return list;
}
/**
* CoderInfo provides the means to get information regarding ImageMagick
* support for an image format (designated by a magick string). It may be
* used to provide information for a specific named format (provided as an
* argument to the constructor).
*/
struct CoderInfo
{
/**
* Format name. (e.g. "GIF")
*/
string name;
/**
* Format description. (e.g. "CompuServe graphics interchange format")
*/
string description;
/**
* Format is readable.
*/
bool readable;
/**
* Format is writable.
*/
bool writable;
/**
* Format supports multiple frames.
*/
bool supportsMultiFrame;
/**
* Construct object corresponding to named format. (e.g. "GIF")
*/
this (string format)
{
const(MagickInfo)* info =
GetMagickInfo(toStringz(format), DMagickExceptionInfo());
this(info);
}
this (const(MagickInfo)* info)
{
name = to!(string)(info.name);
description = to!(string)(info.description);
readable = info.decoder !is null;
writable = info.encoder !is null;
supportsMultiFrame = info.adjoin != 0;
}
}
///
enum MatchType
{
Any, /// Don't care.
True, /// Matches.
False /// Doesn't match.
}
|