-
Notifications
You must be signed in to change notification settings - Fork 0
/
flimage.cpp
executable file
·86 lines (62 loc) · 1.67 KB
/
flimage.cpp
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
// Authors: Unknown. Please, if you are the author of this file, or if you
// know who are the authors of this file, let us know, so we can give the
// adequate credits and/or get the adequate authorizations.
#include "flimage.h"
//////////////////////////////////////////////// Class flimage
//// Construction
flimage::flimage() : width(0), height(0), p(0)
{
}
flimage::flimage(int w, int h) : width(w), height(h), p(new float[w*h])
{
for (int j=width*height-1; j>=0 ; j--) p[j] = 0.0;
}
flimage::flimage(int w, int h, float v) : width(w), height(h), p(new float[w*h])
{
for (int j=width*height-1; j>=0 ; j--) p[j] = v;
}
flimage::flimage(int w, int h, float* v) : width(w), height(h), p(new float[w*h])
{
for (int j=width*height-1; j>=0 ; j--) p[j] = v[j];
}
void flimage::create(int w, int h)
{
erase();
width = w; height = h;
p = new float[w*h];
for (int j=width*height-1; j>=0 ; j--) p[j] = 0.0;
}
void flimage::create(int w, int h, float* v)
{
erase();
width = w; height = h; p = new float[w*h];
for (int j=width*height-1; j>=0 ; j--) p[j] = v[j];
}
flimage::flimage(const flimage& im) : width(im.width), height(im.height), p(new float[im.width*im.height])
{
for (int j=width*height-1; j>=0 ; j--) p[j] = im.p[j];
}
flimage& flimage::operator= (const flimage& im)
{
if (&im == this) {
return *this;
}
if (width != im.width || height != im.height)
{
erase();
width = im.width; height=im.height; p = new float[width*height];
}
for (int j=width*height-1; j>=0 ; j--) p[j] = im.p[j];
return *this;
}
//// Destruction
void flimage::erase()
{
width = height = 0;
if (p) delete[] p;
p=0;
}
flimage::~flimage()
{
erase();
}