File: PPMPump.h

package info (click to toggle)
smilutils 0.3.0-10
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 3,008 kB
  • ctags: 2,647
  • sloc: cpp: 13,066; sh: 8,861; ansic: 8,309; makefile: 294
file content (71 lines) | stat: -rw-r--r-- 2,171 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
 * PPMPump.cc -- PPM Pump Implementation
 * Copyright (C) 2003 Charles Yates <charles.yates@pandora.be>
 *
 * 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.
 *
 * This program 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 this program; if not, write to the Free Software Foundation,
 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef _KINO_PPM_PUMP_
#define _KINO_PPM_PUMP_

#include <stdio.h>
#include <string>

using std::string;

#include "DVPump.h"

class PPMFrame
{
	public:
		PPMFrame();
		PPMFrame( int width, int height );
		PPMFrame( PPMFrame &frame );
		virtual ~PPMFrame();
		virtual int ReadData( uint8_t *data, int length );
		virtual int WriteData( uint8_t *data, int length );
		virtual bool Flush( );
		uint8_t *GetImage( ) const;
		uint8_t *GetImage( int &_width, int &_height ) const;
		virtual bool ReadImage( );
		virtual bool WriteImage( bool alpha = false );
		bool GetPixel( uint8_t rgb[ 4 ], int x, int y );
		bool SetPixel( uint8_t rgb[ 4 ], int x, int y );
		void FillArea( int x, int y, int width, int height, uint8_t rgb[ 4 ] );
		bool Scale( int _width, int _height, int _quality = 3 );
		bool Overlay( string file, int x, int y, int w, int h, double weight = 1.0 );
		bool Overlay( PPMFrame &frame, int x, int y, int w, int h, double weight = 1.0 );
		bool Copy( PPMFrame & );
		bool Load( string filename );
		// Temporary
		void ExtractHeader( ) { }
		int GetWidth( ) { return width; }
		int GetHeight( ) { return height; }

	private:
		int ReadNumber( );
		bool ReadHeader( char *, int &, int &, int & );
		uint8_t *image;
		int width;
		int height;
		string description;
};

class PPMPump :
	public DataPump < PPMFrame >
{
};

#endif