File:  [Isaki's NoNo m68k/m88k emulator] / nono / wx / wxbitmapbuf.h
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed Apr 29 17:04:56 2026 UTC (2 months, 3 weeks ago) by root
Branches: MAIN, Isaki
CVS tags: v014, v013, v012, v011, HEAD
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 {};
};

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.