13#if defined(MISSING_STD_IOS_BINARY)
14# define IOS_IN_BINARY ios::in
16# define IOS_IN_BINARY ios::in | ios::binary
21using namespace Magick;
28 myBlob( ifstream &stream_ )
31 unsigned char* blobData =
new unsigned char[100000];
32 char* c=
reinterpret_cast<char *
>(blobData);
34 while( (blobLen< 100000) && stream_.get(*c) )
39 if ((!stream_.eof()) || (blobLen == 0))
41 cout <<
"Failed to stream into blob!" << endl;
46 updateNoCopy(
reinterpret_cast<unsigned char*
>(blobData), blobLen,
52int main(
int ,
char ** argv)
56 InitializeMagick(*argv);
63 if(getenv(
"SRCDIR") != 0)
64 srcdir = getenv(
"SRCDIR");
74 Image image(srcdir +
"test_image.miff");
75 signature = image.signature();
79 testimage = srcdir +
"test_image.miff";
80 ifstream in( testimage.c_str(), ios::in | IOS_IN_BINARY );
83 cout <<
"Failed to open file " << testimage <<
" for input!" << endl;
86 unsigned char* blobData =
new unsigned char[100000];
87 char* c=
reinterpret_cast<char *
>(blobData);
89 while( (blobLen< 100000) && in.get(*c) )
94 if ((!in.eof()) || (blobLen == 0))
96 cout <<
"Failed to read file " << testimage <<
" for input!" << endl;
102 Blob blob(
static_cast<const unsigned char*
>(blobData), blobLen);
109 if ( image.signature() != signature )
112 cout <<
"Line: " << __LINE__
113 <<
" Image signature "
116 << signature << endl;
123 if ( image.signature() != signature )
126 cout <<
"Line: " << __LINE__
127 <<
" Image signature "
130 << signature << endl;
138 if ( image.signature() != signature )
141 cout <<
"Line: " << __LINE__
142 <<
" Image signature "
145 << signature << endl;
153 image.read( blob,
Geometry(148,99) );
154 if ( image.signature() != signature )
157 cout <<
"Line: " << __LINE__
158 <<
" Image signature "
161 << signature << endl;
170 string signature(
"");
172 Image image(srcdir +
"test_image.miff");
173 image.magick(
"MIFF");
174 image.write( &blob );
175 signature = image.signature();
179 if ( image.signature() != signature )
182 cout <<
"Line: " << __LINE__
183 <<
" Image signature "
186 << signature << endl;
197 readImages( &first, srcdir +
"test_image_anim.miff" );
198 writeImages( first.begin(), first.end(), &blob,
true );
204 string signature(
"");
206 Image image(srcdir +
"test_image.miff");
207 signature = image.signature();
211 testimage = srcdir +
"test_image.miff";
212 ifstream in( testimage.c_str(), ios::in | IOS_IN_BINARY );
215 cout <<
"Failed to open file for input!" << endl;
223 if ( image.signature() != signature )
226 cout <<
"Line: " << __LINE__
227 <<
" Image signature "
230 << signature << endl;
237 cout <<
"Caught exception: " << error_.what() << endl;
240 catch( exception &error_ )
242 cout <<
"Caught exception: " << error_.what() << endl;
248 cout << failures <<
" failures" << endl;