mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-01 00:23:35 +00:00
40 lines
803 B
C++
40 lines
803 B
C++
// Aseprite Document Library
|
|
// Copyright (c) 2001-2015 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/shared_ptr.h"
|
|
|
|
#include <vector>
|
|
#include <cstddef>
|
|
|
|
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 base::SharedPtr<ImageBuffer> ImageBufferPtr;
|
|
|
|
} // namespace doc
|
|
|
|
#endif
|