|
|
nono 0.1.6
//
// nono
// Copyright (C) 2021 nono project
// Licensed under nono-license.txt
//
#pragma once
#include "wxheader.h"
// wxBitmap を便利に使うためのクラス。
// wxBitmap を使うためには実体の wxImage とその下のバッファの3つを
// 毎回管理しないといけないが、全部定型文なので。
class WXBitmap
{
public:
WXBitmap();
~WXBitmap();
// ビットマップを(再)構成。
// すでに同じ縦横サイズのビットマップなら何もしない。
void Create(const wxSize& size) {
Create(size.x, size.y);
}
void Create(int width, int height);
// ビットマップが有効なら true を返す
bool Valid() const { return (*bitmap).IsOk(); }
// wxBitmap を取得
wxBitmap& GetBitmap() const { return *(bitmap.get()); }
// 直接評価すると wxBitmap を返す
operator wxBitmap&() const {
return GetBitmap();
}
// サイズを取得
wxSize GetSize() const {
if ((bool)bitmap && (*bitmap).IsOk()) {
return (*bitmap).GetSize();
} else {
return wxSize(0, 0);
}
}
private:
std::unique_ptr<uint8[]> buf {};
std::unique_ptr<wxImage> image {};
std::unique_ptr<wxBitmap> bitmap {};
};
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.