// ----------------------------------------------------------------------------
// picture.h
//
// Copyright (C) 2006-2008
//		Dave Freese, W1HKJ
// Copyright (C) 2008
//		Stelios Bounanos, M0GLD
//
// This file is part of fldigi.
//
// Fldigi 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 3 of the License, or
// (at your option) any later version.
//
// Fldigi 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with fldigi.  If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------

#ifndef picture_H
#define picture_H

#include <FL/Fl_Widget.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Image.H>

class picture : public Fl_Widget { 
private:
	unsigned char *vidbuf;
	int bufsize;
	int width;
	int height;
	int depth;
	int numcol;
	int slantdir;
	void slant_corr(int x, int y);
	void slant_undo();
	int zoom ;
	int background ;
	static void draw_cb(void *data, int x, int y, int w, uchar *buf);
	void	resize_zoom(int, int, int, int);
public:
	picture(int, int, int, int, int bg_col = 0);
	~picture();
	void	video(unsigned char *, int);
	void	pixel(unsigned char, int);
	unsigned char	pixel(int);
	int		handle(int);
	void	draw();
	void	clear();
	void	image(Fl_Image *img) {Fl_Widget::image(img);}
	void	resize(int, int, int, int);
	void    resize_height(int new_height, bool clear_img);
	void    shift_horizontal_center(int hShift);
	void    stretch(double the_ratio);
	int	save_png(const char * filename, const char * extra_comments = NULL);
	void    set_zoom(int the_zoom);
	int     pix_width(void) const {
		return width ;
	}
	int     pix_height(void) const {
		return height ;
	}
	const unsigned char * buffer(void) const {
		return vidbuf;
	}
};

class picbox : public Fl_Box
{
public:
	picbox(int x, int y, int w, int h, const char* l = 0)
		: Fl_Box(x, y, w, h, l) { }
	int handle(int event);
};

#endif
