-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bitmap.hpp
50 lines (39 loc) · 1007 Bytes
/
Bitmap.hpp
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
#ifndef __DARKRL__BITMAP_HPP__
#define __DARKRL__BITMAP_HPP__
#include <future>
#include <memory>
#include <mutex>
#include "Semaphore.hpp"
#include "Types.hpp"
#include "Vector.hpp"
enum class Channels
{
RGB,
Alpha
};
class Bitmap
{
public:
Bitmap( const char* fn, uint lines );
Bitmap( const v2i& size );
virtual ~Bitmap();
void Write( const char* fn );
uint32* Data() { if( m_load.valid() ) m_load.wait(); return m_data; }
const uint32* Data() const { if( m_load.valid() ) m_load.wait(); return m_data; }
const v2i& Size() const { return m_size; }
bool Alpha() const { return m_alpha; }
const uint32* NextBlock( uint& lines, bool& done );
protected:
Bitmap( const Bitmap& src, uint lines );
uint32* m_data;
uint32* m_block;
uint m_lines;
uint m_linesLeft;
v2i m_size, m_orgsize;
bool m_alpha;
Semaphore m_sema;
std::mutex m_lock;
std::future<void> m_load;
};
typedef std::shared_ptr<Bitmap> BitmapPtr;
#endif