gosu 0.8.6-x86-mingw32 → 0.8.7-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gosu/Audio.hpp +171 -171
- data/Gosu/Bitmap.hpp +96 -96
- data/Gosu/Color.hpp +204 -204
- data/Gosu/Directories.hpp +36 -36
- data/Gosu/Font.hpp +83 -83
- data/Gosu/Gosu.hpp +34 -34
- data/Gosu/Graphics.hpp +115 -115
- data/Gosu/GraphicsBase.hpp +110 -110
- data/Gosu/IO.hpp +269 -269
- data/Gosu/Image.hpp +122 -122
- data/Gosu/ImageData.hpp +61 -61
- data/Gosu/Input.hpp +149 -149
- data/Gosu/Inspection.hpp +14 -14
- data/Gosu/Math.hpp +135 -135
- data/Gosu/Platform.hpp +93 -93
- data/Gosu/Sockets.hpp +156 -156
- data/Gosu/TR1.hpp +56 -56
- data/Gosu/Text.hpp +71 -71
- data/Gosu/TextInput.hpp +70 -70
- data/Gosu/Utility.hpp +28 -28
- data/Gosu/Version.hpp +19 -19
- data/Gosu/Window.hpp +145 -145
- data/examples/ChipmunkIntegration.rb +275 -275
- data/examples/CptnRuby.rb +223 -223
- data/examples/GosuZen.rb +68 -68
- data/examples/MoreChipmunkAndRMagick.rb +155 -155
- data/examples/OpenGLIntegration.rb +225 -225
- data/examples/RMagickIntegration.rb +417 -417
- data/examples/TextInput.rb +154 -154
- data/examples/Tutorial.rb +130 -130
- data/examples/media/Beep.wav +0 -0
- data/examples/media/CptnRuby Map.txt b/data/examples/media/CptnRuby → Map.txt +0 -0
- data/examples/media/Explosion.wav +0 -0
- data/examples/media/Landscape.svg +9 -9
- data/examples/media/Space.png +0 -0
- data/examples/media/Star.png +0 -0
- data/examples/media/Starfighter.bmp +0 -0
- data/lib/1.8/gosu.so +0 -0
- data/lib/1.9/gosu.so +0 -0
- data/lib/2.0/gosu.so +0 -0
- data/lib/2.1/gosu.so +0 -0
- data/lib/FreeImage.dll +0 -0
- data/lib/OpenAL32.dll +0 -0
- data/lib/gosu.rb +19 -16
- data/lib/gosu/patches.rb +81 -81
- data/lib/gosu/preview.rb +143 -139
- data/lib/gosu/run.rb +11 -11
- data/lib/gosu/swig_patches.rb +60 -60
- data/lib/gosu/zen.rb +89 -89
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df73ca132662b34b18796107171a789df123ca86
|
4
|
+
data.tar.gz: a7277391d6f01631d4168a4d7dc4883abe947a7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c18107d4fff35f8be824076b6932379e018f77f4a0bc7fec5b62f8313b96e899e43c5427ce84fe708c16279bdf37b09f469a07d1d3f49f02dd63fc34a766e55
|
7
|
+
data.tar.gz: 110f9914d6fa2643d52297adfbad4af77b6b643b46345974b0736ae084abf6dde0979bf3e56148f0dcf02bcd1ab6c4d0ab9b4e1fe82bc966c0fcc949d52cc8f7
|
data/Gosu/Audio.hpp
CHANGED
@@ -1,171 +1,171 @@
|
|
1
|
-
//! \file Audio.hpp
|
2
|
-
//! Contains all the classes of Gosu's audio system.
|
3
|
-
|
4
|
-
#ifndef GOSU_AUDIO_HPP
|
5
|
-
#define GOSU_AUDIO_HPP
|
6
|
-
|
7
|
-
#ifdef WIN32
|
8
|
-
#ifndef NOMINMAX
|
9
|
-
#define NOMINMAX
|
10
|
-
#endif
|
11
|
-
#include <windows.h>
|
12
|
-
#endif
|
13
|
-
#include <Gosu/Fwd.hpp>
|
14
|
-
#include <Gosu/IO.hpp>
|
15
|
-
#include <Gosu/Platform.hpp>
|
16
|
-
#include <Gosu/TR1.hpp>
|
17
|
-
#include <memory>
|
18
|
-
#include <string>
|
19
|
-
|
20
|
-
namespace Gosu
|
21
|
-
{
|
22
|
-
// Deprecated.
|
23
|
-
#ifndef SWIG
|
24
|
-
class
|
25
|
-
#endif
|
26
|
-
|
27
|
-
//! An instance of a Sample playing. Can be used to stop sounds dynamically,
|
28
|
-
//! or to check if they are finished.
|
29
|
-
//! It is recommended that you throw away sample instances if possible,
|
30
|
-
//! as they could accidentally refer to other sounds being played after
|
31
|
-
//! a very long time has passed.
|
32
|
-
class SampleInstance
|
33
|
-
{
|
34
|
-
int handle, extra;
|
35
|
-
bool alive() const;
|
36
|
-
|
37
|
-
public:
|
38
|
-
//! Called by Sample, do not use.
|
39
|
-
SampleInstance(int handle, int extra);
|
40
|
-
|
41
|
-
bool playing() const;
|
42
|
-
bool paused() const;
|
43
|
-
//! Pauses this instance to be resumed afterwards. It will still keep a channel filled while paused.
|
44
|
-
void pause();
|
45
|
-
void resume();
|
46
|
-
//! Stops this instance of a sound being played.
|
47
|
-
//! Calling this twice, or too late, does not do any harm.
|
48
|
-
void stop();
|
49
|
-
|
50
|
-
//! \param volume Can be anything from 0.0 (silence) to 1.0 (full
|
51
|
-
//! volume).
|
52
|
-
void changeVolume(double volume);
|
53
|
-
//! \param pan Can be anything from -1.0 (left) to 1.0 (right).
|
54
|
-
void changePan(double pan);
|
55
|
-
//! \param speed Playback speed is only limited by FMOD's
|
56
|
-
//! capabilities and can accept very high or low values. Use 1.0 for
|
57
|
-
//! normal playback speed.
|
58
|
-
void changeSpeed(double speed);
|
59
|
-
};
|
60
|
-
|
61
|
-
//! A sample is a short sound that is completely loaded in memory, can be
|
62
|
-
//! played multiple times at once and offers very flexible playback
|
63
|
-
//! parameters. Use samples for everything that's not music.
|
64
|
-
class Sample
|
65
|
-
{
|
66
|
-
struct SampleData;
|
67
|
-
std::tr1::shared_ptr<SampleData> data;
|
68
|
-
|
69
|
-
public:
|
70
|
-
//! Constructs a sample that can be played on the specified audio
|
71
|
-
//! system and loads the sample from a file.
|
72
|
-
explicit Sample(const std::wstring& filename);
|
73
|
-
|
74
|
-
//! Constructs a sample that can be played on the specified audio
|
75
|
-
//! system and loads the sample data from a stream.
|
76
|
-
explicit Sample(Reader reader);
|
77
|
-
|
78
|
-
//! Plays the sample without panning.
|
79
|
-
//! \param volume Can be anything from 0.0 (silence) to 1.0 (full
|
80
|
-
//! volume).
|
81
|
-
//! \param speed Playback speed is only limited by the underlying audio library,
|
82
|
-
//! and can accept very high or low values. Use 1.0 for
|
83
|
-
//! normal playback speed.
|
84
|
-
SampleInstance play(double volume = 1, double speed = 1,
|
85
|
-
bool looping = false) const;
|
86
|
-
|
87
|
-
//! Plays the sample with panning. Even if pan is 0.0, the sample will
|
88
|
-
//! not be as loud as if it were played by calling play() due to the
|
89
|
-
//! way the panning works.
|
90
|
-
//! \param pan Can be anything from -1.0 (left) to 1.0 (right).
|
91
|
-
//! \param volume Can be anything from 0.0 (silence) to 1.0 (full
|
92
|
-
//! volume).
|
93
|
-
//! \param speed Playback speed is only limited by by the underlying audio library,
|
94
|
-
//! and can accept very high
|
95
|
-
//! or low values. Use 1.0 for normal playback speed.
|
96
|
-
SampleInstance playPan(double pan, double volume = 1, double speed = 1,
|
97
|
-
bool looping = false) const;
|
98
|
-
|
99
|
-
#ifndef SWIG
|
100
|
-
GOSU_DEPRECATED Sample(Audio& audio, const std::wstring& filename);
|
101
|
-
GOSU_DEPRECATED Sample(Audio& audio, Reader reader);
|
102
|
-
#endif
|
103
|
-
};
|
104
|
-
|
105
|
-
//! Songs are less flexible than samples in that they can only be played
|
106
|
-
//! one at a time and without panning or speed parameters.
|
107
|
-
class Song
|
108
|
-
{
|
109
|
-
class BaseData;
|
110
|
-
class ModuleData;
|
111
|
-
class StreamData;
|
112
|
-
GOSU_UNIQUE_PTR<BaseData> data;
|
113
|
-
|
114
|
-
#if defined(GOSU_CPP11_ENABLED)
|
115
|
-
Song(Song&&) = delete;
|
116
|
-
Song& operator=(Song&&) = delete;
|
117
|
-
Song(const Song&) = delete;
|
118
|
-
Song& operator=(const Song&) = delete;
|
119
|
-
#else
|
120
|
-
Song(const Song&);
|
121
|
-
Song& operator=(const Song&);
|
122
|
-
#endif
|
123
|
-
|
124
|
-
public:
|
125
|
-
//! Constructs a song that can be played on the provided audio system
|
126
|
-
//! and loads the song from a file. The type is determined from the
|
127
|
-
//! filename.
|
128
|
-
explicit Song(const std::wstring& filename);
|
129
|
-
|
130
|
-
//! Constructs a song of the specified type that can be played on the
|
131
|
-
//! provided audio system and loads the song data from a stream.
|
132
|
-
explicit Song(Reader reader);
|
133
|
-
|
134
|
-
~Song();
|
135
|
-
|
136
|
-
//! Returns the song currently being played or paused, or 0 if
|
137
|
-
//! no song has been played yet or the last song has finished
|
138
|
-
//! playing.
|
139
|
-
static Song* currentSong();
|
140
|
-
|
141
|
-
//! Starts or resumes playback of the song. This will stop all other
|
142
|
-
//! songs and set the current song to this object.
|
143
|
-
void play(bool looping = false);
|
144
|
-
//! Pauses playback of the song. It is not considered being played.
|
145
|
-
//! currentSong will stay the same.
|
146
|
-
void pause();
|
147
|
-
//! Returns true if the song is the current song, but in paused
|
148
|
-
//! mode.
|
149
|
-
bool paused() const;
|
150
|
-
//! Stops playback of this song if it is currently played or paused.
|
151
|
-
//! Afterwards, currentSong will return 0.
|
152
|
-
void stop();
|
153
|
-
//! Returns true if the song is currently playing.
|
154
|
-
bool playing() const;
|
155
|
-
//! Returns the current volume of the song.
|
156
|
-
double volume() const;
|
157
|
-
//! Changes the volume of the song.
|
158
|
-
void changeVolume(double volume);
|
159
|
-
|
160
|
-
//! Called every tick by Window for management purposes.
|
161
|
-
static void update();
|
162
|
-
|
163
|
-
#ifndef SWIG
|
164
|
-
enum Type { stStream, stModule };
|
165
|
-
GOSU_DEPRECATED Song(Audio&, const std::wstring& filename);
|
166
|
-
GOSU_DEPRECATED Song(Audio&, Type type, Reader reader);
|
167
|
-
#endif
|
168
|
-
};
|
169
|
-
}
|
170
|
-
|
171
|
-
#endif
|
1
|
+
//! \file Audio.hpp
|
2
|
+
//! Contains all the classes of Gosu's audio system.
|
3
|
+
|
4
|
+
#ifndef GOSU_AUDIO_HPP
|
5
|
+
#define GOSU_AUDIO_HPP
|
6
|
+
|
7
|
+
#ifdef WIN32
|
8
|
+
#ifndef NOMINMAX
|
9
|
+
#define NOMINMAX
|
10
|
+
#endif
|
11
|
+
#include <windows.h>
|
12
|
+
#endif
|
13
|
+
#include <Gosu/Fwd.hpp>
|
14
|
+
#include <Gosu/IO.hpp>
|
15
|
+
#include <Gosu/Platform.hpp>
|
16
|
+
#include <Gosu/TR1.hpp>
|
17
|
+
#include <memory>
|
18
|
+
#include <string>
|
19
|
+
|
20
|
+
namespace Gosu
|
21
|
+
{
|
22
|
+
// Deprecated.
|
23
|
+
#ifndef SWIG
|
24
|
+
class Audio;
|
25
|
+
#endif
|
26
|
+
|
27
|
+
//! An instance of a Sample playing. Can be used to stop sounds dynamically,
|
28
|
+
//! or to check if they are finished.
|
29
|
+
//! It is recommended that you throw away sample instances if possible,
|
30
|
+
//! as they could accidentally refer to other sounds being played after
|
31
|
+
//! a very long time has passed.
|
32
|
+
class SampleInstance
|
33
|
+
{
|
34
|
+
int handle, extra;
|
35
|
+
bool alive() const;
|
36
|
+
|
37
|
+
public:
|
38
|
+
//! Called by Sample, do not use.
|
39
|
+
SampleInstance(int handle, int extra);
|
40
|
+
|
41
|
+
bool playing() const;
|
42
|
+
bool paused() const;
|
43
|
+
//! Pauses this instance to be resumed afterwards. It will still keep a channel filled while paused.
|
44
|
+
void pause();
|
45
|
+
void resume();
|
46
|
+
//! Stops this instance of a sound being played.
|
47
|
+
//! Calling this twice, or too late, does not do any harm.
|
48
|
+
void stop();
|
49
|
+
|
50
|
+
//! \param volume Can be anything from 0.0 (silence) to 1.0 (full
|
51
|
+
//! volume).
|
52
|
+
void changeVolume(double volume);
|
53
|
+
//! \param pan Can be anything from -1.0 (left) to 1.0 (right).
|
54
|
+
void changePan(double pan);
|
55
|
+
//! \param speed Playback speed is only limited by FMOD's
|
56
|
+
//! capabilities and can accept very high or low values. Use 1.0 for
|
57
|
+
//! normal playback speed.
|
58
|
+
void changeSpeed(double speed);
|
59
|
+
};
|
60
|
+
|
61
|
+
//! A sample is a short sound that is completely loaded in memory, can be
|
62
|
+
//! played multiple times at once and offers very flexible playback
|
63
|
+
//! parameters. Use samples for everything that's not music.
|
64
|
+
class Sample
|
65
|
+
{
|
66
|
+
struct SampleData;
|
67
|
+
std::tr1::shared_ptr<SampleData> data;
|
68
|
+
|
69
|
+
public:
|
70
|
+
//! Constructs a sample that can be played on the specified audio
|
71
|
+
//! system and loads the sample from a file.
|
72
|
+
explicit Sample(const std::wstring& filename);
|
73
|
+
|
74
|
+
//! Constructs a sample that can be played on the specified audio
|
75
|
+
//! system and loads the sample data from a stream.
|
76
|
+
explicit Sample(Reader reader);
|
77
|
+
|
78
|
+
//! Plays the sample without panning.
|
79
|
+
//! \param volume Can be anything from 0.0 (silence) to 1.0 (full
|
80
|
+
//! volume).
|
81
|
+
//! \param speed Playback speed is only limited by the underlying audio library,
|
82
|
+
//! and can accept very high or low values. Use 1.0 for
|
83
|
+
//! normal playback speed.
|
84
|
+
SampleInstance play(double volume = 1, double speed = 1,
|
85
|
+
bool looping = false) const;
|
86
|
+
|
87
|
+
//! Plays the sample with panning. Even if pan is 0.0, the sample will
|
88
|
+
//! not be as loud as if it were played by calling play() due to the
|
89
|
+
//! way the panning works.
|
90
|
+
//! \param pan Can be anything from -1.0 (left) to 1.0 (right).
|
91
|
+
//! \param volume Can be anything from 0.0 (silence) to 1.0 (full
|
92
|
+
//! volume).
|
93
|
+
//! \param speed Playback speed is only limited by by the underlying audio library,
|
94
|
+
//! and can accept very high
|
95
|
+
//! or low values. Use 1.0 for normal playback speed.
|
96
|
+
SampleInstance playPan(double pan, double volume = 1, double speed = 1,
|
97
|
+
bool looping = false) const;
|
98
|
+
|
99
|
+
#ifndef SWIG
|
100
|
+
GOSU_DEPRECATED Sample(Audio& audio, const std::wstring& filename);
|
101
|
+
GOSU_DEPRECATED Sample(Audio& audio, Reader reader);
|
102
|
+
#endif
|
103
|
+
};
|
104
|
+
|
105
|
+
//! Songs are less flexible than samples in that they can only be played
|
106
|
+
//! one at a time and without panning or speed parameters.
|
107
|
+
class Song
|
108
|
+
{
|
109
|
+
class BaseData;
|
110
|
+
class ModuleData;
|
111
|
+
class StreamData;
|
112
|
+
GOSU_UNIQUE_PTR<BaseData> data;
|
113
|
+
|
114
|
+
#if defined(GOSU_CPP11_ENABLED)
|
115
|
+
Song(Song&&) = delete;
|
116
|
+
Song& operator=(Song&&) = delete;
|
117
|
+
Song(const Song&) = delete;
|
118
|
+
Song& operator=(const Song&) = delete;
|
119
|
+
#else
|
120
|
+
Song(const Song&);
|
121
|
+
Song& operator=(const Song&);
|
122
|
+
#endif
|
123
|
+
|
124
|
+
public:
|
125
|
+
//! Constructs a song that can be played on the provided audio system
|
126
|
+
//! and loads the song from a file. The type is determined from the
|
127
|
+
//! filename.
|
128
|
+
explicit Song(const std::wstring& filename);
|
129
|
+
|
130
|
+
//! Constructs a song of the specified type that can be played on the
|
131
|
+
//! provided audio system and loads the song data from a stream.
|
132
|
+
explicit Song(Reader reader);
|
133
|
+
|
134
|
+
~Song();
|
135
|
+
|
136
|
+
//! Returns the song currently being played or paused, or 0 if
|
137
|
+
//! no song has been played yet or the last song has finished
|
138
|
+
//! playing.
|
139
|
+
static Song* currentSong();
|
140
|
+
|
141
|
+
//! Starts or resumes playback of the song. This will stop all other
|
142
|
+
//! songs and set the current song to this object.
|
143
|
+
void play(bool looping = false);
|
144
|
+
//! Pauses playback of the song. It is not considered being played.
|
145
|
+
//! currentSong will stay the same.
|
146
|
+
void pause();
|
147
|
+
//! Returns true if the song is the current song, but in paused
|
148
|
+
//! mode.
|
149
|
+
bool paused() const;
|
150
|
+
//! Stops playback of this song if it is currently played or paused.
|
151
|
+
//! Afterwards, currentSong will return 0.
|
152
|
+
void stop();
|
153
|
+
//! Returns true if the song is currently playing.
|
154
|
+
bool playing() const;
|
155
|
+
//! Returns the current volume of the song.
|
156
|
+
double volume() const;
|
157
|
+
//! Changes the volume of the song.
|
158
|
+
void changeVolume(double volume);
|
159
|
+
|
160
|
+
//! Called every tick by Window for management purposes.
|
161
|
+
static void update();
|
162
|
+
|
163
|
+
#ifndef SWIG
|
164
|
+
enum Type { stStream, stModule };
|
165
|
+
GOSU_DEPRECATED Song(Audio&, const std::wstring& filename);
|
166
|
+
GOSU_DEPRECATED Song(Audio&, Type type, Reader reader);
|
167
|
+
#endif
|
168
|
+
};
|
169
|
+
}
|
170
|
+
|
171
|
+
#endif
|
data/Gosu/Bitmap.hpp
CHANGED
@@ -1,96 +1,96 @@
|
|
1
|
-
//! \file Bitmap.hpp
|
2
|
-
//! Interface of the Bitmap class.
|
3
|
-
|
4
|
-
#ifndef GOSU_BITMAP_HPP
|
5
|
-
#define GOSU_BITMAP_HPP
|
6
|
-
|
7
|
-
#include <Gosu/Color.hpp>
|
8
|
-
#include <Gosu/Fwd.hpp>
|
9
|
-
#include <Gosu/GraphicsBase.hpp>
|
10
|
-
#include <Gosu/Platform.hpp>
|
11
|
-
#include <string>
|
12
|
-
#include <vector>
|
13
|
-
|
14
|
-
namespace Gosu
|
15
|
-
{
|
16
|
-
//! Rectangular area of pixels, each represented by a Color value. Provides
|
17
|
-
//! minimal drawing functionality and serves as a temporary holder for
|
18
|
-
//! graphical resources which are usually turned into Images later.
|
19
|
-
//! Has (expensive) value semantics.
|
20
|
-
class Bitmap
|
21
|
-
{
|
22
|
-
unsigned w, h;
|
23
|
-
std::vector<Color> pixels;
|
24
|
-
|
25
|
-
public:
|
26
|
-
Bitmap() : w(0), h(0) {}
|
27
|
-
Bitmap(unsigned w, unsigned h, Color c = Color::NONE) : w(w), h(h), pixels(w * h, c) {}
|
28
|
-
|
29
|
-
unsigned width() const { return w; }
|
30
|
-
unsigned height() const { return h; }
|
31
|
-
|
32
|
-
void swap(Bitmap& other);
|
33
|
-
|
34
|
-
void resize(unsigned width, unsigned height, Color c = Color::NONE);
|
35
|
-
|
36
|
-
//! Returns the color at the specified position. x and y must be on the
|
37
|
-
//! bitmap.
|
38
|
-
Color getPixel(unsigned x, unsigned y) const { return pixels[y * w + x]; }
|
39
|
-
|
40
|
-
//! Sets the pixel at the specified position to a color. x and y must
|
41
|
-
//! be on the bitmap.
|
42
|
-
void setPixel(unsigned x, unsigned y, Color c) { pixels[y * w + x] = c; }
|
43
|
-
|
44
|
-
//! Inserts a bitmap at the given position. Parts of the inserted
|
45
|
-
//! bitmap that would be outside of the target bitmap will be
|
46
|
-
//! clipped away.
|
47
|
-
void insert(const Bitmap& source, int x, int y);
|
48
|
-
|
49
|
-
//! Inserts a portion of a bitmap at the given position. Parts of the
|
50
|
-
//! inserted bitmap that would be outside of the target bitmap will be
|
51
|
-
//! clipped away.
|
52
|
-
void insert(const Bitmap& source, int x, int y, unsigned srcX,
|
53
|
-
unsigned srcY, unsigned srcWidth, unsigned srcHeight);
|
54
|
-
|
55
|
-
//! Direct access to the array of color values. May be useful for optimized
|
56
|
-
//! OpenGL operations.
|
57
|
-
const Color* data() const { return &pixels[0]; }
|
58
|
-
Color* data() { return &pixels[0]; }
|
59
|
-
|
60
|
-
// Work with data() instead if you need fast operations.
|
61
|
-
GOSU_DEPRECATED void fill(Color c);
|
62
|
-
GOSU_DEPRECATED void replace(Color oldColor, Color newColor);
|
63
|
-
};
|
64
|
-
|
65
|
-
//! Loads any supported image into a Bitmap.
|
66
|
-
void loadImageFile(Bitmap& bitmap, const std::wstring& filename);
|
67
|
-
//! Loads any supported image into a Bitmap.
|
68
|
-
void loadImageFile(Bitmap& bitmap, Reader input);
|
69
|
-
|
70
|
-
//! Saves a Bitmap to a file.
|
71
|
-
void saveImageFile(const Bitmap& bitmap, const std::wstring& filename);
|
72
|
-
//! Saves a Bitmap to an arbitrary resource.
|
73
|
-
void saveImageFile(const Bitmap& bitmap, Gosu::Writer writer,
|
74
|
-
const std::wstring& formatHint = L"png");
|
75
|
-
|
76
|
-
//! Set the alpha value of all pixels which are equal to the color key
|
77
|
-
//! to zero. Color values are adjusted so that no borders show up when
|
78
|
-
//! the image is stretched or rotated.
|
79
|
-
void applyColorKey(Bitmap& bitmap, Color key);
|
80
|
-
|
81
|
-
//! The reverse of applyColorKey. Resets all fully transparent pixels by
|
82
|
-
//! a background color, makes all other pixels fully opaque.
|
83
|
-
void unapplyColorKey(Bitmap& bitmap, Color background);
|
84
|
-
|
85
|
-
void applyBorderFlags(Bitmap& dest, const Bitmap& source,
|
86
|
-
unsigned srcX, unsigned srcY, unsigned srcWidth, unsigned srcHeight,
|
87
|
-
unsigned borderFlags);
|
88
|
-
|
89
|
-
// Use loadImageFile/saveImageFile instead.
|
90
|
-
GOSU_DEPRECATED Reader loadFromBMP(Bitmap& bmp, Reader reader);
|
91
|
-
GOSU_DEPRECATED Writer saveToBMP(const Bitmap& bmp, Writer writer);
|
92
|
-
GOSU_DEPRECATED Reader loadFromPNG(Bitmap& bmp, Reader reader);
|
93
|
-
GOSU_DEPRECATED Writer saveToPNG(const Bitmap& bmp, Writer writer);
|
94
|
-
}
|
95
|
-
|
96
|
-
#endif
|
1
|
+
//! \file Bitmap.hpp
|
2
|
+
//! Interface of the Bitmap class.
|
3
|
+
|
4
|
+
#ifndef GOSU_BITMAP_HPP
|
5
|
+
#define GOSU_BITMAP_HPP
|
6
|
+
|
7
|
+
#include <Gosu/Color.hpp>
|
8
|
+
#include <Gosu/Fwd.hpp>
|
9
|
+
#include <Gosu/GraphicsBase.hpp>
|
10
|
+
#include <Gosu/Platform.hpp>
|
11
|
+
#include <string>
|
12
|
+
#include <vector>
|
13
|
+
|
14
|
+
namespace Gosu
|
15
|
+
{
|
16
|
+
//! Rectangular area of pixels, each represented by a Color value. Provides
|
17
|
+
//! minimal drawing functionality and serves as a temporary holder for
|
18
|
+
//! graphical resources which are usually turned into Images later.
|
19
|
+
//! Has (expensive) value semantics.
|
20
|
+
class Bitmap
|
21
|
+
{
|
22
|
+
unsigned w, h;
|
23
|
+
std::vector<Color> pixels;
|
24
|
+
|
25
|
+
public:
|
26
|
+
Bitmap() : w(0), h(0) {}
|
27
|
+
Bitmap(unsigned w, unsigned h, Color c = Color::NONE) : w(w), h(h), pixels(w * h, c) {}
|
28
|
+
|
29
|
+
unsigned width() const { return w; }
|
30
|
+
unsigned height() const { return h; }
|
31
|
+
|
32
|
+
void swap(Bitmap& other);
|
33
|
+
|
34
|
+
void resize(unsigned width, unsigned height, Color c = Color::NONE);
|
35
|
+
|
36
|
+
//! Returns the color at the specified position. x and y must be on the
|
37
|
+
//! bitmap.
|
38
|
+
Color getPixel(unsigned x, unsigned y) const { return pixels[y * w + x]; }
|
39
|
+
|
40
|
+
//! Sets the pixel at the specified position to a color. x and y must
|
41
|
+
//! be on the bitmap.
|
42
|
+
void setPixel(unsigned x, unsigned y, Color c) { pixels[y * w + x] = c; }
|
43
|
+
|
44
|
+
//! Inserts a bitmap at the given position. Parts of the inserted
|
45
|
+
//! bitmap that would be outside of the target bitmap will be
|
46
|
+
//! clipped away.
|
47
|
+
void insert(const Bitmap& source, int x, int y);
|
48
|
+
|
49
|
+
//! Inserts a portion of a bitmap at the given position. Parts of the
|
50
|
+
//! inserted bitmap that would be outside of the target bitmap will be
|
51
|
+
//! clipped away.
|
52
|
+
void insert(const Bitmap& source, int x, int y, unsigned srcX,
|
53
|
+
unsigned srcY, unsigned srcWidth, unsigned srcHeight);
|
54
|
+
|
55
|
+
//! Direct access to the array of color values. May be useful for optimized
|
56
|
+
//! OpenGL operations.
|
57
|
+
const Color* data() const { return &pixels[0]; }
|
58
|
+
Color* data() { return &pixels[0]; }
|
59
|
+
|
60
|
+
// Work with data() instead if you need fast operations.
|
61
|
+
GOSU_DEPRECATED void fill(Color c);
|
62
|
+
GOSU_DEPRECATED void replace(Color oldColor, Color newColor);
|
63
|
+
};
|
64
|
+
|
65
|
+
//! Loads any supported image into a Bitmap.
|
66
|
+
void loadImageFile(Bitmap& bitmap, const std::wstring& filename);
|
67
|
+
//! Loads any supported image into a Bitmap.
|
68
|
+
void loadImageFile(Bitmap& bitmap, Reader input);
|
69
|
+
|
70
|
+
//! Saves a Bitmap to a file.
|
71
|
+
void saveImageFile(const Bitmap& bitmap, const std::wstring& filename);
|
72
|
+
//! Saves a Bitmap to an arbitrary resource.
|
73
|
+
void saveImageFile(const Bitmap& bitmap, Gosu::Writer writer,
|
74
|
+
const std::wstring& formatHint = L"png");
|
75
|
+
|
76
|
+
//! Set the alpha value of all pixels which are equal to the color key
|
77
|
+
//! to zero. Color values are adjusted so that no borders show up when
|
78
|
+
//! the image is stretched or rotated.
|
79
|
+
void applyColorKey(Bitmap& bitmap, Color key);
|
80
|
+
|
81
|
+
//! The reverse of applyColorKey. Resets all fully transparent pixels by
|
82
|
+
//! a background color, makes all other pixels fully opaque.
|
83
|
+
void unapplyColorKey(Bitmap& bitmap, Color background);
|
84
|
+
|
85
|
+
void applyBorderFlags(Bitmap& dest, const Bitmap& source,
|
86
|
+
unsigned srcX, unsigned srcY, unsigned srcWidth, unsigned srcHeight,
|
87
|
+
unsigned borderFlags);
|
88
|
+
|
89
|
+
// Use loadImageFile/saveImageFile instead.
|
90
|
+
GOSU_DEPRECATED Reader loadFromBMP(Bitmap& bmp, Reader reader);
|
91
|
+
GOSU_DEPRECATED Writer saveToBMP(const Bitmap& bmp, Writer writer);
|
92
|
+
GOSU_DEPRECATED Reader loadFromPNG(Bitmap& bmp, Reader reader);
|
93
|
+
GOSU_DEPRECATED Writer saveToPNG(const Bitmap& bmp, Writer writer);
|
94
|
+
}
|
95
|
+
|
96
|
+
#endif
|