-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFrameBuffer.cpp
More file actions
60 lines (51 loc) · 1.6 KB
/
FrameBuffer.cpp
File metadata and controls
60 lines (51 loc) · 1.6 KB
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
// AUTHOR: Nenad Amodaj, nenad@amodaj.com
//
// COPYRIGHT: 2005 Nenad Amodaj
// 2005-2015 Regents of the University of California
// 2017 Open Imaging, Inc.
//
// LICENSE: This file is free for use, modification and distribution and
// is distributed under terms specified in the BSD license
// This file 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.
//
// IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES.
//
// NOTE: Imported from ADVI for use in Micro-Manager
#include "FrameBuffer.h"
#include <cmath>
#include <cstring>
namespace mmcore {
namespace internal {
FrameBuffer::FrameBuffer(std::size_t size) :
size_(size),
pixels_(new unsigned char[size]())
{
}
const unsigned char* FrameBuffer::GetPixels() const
{
return pixels_.get();
}
void FrameBuffer::SetPixels(const void* pix)
{
memcpy(pixels_.get(), pix, size_);
}
void FrameBuffer::Resize(std::size_t size)
{
if (size != size_)
{
// Deallocate before allocating, since these buffers can be large
pixels_.reset();
pixels_.reset(new unsigned char[size]());
size_ = size;
}
}
void FrameBuffer::SetSerializedMetadata(std::string_view serialized)
{
serializedMetadata_.assign(serialized);
}
} // namespace internal
} // namespace mmcore