/* Network-Integrated Multimedia Middleware (NMM)
 * http://www.motama.com/nmm.html
 *
 * Copyright (C) 2006-2007
 * Motama GmbH, Saarbruecken, Germany
 * http://www.motama.com
 *
 * This file is part of NMM. 
 * 
 * NMM is free software; you can redistribute it and/or modify it    
 * under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; only version 2 of the License.      
 * 
 * NMM is distributed in the hope that it will be useful, but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 
 * License for more details.  
 * 
 * You should have received a copy of the GNU General Public License 
 * along with NMM; if not, write to the Free Software Foundation,    
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */

#ifndef NMM_IBitmapReader_HPP
#define NMM_IBitmapReader_HPP

#include "nmm/nmm_prefix.hpp"

#include "nmm/comm/Interface.hpp"
#include "nmm/comm/messaging/Event.hpp"
#include "nmm/comm/messaging/IllegalStateException.hpp"
#include <memory>


#include "visibility.hpp"

namespace NMM
{

  class DLLEXPORT IBitmapReader : virtual public NMM::Interface { 
  public:    /** Bitmap format. */

  enum Format { 
    RGBA = 0 , 
    YV12 = 1 , 
    YV12A = 2  };

    IBitmapReader() : NMM::Interface(IBitmapReader::IBitmapReader_type, "NMM") { };

    IBitmapReader(NMM::NMMObject& parent) : NMM::Interface (parent, IBitmapReader::IBitmapReader_type, "NMM") { };

    virtual ~IBitmapReader() {};

    static const char* IBitmapReader_type;

    virtual  string getInterfaceType() const { return IBitmapReader_type; }

    NMM::Interface* copy() const { return new IBitmapReader(*this); }
    static void used(); 
    static const char* loadImage_event;
    static const char* getImage_event;
    static const char* createImage_event;
    static const char* freeImage_event;
    static const char* freeAll_event;
    /**
     * loads a (PNG) image that can be accessed by the given identifier
     * @param id identifier for accessing image later
     * @param filename filename of the (png) image
     * @param f color format that should be used (RGBA, YV12, YV12A)
     * @returns true, if bitmap could be read
     * Note: an image that is already saved under the given id, will be deleted before automatically
     */

    virtual nmm_bool loadImage(const string& id, const string& filename, const IBitmapReader::Format& f = IBitmapReader::RGBA)
      throw(const NMM::SerializedException&);
    /**
     * Get width and height of an image.
     * @param id identifier of the image
     * @param w width of the image
     * @param h width of the image
     */

    virtual void getImage(const string& id, nmm_uint32& w, nmm_uint32& h)
      throw(const NMM::SerializedException&);
    /**
     * Creates an image with the given color.
     * @param id identifier for accessing image later
     * @param width width of the bitmap
     * @param height height of the bitmap
     * @param color color of the image (RGBA)
     * @param f color format that should be used (RGBA, YV12, YV12A)
     */

    virtual nmm_bool createImage(const string& id, const nmm_uint32& width, const nmm_uint32& height, const nmm_uint32& color1, const nmm_uint32& color2, const nmm_uint32& color3, const IBitmapReader::Format& f = IBitmapReader::RGBA)
      throw(const NMM::SerializedException&);
    /** Deletes image with the given id */

    virtual void freeImage(const string& id)
      throw(const NMM::SerializedException&);
    /** Deletes all read images */

    virtual void freeAll()
      throw(const NMM::SerializedException&);


  };

  typedef auto_ptr<IBitmapReader> IBitmapReader_var;

  DLLEXPORT NMM::OValueStream& operator<<(NMM::OValueStream& ov, const IBitmapReader::Format& t);
  DLLEXPORT NMM::IValueStream& operator>>(NMM::IValueStream& iv, IBitmapReader::Format& t);



}

#include "nmm/nmm_suffix.hpp"

#endif
