|
|
1.1 ! root 1: // ! 2: // nono ! 3: // Copyright (C) 2021 nono project ! 4: // Licensed under nono-license.txt ! 5: // ! 6: ! 7: #pragma once ! 8: ! 9: #include "wxnono.h" ! 10: ! 11: // バッファ付き wxBitmap クラス。 ! 12: // wxBitmap を使うためには実体の wxImage とその下のバッファの2つも必要で ! 13: // このうちバッファを自前で持つ場合の定型処理を担当する。 ! 14: class WXBitmapBuf ! 15: { ! 16: public: ! 17: WXBitmapBuf(); ! 18: ~WXBitmapBuf(); ! 19: ! 20: // ビットマップを(再)構成。 ! 21: // すでに同じ縦横サイズのビットマップなら何もしない。 ! 22: void Create(const wxSize& size) { ! 23: Create(size.x, size.y); ! 24: } ! 25: void Create(int width, int height); ! 26: ! 27: // ビットマップが有効なら true を返す ! 28: bool Valid() const { return (*bitmap).IsOk(); } ! 29: ! 30: // wxBitmap を取得 ! 31: wxBitmap& GetBitmap() const { return *(bitmap.get()); } ! 32: ! 33: // 直接評価すると wxBitmap を返す ! 34: operator wxBitmap&() const { ! 35: return GetBitmap(); ! 36: } ! 37: ! 38: // サイズを取得 ! 39: wxSize GetSize() const { ! 40: if ((bool)bitmap && (*bitmap).IsOk()) { ! 41: return (*bitmap).GetSize(); ! 42: } else { ! 43: return wxSize(0, 0); ! 44: } ! 45: } ! 46: ! 47: private: ! 48: std::unique_ptr<uint8[]> buf {}; ! 49: std::unique_ptr<wxImage> image {}; ! 50: std::unique_ptr<wxBitmap> bitmap {}; ! 51: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.