2014-10-21 01:21:31 +00:00
|
|
|
// Aseprite Document Library
|
2015-03-05 00:35:11 +00:00
|
|
|
// Copyright (c) 2001-2015 David Capello
|
2014-10-21 01:21:31 +00:00
|
|
|
//
|
|
|
|
// 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/shared_ptr.h"
|
|
|
|
|
|
|
|
#include <vector>
|
2015-03-05 00:35:11 +00:00
|
|
|
#include <cstddef>
|
2014-10-21 01:21:31 +00:00
|
|
|
|
|
|
|
namespace doc {
|
|
|
|
|
|
|
|
class ImageBuffer {
|
|
|
|
public:
|
2015-03-05 00:35:11 +00:00
|
|
|
ImageBuffer(std::size_t size = 1) : m_buffer(size) {
|
2014-10-21 01:21:31 +00:00
|
|
|
}
|
|
|
|
|
2015-03-05 00:35:11 +00:00
|
|
|
std::size_t size() const { return m_buffer.size(); }
|
2014-10-21 01:21:31 +00:00
|
|
|
uint8_t* buffer() { return &m_buffer[0]; }
|
|
|
|
|
2015-03-05 00:35:11 +00:00
|
|
|
void resizeIfNecessary(std::size_t size) {
|
2014-10-21 01:21:31 +00:00
|
|
|
if (size > m_buffer.size())
|
|
|
|
m_buffer.resize(size);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<uint8_t> m_buffer;
|
|
|
|
};
|
|
|
|
|
2015-04-01 15:35:18 +00:00
|
|
|
typedef base::SharedPtr<ImageBuffer> ImageBufferPtr;
|
2014-10-21 01:21:31 +00:00
|
|
|
|
|
|
|
} // namespace doc
|
|
|
|
|
|
|
|
#endif
|