#ifndef G12BUFFER_H_
#define G12BUFFER_H_
/**
 * \file g12buffer.h
 * \brief a header for g12buffer.c
 *
 *
 *  \ingroup corefiles
 * \date Apr 14, 2009
 * \author Alexander Pimenov
 *
 */

#ifdef __cplusplus
	extern "C" {
#endif
#include <stdint.h>

#include "projective.h"


#define G12BUFFER_MAX_VALUE (0xFFF)
#define G12ELEM(G12buf, X, Y)  (G12buf)->data[(G12buf)->w * (Y) + (X)]

/**
 * \brief This buffer holds the greyscale buffer with 12 bits death.
 */
typedef struct g12Buffer_TAG {
	int h;
	int w;
	uint16_t *data;
} G12Buffer;


G12Buffer *g12BufferCreate(int h, int w);
G12Buffer *g12BufferClone(G12Buffer *input);


void g12BufferDelete(G12Buffer *toDelete);
G12Buffer* g12BufferCreateFromRegion(G12Buffer *src, int x1, int y1, int x2, int y2);

G12Buffer* applyAffineTransformBilinear (projectiveTransform2D inverseTransform, G12Buffer *input, int newh, int neww);

G12Buffer *g12BufferSobelX (G12Buffer *input);

G12Buffer *g12BufferSobelY (G12Buffer *input);

G12Buffer *g12BufferSobelMag (G12Buffer *input, int scale);


void g12BufferGainOffset (G12Buffer *input, double gain, int offset);

void g12BufferMapToInterval (G12Buffer *input, int32_t min, int32_t max);

#ifdef __cplusplus
	} // 	extern "C"
#endif
#endif /* G12BUFFER_H_ */
