-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathimage_data.cc
121 lines (108 loc) · 2.8 KB
/
image_data.cc
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
/*
* Copyright ViewTouch, Inc., 1995, 1996, 1997, 1998
* 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 3 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, see <http://www.gnu.org/licenses/>.
*
* image_data.cc - revision 25 (9/7/98)
* implementation of image_data module
*/
#include "basic.hh"
#include "image_data.hh"
#include <cassert>
#include <sstream>
#ifdef DMALLOC
#include <dmalloc.h>
#endif
/**** Textures ****/
#include "xpm/darksand-6.xpm"
#include "xpm/darkwood-10.xpm"
#include "xpm/grayparchment-8.xpm"
#include "xpm/graymarble-12.xpm"
#include "xpm/greenmarble-12.xpm"
#include "xpm/litewood-8.xpm"
#include "xpm/litsand-6.xpm"
#include "xpm/sand-8.xpm"
#include "xpm/wood-10.xpm"
#include "xpm/canvas-8.xpm"
#include "xpm/pearl-8.xpm"
#include "xpm/parchment-6.xpm"
#include "xpm/tanparchment-8.xpm"
#include "xpm/smoke-4.xpm"
#include "xpm/leather-8.xpm"
#include "xpm/gradient-8.xpm"
#include "xpm/black.xpm"
#include "xpm/gradient-brown.xpm"
#include "xpm/blueparchment.xpm"
#include "xpm/greySand.xpm"
#include "xpm/whiteMesh.xpm"
/**** Image Values ****/
constexpr std::array<const char**, IMAGE_COUNT> ImageData = {
SandData,
LitSandData,
DarkSandData,
LiteWoodData,
WoodData,
DarkWoodData,
GrayParchmentData,
GrayMarbleData,
GreenMarbleData,
ParchmentData,
PearlData,
CanvasData,
TanParchmentData,
smokeData,
LeatherData,
BlueParchementData,
gradient_8_xpm,
gradient_brown_xpm,
black_xpm,
greySand,
whiteMesh
};
/**** Functions ****/
int ImageColorsUsed()
{
int colors = 0;
int tmp;
int c;
for (size_t image = 0; image < IMAGE_COUNT; ++image)
{
std::istringstream ss(ImageData[image][0]);
ss >> tmp >> tmp >> c;
if (ss.fail())
assert(false);
colors += c;
}
return colors;
}
int ImageWidth(const size_t image)
{
assert(image < IMAGE_COUNT);
int width = 0;
std::istringstream ss(ImageData[image][0]);
ss >> width;
if (ss.fail())
assert(false);
return width;
}
int ImageHeight(const size_t image)
{
assert(image < IMAGE_COUNT);
int height = 0;
int tmp;
std::istringstream ss(ImageData[image][0]);
ss >> tmp >> height;
if (ss.fail())
assert(false);
return height;
}