File: bitmap.h

package info (click to toggle)
rafkill 1.2.2-3.3
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 13,268 kB
  • sloc: cpp: 13,508; makefile: 64; sh: 14
file content (200 lines) | stat: -rw-r--r-- 5,653 bytes parent folder | download | duplicates (12)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#ifndef _bitmap_h_
#define _bitmap_h_

#include <string>
#include <vector>

#include <iostream>

/*
#ifdef WINDOWS
#include <winalleg.h>
#endif
*/

struct BITMAP;
struct FONT;
class Font;

using namespace std;

class Bitmap{
public:

	static Bitmap * Screen;
	
	/* default constructor makes 10x10 bitmap */
	Bitmap();
	Bitmap( int x, int y );
	Bitmap( const char * load_file );
	Bitmap( const string & load_file );
	Bitmap( const char * load_file, int sx, int sy );
	Bitmap( const char * load_file, int sx, int sy, double accuracy );
	Bitmap( BITMAP * who, bool deep_copy = false );
	Bitmap( const Bitmap & copy, bool deep_copy = false );
	Bitmap( const Bitmap & copy, int sx, int sy );
	Bitmap( const Bitmap & copy, int sx, int sy, double accuracy );
	Bitmap( const Bitmap & copy, int x, int y, int width, int height );
	virtual ~Bitmap();

	virtual void save( const string & str );

	Bitmap & operator=( const Bitmap & );

	const int getWidth() const;
	const int getHeight() const;

	/*
	inline const int getWidth() const{
		return getBitmap()->w;
	}

	inline const int getHeight() const{
		return getBitmap()->h;
	}
	*/

	/*
	inline const int getWidth() const{
		return my_bitmap->w;
	}

	inline const int getHeight() const{
		return my_bitmap->h;
	}
	*/

	void detach();

	static void transBlender( int r, int g, int b, int a );
	static void multiplyBlender( int r, int g, int b, int a );

	static void drawingMode( int type );

	void acquire();
	void release();

	void resize( const int width, const int height );
	
	void debugSelf() const;

	void printf( int x, int y, int color, FONT * f, const char * str, ... ) const;
	void printf( int x, int y, int color, Font * f, const char * str, ... ) const;
	void printf( int x, int y, int color, Font * f, const string & str ) const;
	void printfNormal( int x, int y, int color, const char * str, ... ) const;
	void printfNormal( int x, int y, int color, const string & str ) const;
	void triangle( int x1, int y1, int x2, int y2, int x3, int y3, int color ) const;
	void ellipse( int x, int y, int rx, int ry, int color ) const;
	void ellipseFill( int x, int y, int rx, int ry, int color ) const;

	void rectangle( int x1, int y1, int x2, int y2, int color ) const;
	void rectangleFill( int x1, int y1, int x2, int y2, int color ) const;
	void circleFill( int x, int y, int radius, int color ) const;
	void circle( int x, int y, int radius, int color ) const;
	void line( const int x1, const int y1, const int x2, const int y2, const int color ) const;
		
	void horizontalLine( const int x1, const int y, const int x2, const int color ) const;
	void hLine( const int x1, const int y, const int x2, const int color ) const;
	void vLine( const int y1, const int x, const int y2, const int color ) const;
	void polygon( const int * verts, const int nverts, const int color ) const;

	void drawBorder( const int border, const int color ) const;
	void draw( const int x, const int y, const Bitmap & where ) const;
	void drawLit( const int x, const int y, const int level, const Bitmap & where ) const;
	void drawHFlip( const int x, const int y, const Bitmap & where );
	void drawTrans( const int x, const int y, const Bitmap & where ) const;
	void drawMask( const int x, const int y, const Bitmap & where );
	void drawStretched( const int x, const int y, const int new_width, const int new_height, const Bitmap & who );
	void drawRotate( const int x, const int y, const int angle, const Bitmap & where );

	void Stretch( const Bitmap & where );
	void StretchBy2( const Bitmap & where );
	void StretchBy4( const Bitmap & where );
	void Blit( const string & xpath );
	void Blit( const Bitmap & where );
	void Blit( const int x, const int y, const Bitmap & where );
	void Blit( const int mx, const int my, const int wx, const int wy, const Bitmap & where );
	void Blit( const int mx, const int my, const int width, const int height, const int wx, const int wy, Bitmap & where );
	void BlitToScreen();
	void fill( int color ) const;

	inline void clear() const{
		this->fill( 0 );
	}

	bool getError();

	inline BITMAP * getBitmap() const{
		return _my_bitmap;
	}

	void readLine( vector< int > & vec, int y );
	const int getPixel( const int x, const int y ) const;

	void putPixel( int x, int y, int col ) const;

	/*
	inline int getPixel( int x, int y ) const{
		if ( x >= 0 && x < my_bitmap->w && y >= 0 && y <= my_bitmap->h )
			return _getpixel16( my_bitmap, x, y );
		return -1;
	}
	
	inline void putPixel( int x, int y, int col ) const{
		if ( x >= 0 && x < my_bitmap->w && y >= 0 && y <= my_bitmap->h )
			_putpixel16( my_bitmap, x, y, col );
	}
	*/

	inline const string & getPath() const{
		return path;
	}

	static int setGfxModeText();
	static int setGfxModeFullscreen( int x, int y );
	static int setGfxModeWindowed( int x, int y );

	static int makeColor( int r, int g, int b );
	static void hsvToRGB( float h, float s, float v, int * r, int * g, int * b );

	static int getRed( int x );
	static int getBlue( int x );
	static int getGreen( int x );

	/* Add two colors together
	 */
	static int addColor( int color1, int color2 );

	/*
	inline static int makeColor( int r, int g, int b ){
		return makecol16( r, g, b );
	}
	*/

	// static const int MaskColor = MASK_COLOR_16;
	static const int MaskColor;
	static const int MODE_TRANS;
	static const int MODE_SOLID;

protected:

	void releaseInternalBitmap();

	inline void setBitmap( BITMAP * bitmap ){
		if ( bitmap == NULL ){
			cout << "*FATAL* Setting null bitmap" << endl;
		}
		_my_bitmap = bitmap;
	}

	void internalLoadFile( const char * load_file );

	BITMAP * _my_bitmap;
	int * own;
	// bool own;
	bool error;
	string path;

};

#endif