/*********************************************************************
 * This file is part of the PRAPI library.
 *
 * Copyright (C) 2001 Topi Mäenpää and Jaakko Viertola
 * All rights reserved.
 *
 * This program is free software. You can redistribute and/or modify
 * it under the terms of the free software licence found in the
 * accompanying file "COPYING". The licence terms must always be
 * redistributed with this source file. The above copyright notice
 * must be reproduced in all modified and unmodified copies of this
 * source file.
 *
 * $Revision: 1.9 $
 *********************************************************************/

#ifndef _BMPCODEC_H
#define _BMPCODEC_H

#include <iostream>
#include <stdlib.h>
#include <Matrix.h>
#include <MatrixCodec.h>
#include "Color.h"

namespace prapi
{
	struct BitmapFileHeader
	{
		unsigned short bfType;
		unsigned bfSize;
		unsigned short bfReserved1;
		unsigned short bfReserved2;
		unsigned bfOffBits;
	};

	struct BitmapInfoHeader
	{
		unsigned biSize;
		int biWidth;
		int biHeight;
		unsigned short biPlanes;
		unsigned short biBitCount;
		unsigned biCompression;
		unsigned biSizeImage;
		int biXPelsPerMeter;
		int biYPelsPerMeter;
		unsigned biClrUsed;
		unsigned biClrImportant;
	};


	/**
	 * A codec for 24-bit color BMP images.
	 **/
	class ColorBmpCodec : public util::MatrixCodec<RGBColor<> >
	{
	public:
		void decodeMatrix(std::istream& in, util::Matrix<RGBColor<> >& mat) throw (util::MatrixException&, util::io::IOException&);
		void encodeMatrix(std::ostream& out, const util::Matrix<RGBColor<> >& mat) throw (util::MatrixException&, util::io::IOException&);
	};
}

#endif
