|
|
nono 0.2.0
//
// nono
// Copyright (C) 2021 nono project
// Licensed under nono-license.txt
//
#pragma once
#include "wxnono.h"
// バッファ付き wxBitmap クラス。
// wxBitmap を使うためには実体の wxImage とその下のバッファの2つも必要で
// このうちバッファを自前で持つ場合の定型処理を担当する。
class WXBitmapBuf
{
public:
WXBitmapBuf();
~WXBitmapBuf();
// ビットマップを(再)構成。
// すでに同じ縦横サイズのビットマップなら何もしない。
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.