// ****************************************************************************
// ************************* author: Maxime Lhuillier *************************
// ****************************************************************************


#ifndef __MSHORTIMAGE__H__
#define __MSHORTIMAGE__H__

#include <iostream>
#include "Mmx.h"
#include "Sse.h"
#include "MUtils.h"

using namespace std;

#include "MCharImage.h"
class MCharImage;

class MShortImage {
  int x__, y__,xMin_, xMax_, yMin_, yMax_;
  unsigned short *Map;
  inline void SetSize(int x_, int y_);
 public:
  MShortImage(int x_= 0, int y_= 0, int WithInit0= 0);
  ~MShortImage();

  inline int x() const { return x__; }
  inline int y() const { return y__; }
  inline void Bound(int&xMin, int&xMax, int&yMin, int&yMax) const {xMin= xMin_; xMax= xMax_; yMin= yMin_; yMax= yMax_;}
  inline const unsigned short& M_(int xx, int yy) const {return Map[xx+yy*x__];}
  inline unsigned short& M(int xx, int yy) {return Map[xx+yy*x__];}


  void ConvertFrom(const MCharImage& Image);

  //calcul du produit de 2 MCharImage, resultat dans une MShortImage
  void CharProduct(const MCharImage& Image1,const MCharImage& Image2);

  const MShortImage& operator=(const MShortImage& Image);
  void Smooth121(int IsHorizontal0Vertical1, const MShortImage& Data);
  
};

#endif

