1// Aseprite Document Library
2// Copyright (C) 2019 Igara Studio S.A.
3// Copyright (C) 2001-2016 David Capello
4//
5// This file is released under the terms of the MIT license.
6// Read LICENSE.txt for more information.
7
8#ifndef DOC_IMAGE_BUFFER_H_INCLUDED
9#define DOC_IMAGE_BUFFER_H_INCLUDED
10#pragma once
11
12#include "base/ints.h"
13
14#include <cstddef>
15#include <memory>
16#include <vector>
17
18namespace doc {
19
20 class ImageBuffer {
21 public:
22 ImageBuffer(std::size_t size = 1) : m_buffer(size) {
23 }
24
25 std::size_t size() const { return m_buffer.size(); }
26 uint8_t* buffer() { return &m_buffer[0]; }
27
28 void resizeIfNecessary(std::size_t size) {
29 if (size > m_buffer.size())
30 m_buffer.resize(size);
31 }
32
33 private:
34 std::vector<uint8_t> m_buffer;
35 };
36
37 typedef std::shared_ptr<ImageBuffer> ImageBufferPtr;
38
39} // namespace doc
40
41#endif
42