/*
 * ImageScaler.h
 *
 * (c) 2002 by Thorsten Scheuermann <tscheuermann@gmx.net>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */

#ifndef IMAGESCALER_H
#define IMAGESCALER_H

#include "ImageDataSink.h"
#define USE_FIXED_POINT
#include "fixed.h"

/**
  *@author Thorsten Scheuermann
  */

class ImageScaler : public ImageDataSink
{
public: 
	ImageScaler();
	virtual ~ImageScaler();

	enum Rotation
	{
		ROTATION_CW,
		ROTATION_CCW,
		ROTATION_NONE
	};

	virtual void setImageDimension(int w, int h);
	virtual void setNumImageChannels(int c);
	virtual void startImage();
	virtual void endImage();
	virtual void imageRow(unsigned char *rowData);
	virtual void imageRow(fixed *rowData);

	void setOutputDimension(int width, int height);
	void setConsumer(ImageDataSink *c);

protected:
	fixed *accum;
	fixed *rowBuf;
	int accumSize;
	int destWidth, destHeight;
	int origWidth, origHeight;
	fixed xScale;
	fixed yScale;
	fixed scale;
	fixed yFrac;

	ImageDataSink *dataConsumer;

 	static const int numComponents;

  void scaleRow(unsigned char *row);
};

#endif
