-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathImage.h
68 lines (55 loc) · 1.71 KB
/
Image.h
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
// Copyright 2014 Isis Innovation Limited and the authors of InfiniTAM
#pragma once
#include "MemoryBlock.h"
#ifndef __METALC__
namespace ORUtils
{
/** \brief
Represents images, templated on the pixel type
*/
template <typename T>
class Image : public MemoryBlock < T >
{
public:
/** Size of the image in pixels. */
Vector2<int> noDims;
/** Initialize an empty image of the given size, either
on CPU only or on both CPU and GPU.
*/
Image(Vector2<int> noDims, bool allocate_CPU, bool allocate_CUDA, bool metalCompatible = true)
: MemoryBlock<T>(noDims.x * noDims.y, allocate_CPU, allocate_CUDA, metalCompatible)
{
this->noDims = noDims;
}
Image(bool allocate_CPU, bool allocate_CUDA, bool metalCompatible = true)
: MemoryBlock<T>(1, allocate_CPU, allocate_CUDA, metalCompatible)
{
this->noDims = Vector2<int>(1, 1); //TODO - make nicer
}
Image(Vector2<int> noDims, MemoryDeviceType memoryType)
: MemoryBlock<T>(noDims.x * noDims.y, memoryType)
{
this->noDims = noDims;
}
/** Resize an image, loosing all old image data.
Essentially any previously allocated data is
released, new memory is allocated.
*/
void ChangeDims(Vector2<int> newDims)
{
if (newDims != noDims)
{
this->noDims = newDims;
bool allocate_CPU = this->isAllocated_CPU;
bool allocate_CUDA = this->isAllocated_CUDA;
bool metalCompatible = this->isMetalCompatible;
this->Free();
this->Allocate(newDims.x * newDims.y, allocate_CPU, allocate_CUDA, metalCompatible);
}
}
// Suppress the default copy constructor and assignment operator
Image(const Image&);
Image& operator=(const Image&);
};
}
#endif