#include <image_fileinput.h>
Inheritance diagram for mimas::image_fileinput< T >:
Public Member Functions | |
image_fileinput (std::istream &_stream) | |
Constructor. | |
virtual void | read (image< T > &image) throw (mimasexception) |
Read image from stream. | |
template<> | |
const char * | mapString (void) |
template<> | |
const char * | mapString (void) |
Static Public Member Functions | |
static std::map< std::string, bool > | formats (void) |
Get list of supported file-formats. | |
Static Protected Member Functions | |
static const char * | mapString (void) |
Identification of mapping. | |
Protected Attributes | |
std::istream * | stream |
Pointer to stream. | |
boost::shared_ptr< std::list< Magick::Image > > | images |
Buffer for unread images. |
The stream is used for reading image(s) from.
The Magick++ library is used for reading the images.
Currently Magick++ supports reading the following file-formats: 8BIM 8BIMTEXT 8BIMWTEXT APP1 APP1JPEG ART AVI AVS BIE BMP CAPTION CMYK CMYKA CUR CUT DCM DCX DPS DPX EPDF EPI EPS EPSF EPSI EPT EXIF FAX FITS FPX FRACTAL G3 GIF GIF87 GRADIENT GRANITE GRAY ICB ICC ICM ICO ICON IPTC IPTCTEXT IPTCWTEXT JBG JBIG JNG JPEG JPG LABEL LOGO M2V MAGICK MAP MAT MIFF MNG MONO MPC MPEG MPG MSL MTV MVG NETSCAPE NULL OTB P7 PAL PALM PATTERN PBM PCD PCDS PCT PCX PDB PDF PFA FB PGM PICON PICT PIX PLASMA PM PNG PNG24 PNG32 PNG8 PNM PPM PS PSD PTIF PWP RAS RGB RGBA RLA RLE SCT SFW SGI STEGANO SUN SVG TEXT TGA TIF TIFF TILE TIM TTF TXT UYVY VDA VICAR VID VIFF VST WBMP WMF WPG X XBM XC XCF XMP XPM XV XWD YUV
The following example demonstrates, how easy it is to load an image:
#include <fstream> #include <GL/glut.h> #include "image_fileinput.h" #include "image_mesaoutput.h" using namespace std; using namespace mimas; // Minimal program for displaying single image. int main( int argc, char *argv[] ) { int retVal = 0; try { // Initialise GLUT. glutInit( &argc, argv ); // Check command-line. MMERROR( argc == 2, mimasexception, , "Syntax: " << argv[0] << " <image>" ); // Open X11 display. x11_display disp; // Load single image. ifstream f( argv[1], ios::binary ); image< rgba< unsigned char > > img; f >> img; // Display the image. image_mesaoutput< rgba< unsigned char > > win( &disp ); win << img << mimas::pause(); } catch ( exception &e ) { // Print error message. cerr << e.what() << endl; retVal = 1; }; return retVal; }
Loading images from a multi-image file (such as animated GIF or PDF) requires you to instantiate an image_fileinput
object:
#include <fstream> #include <GL/glut.h> #include "image_fileinput.h" #include "image_mesaoutput.h" using namespace std; using namespace mimas; // Minimal program for displaying multiple images from a single file. int main( int argc, char *argv[] ) { int retVal = 0; try { // Initialise GLUT. glutInit( &argc, argv ); // Check command-line. MMERROR( argc == 2, mimasexception, , "Syntax: " << argv[0] << " <image>" ); // Open X11 display. x11_display disp; // Load file. ifstream f( argv[1], ios::binary ); image_fileinput< rgba< unsigned char > > input( f ); // Open window. image_mesaoutput< rgba< unsigned char > > win( &disp ); // Allocate image. image< rgba< unsigned char > > img; while( input ) { // Read image. input >> img; // Display image. win << img << mimas::delay( 300 ); }; win << mimas::pause(); } catch ( exception &e ) { // Print error message. cerr << e.what() << endl; retVal = 1; }; return retVal; }
Definition at line 46 of file image_fileinput.h.
mimas::image_fileinput< T >::image_fileinput | ( | std::istream & | _stream | ) | [inline, explicit] |
Constructor.
The constructor stores a pointer to the specified stream-object.
_stream | Stream to read image from later. |
Definition at line 52 of file image_fileinput.h.
virtual void mimas::image_fileinput< T >::read | ( | image< T > & | image | ) | throw (mimasexception) [virtual] |
Read image from stream.
An image is constructed from the data provided by the stream. If there are no more images, the state of this object is set to false
(end of stream).
image | Object to store image in. |
Implements mimas::image_input< T >.
Referenced by mimas::operator>>().
static std::map< std::string, bool > mimas::image_fileinput< T >::formats | ( | void | ) | [static] |
Get list of supported file-formats.
Gets a map of file-formats, which have read-support by Magick++. The boolean is indicating, wether the file-formats may contain multiple images or not.
static const char* mimas::image_fileinput< T >::mapString | ( | void | ) | [static, protected] |
Identification of mapping.
This method returns a parameter passed to Magick::Image::write
. The return value either is "BGRA" or "I".
const char * mimas::image_fileinput< unsigned char >::mapString | ( | void | ) |
const char * mimas::image_fileinput< rgba< unsigned char > >::mapString | ( | void | ) |
std::istream* mimas::image_fileinput< T >::stream [protected] |
boost::shared_ptr< std::list< Magick::Image > > mimas::image_fileinput< T >::images [protected] |