#ifndef _CV_COLOR_IMAGE_H
#define _CV_COLOR_IMAGE_H


//----------------
#include "ofCore.h"
#include "ofCvConstants.h"

class ofCvGrayscaleImage;
class ofCvFloatImage;

//------------------------------------
class ofCvColorImage {

	public:

		ofCvColorImage();
		ofCvColorImage(int _w, int _h);
		~ofCvColorImage();

		void allocate(int _w, int _h);
		void clear();
		void setFromPixels(unsigned char * _pixels, int w, int h);
		void setFromGrayscaleImage(ofCvGrayscaleImage& mom);
		void setFromFloatImage(ofCvFloatImage& mom);
		
		// singular (inernal) operations:
		void set(int value);
		void set(int r, int g, int b);

		// 1->1 (one to one) operations
		void warpIntoMe(ofCvColorImage mom, ofCvPoint2f src[4], ofCvPoint2f dst[4]);
		
		
		// operators ------------------------------
		void operator =		( ofCvColorImage & mom );
		void operator +=	( ofCvColorImage & mom );
		void operator -=	( ofCvColorImage & mom );
		void operator *=	( ofCvColorImage & mom );
		// ----------------------------------------
		
		unsigned char 	* getPixels();
		IplImage 		* getCvImage(){ return cvImage;};

		void 			draw(float x, float y);
		void 			draw(float x, float y, float w, float h);

		int 			width, height;


	private:

		//----------------------------
		// internal functionality
		// we will use two iplImages internally, since many of the
		// operations expect a "src" and a "swap"
		//----------------------------

		IplImage		* 	cvImage;
		IplImage		* 	cvImageTemp;
		IplImage		*	cvImageGray;
		void 			swapTemp();		// make the "dst" image the current "src" image

		unsigned char 	* 	pixels;		// not width stepped
		ofTexture 			tex;		// internal tex

		bool				bAllocated;
};



#endif
