Colobot
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Pages
src
common
image.h
Go to the documentation of this file.
1
// * This file is part of the COLOBOT source code
2
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
3
// *
4
// * This program is free software: you can redistribute it and/or modify
5
// * it under the terms of the GNU General Public License as published by
6
// * the Free Software Foundation, either version 3 of the License, or
7
// * (at your option) any later version.
8
// *
9
// * This program is distributed in the hope that it will be useful,
10
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
// * GNU General Public License for more details.
13
// *
14
// * You should have received a copy of the GNU General Public License
15
// * along with this program. If not, see http://www.gnu.org/licenses/.
16
22
#pragma once
23
24
25
#include "
graphics/core/color.h
"
26
27
#include "
math/intpoint.h
"
28
29
#include <stddef.h>
30
#include <string>
31
32
33
// Forward declaration without including headers to clutter the code
34
struct
SDL_Surface;
35
37
39
struct
ImageData
40
{
42
SDL_Surface*
surface
;
43
44
ImageData
() {
surface
= NULL; }
45
};
46
54
class
CImage
55
{
56
private
:
58
CImage
(
const
CImage
&other) {}
60
void
operator=(
const
CImage
&other) {}
61
62
public
:
64
CImage
();
66
CImage
(
Math::IntPoint
size);
68
virtual
~CImage
();
69
71
void
Free
();
72
74
bool
IsEmpty
()
const
;
75
77
ImageData
*
GetData
();
78
80
Math::IntPoint
GetSize
()
const
;
81
83
void
Fill
(
Gfx::IntColor
color);
84
86
void
SetPixel
(
Math::IntPoint
pixel,
Gfx::Color
color);
87
89
void
SetPixelInt
(
Math::IntPoint
pixel,
Gfx::IntColor
color);
90
92
Gfx::Color
GetPixel
(
Math::IntPoint
pixel);
93
95
Gfx::IntColor
GetPixelInt
(
Math::IntPoint
pixel);
96
98
void
PadToNearestPowerOfTwo
();
99
101
void
ConvertToRGBA
();
102
104
bool
Load
(
const
std::string &fileName);
105
107
bool
SavePNG
(
const
std::string &fileName);
108
110
std::string
GetError
();
111
113
void
flipVertically
();
114
116
void
SetDataPixels
(
void
*pixels);
117
118
private
:
120
void
BlitToNewRGBASurface(
int
width,
int
height);
121
123
std::string m_error;
125
ImageData
* m_data;
126
};
127
Generated on Sat Jul 5 2014 09:25:02 for Colobot by
1.8.1.2