mimas::image_fileinput< T > Class Template Reference
[Image Input]

Class for reading an image from a stream. More...

#include <image_fileinput.h>

Inheritance diagram for mimas::image_fileinput< T >:

Inheritance graph
[legend]
Collaboration diagram for mimas::image_fileinput< T >:

Collaboration graph
[legend]
List of all members.

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.

Detailed Description

template<typename T>
class mimas::image_fileinput< T >

Class for reading an image from a stream.

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;
}

Author:
Jan Wedekind (jan at wedesoft.de)
Date:
Thu Jan 12 14:19:44 UTC 2006
See also:
image_fileoutput

image_filesinput

Definition at line 46 of file image_fileinput.h.


Constructor & Destructor Documentation

template<typename T>
mimas::image_fileinput< T >::image_fileinput ( std::istream &  _stream  )  [inline, explicit]

Constructor.

The constructor stores a pointer to the specified stream-object.

Parameters:
_stream Stream to read image from later.

Definition at line 52 of file image_fileinput.h.


Member Function Documentation

template<typename T>
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).

Parameters:
image Object to store image in.

Implements mimas::image_input< T >.

Referenced by mimas::operator>>().

template<typename T>
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.

template<typename T>
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".

template<>
const char * mimas::image_fileinput< unsigned char >::mapString ( void   ) 

template<>
const char * mimas::image_fileinput< rgba< unsigned char > >::mapString ( void   ) 


Member Data Documentation

template<typename T>
std::istream* mimas::image_fileinput< T >::stream [protected]

Pointer to stream.

Definition at line 70 of file image_fileinput.h.

template<typename T>
boost::shared_ptr< std::list< Magick::Image > > mimas::image_fileinput< T >::images [protected]

Buffer for unread images.

Definition at line 72 of file image_fileinput.h.


The documentation for this class was generated from the following file:
[GNU/Linux] [Qt] [Mesa] [STL] [Lapack] [Boost] [Magick++] [Xalan-C and Xerces-C] [doxygen] [graphviz] [FFTW] [popt] [xine] [Gnuplot] [gnu-arch] [gcc] [gstreamer] [autoconf/automake/make] [freshmeat.net] [opensource.org] [sourceforge.net] [MMVL]
mimas 2.1 - Copyright Mon Oct 30 11:31:31 2006, Bala Amavasai, Stuart Meikle, Arul Selvan, Fabio Caparrelli, Jan Wedekind, Manuel Boissenin, ...