1 // This may look like C code, but it is really -*- C++ -*-
2 //
3 // Copyright Bob Friesenhahn, 2001, 2002
4 // Copyright Dirk Lemstra 2013-2015
5 //
6 // CoderInfo implementation
7 //
8
9 #define MAGICKCORE_IMPLEMENTATION 1
10 #define MAGICK_PLUSPLUS_IMPLEMENTATION 1
11
12 #include "Magick++/Include.h"
13 #include "Magick++/CoderInfo.h"
14 #include "Magick++/Exception.h"
15
16 using namespace std;
17
CoderInfo(void)18 Magick::CoderInfo::CoderInfo(void)
19 : _decoderThreadSupport(false),
20 _description(),
21 _encoderThreadSupport(false),
22 _isMultiFrame(false),
23 _isReadable(false),
24 _isWritable(false),
25 _mimeType(),
26 _module(),
27 _name()
28 {
29 }
30
CoderInfo(const Magick::CoderInfo & coder_)31 Magick::CoderInfo::CoderInfo(const Magick::CoderInfo &coder_)
32 : _decoderThreadSupport(coder_._decoderThreadSupport),
33 _description(coder_._description),
34 _encoderThreadSupport(coder_._encoderThreadSupport),
35 _isMultiFrame(coder_._isMultiFrame),
36 _isReadable(coder_._isReadable),
37 _isWritable(coder_._isWritable),
38 _mimeType(coder_._mimeType),
39 _module(coder_._module),
40 _name(coder_._name)
41 {
42 }
43
CoderInfo(const std::string & name_)44 Magick::CoderInfo::CoderInfo(const std::string &name_)
45 : _decoderThreadSupport(false),
46 _description(),
47 _encoderThreadSupport(false),
48 _isMultiFrame(false),
49 _isReadable(false),
50 _isWritable(false),
51 _mimeType(),
52 _module(),
53 _name()
54 {
55 const Magick::MagickInfo
56 *magickInfo;
57
58 GetPPException;
59 magickInfo=GetMagickInfo(name_.c_str(),exceptionInfo);
60 ThrowPPException(false);
61 if (magickInfo == 0)
62 throwExceptionExplicit(MagickCore::OptionError,"Coder not found",
63 name_.c_str());
64 else
65 {
66 _decoderThreadSupport=(GetMagickDecoderThreadSupport(magickInfo) ==
67 MagickTrue) ? true : false;
68 _description=std::string(magickInfo->description);
69 _encoderThreadSupport=(GetMagickEncoderThreadSupport(magickInfo) ==
70 MagickTrue) ? true : false;
71 _isMultiFrame=(GetMagickAdjoin(magickInfo) == MagickTrue) ? true : false;
72 _isReadable=((magickInfo->decoder == (MagickCore::DecodeImageHandler *)
73 NULL) ? false : true);
74 _isWritable=((magickInfo->encoder == (MagickCore::EncodeImageHandler *)
75 NULL) ? false : true);
76 _mimeType=std::string(magickInfo->mime_type != (char *) NULL ?
77 magickInfo->mime_type : "");
78 _module=std::string(magickInfo->magick_module);
79 _name=std::string(magickInfo->name);
80 }
81 }
82
~CoderInfo(void)83 Magick::CoderInfo::~CoderInfo(void)
84 {
85 }
86
operator =(const CoderInfo & coder_)87 Magick::CoderInfo& Magick::CoderInfo::operator=(const CoderInfo &coder_)
88 {
89 // If not being set to ourself
90 if (this != &coder_)
91 {
92 _decoderThreadSupport=coder_._decoderThreadSupport;
93 _description=coder_._description;
94 _encoderThreadSupport=coder_._encoderThreadSupport;
95 _isMultiFrame=coder_._isMultiFrame;
96 _isReadable=coder_._isReadable;
97 _isWritable=coder_._isWritable;
98 _mimeType=coder_._mimeType;
99 _module=coder_._module;
100 _name=coder_._name;
101 }
102 return(*this);
103 }
104
canReadMultithreaded(void) const105 bool Magick::CoderInfo::canReadMultithreaded(void) const
106 {
107 return(_decoderThreadSupport);
108 }
109
canWriteMultithreaded(void) const110 bool Magick::CoderInfo::canWriteMultithreaded(void) const
111 {
112 return(_encoderThreadSupport);
113 }
114
description(void) const115 std::string Magick::CoderInfo::description(void) const
116 {
117 return(_description);
118 }
119
isReadable(void) const120 bool Magick::CoderInfo::isReadable(void) const
121 {
122 return(_isReadable);
123 }
124
isWritable(void) const125 bool Magick::CoderInfo::isWritable(void) const
126 {
127 return(_isWritable);
128 }
129
isMultiFrame(void) const130 bool Magick::CoderInfo::isMultiFrame(void) const
131 {
132 return(_isMultiFrame);
133 }
134
mimeType(void) const135 std::string Magick::CoderInfo::mimeType(void) const
136 {
137 return(_mimeType);
138 }
139
module(void) const140 std::string Magick::CoderInfo::module(void) const
141 {
142 return(_module);
143 }
144
name(void) const145 std::string Magick::CoderInfo::name(void) const
146 {
147 return(_name);
148 }
149
unregister(void) const150 bool Magick::CoderInfo::unregister(void) const
151 {
152 return(UnregisterMagickInfo(_name.c_str()) != MagickFalse);
153 }
154