37 template <
typename TImageContainer>
43 const Magick::PixelPacket *cacheRead;
46 Magick::InitializeMagick(NULL);
52 img.read ( filename );
56 std::cout <<
"MagickReader : can't open " << filename << endl;
60 w = img.size().width();
61 h = img.size().height();
64 img.type ( Magick::TrueColorType );
66 cacheRead = img.getConstPixels ( 0, 0, w, h );
71 typename TImageContainer::Point firstPoint;
72 typename TImageContainer::Point lastPoint;
74 firstPoint = TImageContainer::Point::zero;
78 typename TImageContainer::Domain domain(firstPoint,lastPoint);
79 TImageContainer image(domain);
80 typename TImageContainer::Value val;
83 typename TImageContainer::Domain::ConstIterator it = domain.begin(),
86 for(; it != itend; ++it)
88 const Magick::PixelPacket *pixel = cacheRead + w * ((topbotomOrder)? ( h - 1 - (*it)[1] ): (*it)[1] ) + (*it)[0];
90 val = (pixel->red + pixel->green + pixel->blue) % 256;
92 image.setValue( (*it), val );