2022-12-04 14:14:07 +00:00
|
|
|
#pragma once
|
|
|
|
#include <luna/Types.h>
|
|
|
|
|
|
|
|
class Bitmap
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Bitmap();
|
|
|
|
Bitmap(void* location, usize size_in_bytes);
|
|
|
|
|
|
|
|
void initialize(void* location, usize size_in_bytes);
|
|
|
|
void* move(void* new_location, usize new_location_size_in_bytes);
|
|
|
|
|
|
|
|
void set(usize index, bool value);
|
2022-12-05 11:50:30 +00:00
|
|
|
bool get(usize index) const;
|
2022-12-04 14:14:07 +00:00
|
|
|
|
|
|
|
// size() returns size in bits! If you want the size in bytes, call size_in_bytes().
|
2022-12-05 11:50:30 +00:00
|
|
|
usize size() const
|
2022-12-04 14:14:07 +00:00
|
|
|
{
|
|
|
|
return m_size_in_bytes * 8;
|
|
|
|
}
|
|
|
|
|
2022-12-05 11:50:30 +00:00
|
|
|
usize size_in_bytes() const
|
2022-12-04 14:14:07 +00:00
|
|
|
{
|
|
|
|
return m_size_in_bytes;
|
|
|
|
}
|
|
|
|
|
2022-12-05 11:50:30 +00:00
|
|
|
void* location() const
|
2022-12-04 14:14:07 +00:00
|
|
|
{
|
|
|
|
return (void*)m_location;
|
|
|
|
}
|
|
|
|
|
2022-12-05 11:50:30 +00:00
|
|
|
bool initialized() const
|
2022-12-04 14:14:07 +00:00
|
|
|
{
|
|
|
|
return m_location;
|
|
|
|
}
|
|
|
|
|
|
|
|
void clear(bool value);
|
|
|
|
void clear_region(usize start, usize bits, bool value);
|
|
|
|
|
|
|
|
private:
|
2022-12-05 11:53:16 +00:00
|
|
|
u8 value_byte(bool b)
|
|
|
|
{
|
|
|
|
return b ? 0xff : 0;
|
|
|
|
}
|
|
|
|
|
2022-12-07 10:47:46 +00:00
|
|
|
u8* m_location = nullptr;
|
2022-12-04 14:14:07 +00:00
|
|
|
usize m_size_in_bytes = 0;
|
2023-01-02 12:07:29 +00:00
|
|
|
};
|