30 image(
const int width,
const int height,
const bool init =
true);
36 void init(
const T &val);
39 image<T> *copy()
const;
42 int width()
const {
return w; }
45 int height()
const {
return h; }
58 #define imRef(im, x, y) (im->access[y][x])
61 #define imPtr(im, x, y) &(im->access[y][x])
64 image<T>::image(
const int width,
const int height,
const bool init) {
71 for (
int i = 0; i < h; i++)
72 access[i] = data + (i * w);
75 memset(data, 0, w * h *
sizeof(T));
85 void image<T>::init(
const T &val) {
86 T *ptr = imPtr(
this, 0, 0);
87 T *end = imPtr(
this, w-1, h-1);
94 image<T> *image<T>::copy()
const {
95 image<T> *im =
new image<T>(w, h,
false);
96 memcpy(im->data, data, w * h *
sizeof(T));