/*  $Id: outline_provider_bitmap_generic.h,v 1.2 2004/04/05 09:51:58 sphair Exp $
**
**  ClanLib Game SDK
**  Copyright (C) 2003  The ClanLib Team
**  For a total list of contributers see the file CREDITS.
**
**  This library is free software; you can redistribute it and/or
**  modify it under the terms of the GNU Lesser General Public
**  License as published by the Free Software Foundation; either
**  version 2.1 of the License, or (at your option) any later version.
**
**  This library 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
**  Lesser General Public License for more details.
**
**  You should have received a copy of the GNU Lesser General Public
**  License along with this library; if not, write to the Free Software
**  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
**
*/
#ifndef header_outline_provider_bitmap_generic
#define header_outline_provider_bitmap_generic

#include "API/Display/Collision/contour.h"

class CL_PixelBuffer;

class CL_OutlineProviderBitmap_Generic
{
//!Construction
 public:
	CL_OutlineProviderBitmap_Generic(CL_PixelBuffer *pbuf, int alpha_limit=128 );
	~CL_OutlineProviderBitmap_Generic();

//!Attributes
	std::vector<CL_Contour> contours;
	int width, height;

 private:
	// find the start point of the next outline
	CL_Pointf find_next_contour_start(unsigned int x, unsigned int y);

	void get_next_point(std::vector<CL_Pointf> &points);

	// test if a point is already included in some outline
	bool point_in_outline(unsigned int x, unsigned int y);

	// center points around 0,0
	void center(std::vector<CL_Pointf> &points);

	CL_PixelBuffer *pb;
	unsigned char *data;
	int pitch;
	int bpp;
	int alpha_limit;
	unsigned char consecutive_left_turns;
	unsigned char consecutive_right_turns;
	
	enum MoveDir
	{
		DIR_LEFT=0,
		DIR_RIGHT,
		DIR_UP,
		DIR_DOWN
	} last_dir;

	CL_Pointf last_point;
	
};

#endif
