forked from aseprite/aseprite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
image_buffer.h
41 lines (30 loc) · 857 Bytes
/
image_buffer.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
// Aseprite Document Library
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2016 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#ifndef DOC_IMAGE_BUFFER_H_INCLUDED
#define DOC_IMAGE_BUFFER_H_INCLUDED
#pragma once
#include "base/ints.h"
#include <cstddef>
#include <memory>
#include <vector>
namespace doc {
class ImageBuffer {
public:
ImageBuffer(std::size_t size = 1) : m_buffer(size) {
}
std::size_t size() const { return m_buffer.size(); }
uint8_t* buffer() { return &m_buffer[0]; }
void resizeIfNecessary(std::size_t size) {
if (size > m_buffer.size())
m_buffer.resize(size);
}
private:
std::vector<uint8_t> m_buffer;
};
typedef std::shared_ptr<ImageBuffer> ImageBufferPtr;
} // namespace doc
#endif