![Logo](alamo3.svg) |
Alamo
|
Go to the documentation of this file.
21 if ((f = fopen(
filename.c_str(),
"rb")))
23 unsigned char info[54];
24 retcode = fread(info,
sizeof(
unsigned char), 54, f);
25 if (retcode != 54)
Util::Abort(
INFO,
"Error reading BMP file: 54 bytes expected but only ", retcode,
" read.");
26 nx = *(
int*)&info[18];
27 ny = *(
int*)&info[22];
31 int row_padded = (
nx*3 + 3) & (~3);
32 unsigned char*
data =
new unsigned char[row_padded];
33 for (
int j = 0; j <
ny; j++)
35 retcode = fread(
data,
sizeof(
unsigned char), row_padded, f);
36 if (retcode != row_padded)
Util::Abort(
INFO,
"Error reading BMP file: ",row_padded,
" bytes expected but only ", retcode,
" read.");
37 for(
int i = 0; i <
nx*3; i += 3)
39 (*this)(i/3,j)[0] = (
int)
data[i+2];
40 (*this)(i/3,j)[1] = (
int)
data[i+1];
41 (*this)(i/3,j)[2] = (
int)
data[i];
59 std::array<int,3>
min()
61 std::array<int,3> _min = {std::numeric_limits<int>::max(), std::numeric_limits<int>::max(), std::numeric_limits<int>::max()};
62 for (
unsigned int i = 0; i <
data.size(); i++)
64 if (_min[0] >
data[i][0]) _min[0] =
data[i][0];
65 if (_min[1] >
data[i][1]) _min[1] =
data[i][1];
66 if (_min[2] >
data[i][2]) _min[2] =
data[i][2];
70 std::array<int,3>
max()
72 std::array<int,3> _max = {0, 0, 0};
73 for (
unsigned int i = 0; i <
data.size(); i++)
75 if (_max[0] <
data[i][0]) _max[0] =
data[i][0];
76 if (_max[1] <
data[i][1]) _max[1] =
data[i][1];
77 if (_max[2] <
data[i][2]) _max[2] =
data[i][2];
85 std::vector<std::array<int,3>>
data;
A collection of utility routines.
AMREX_FORCE_INLINE void Assert(std::string file, std::string func, int line, std::string smt, bool pass, Args const &... args)
std::array< int, 3 > min()
void Abort(const char *msg)
AMREX_FORCE_INLINE std::array< int, 3 > & operator()(int i, int j)
std::array< int, 3 > max()
void Define(std::string filename)
std::vector< std::array< int, 3 > > data