Annotation of nono/wx/wxbitmapbuf.cpp, revision 1.1

1.1     ! root        1: //
        !             2: // nono
        !             3: // Copyright (C) 2021 nono project
        !             4: // Licensed under nono-license.txt
        !             5: //
        !             6: 
        !             7: #include "wxbitmapbuf.h"
        !             8: 
        !             9: // コンストラクタ
        !            10: WXBitmapBuf::WXBitmapBuf()
        !            11: {
        !            12: }
        !            13: 
        !            14: // デストラクタ
        !            15: WXBitmapBuf::~WXBitmapBuf()
        !            16: {
        !            17:        bitmap.reset();
        !            18:        image.reset();
        !            19:        buf.reset();
        !            20: }
        !            21: 
        !            22: // ビットマップ作成
        !            23: void
        !            24: WXBitmapBuf::Create(int width, int height)
        !            25: {
        !            26:        // ビットマップがすでにあってサイズが同じなら何もしない
        !            27:        if ((bool)bitmap && (*bitmap).GetSize() == wxSize(width, height)) {
        !            28:                // XXX 塗り直しくらいはしてもいいかもしれんけど
        !            29:                return;
        !            30:        }
        !            31: 
        !            32:        // 持っていればまず逆順に解放
        !            33:        bitmap.reset();
        !            34:        image.reset();
        !            35: 
        !            36:        // 正しく描かれなかった時に分かりやすいよう初期値は濃いグレーにしておく
        !            37:        int buflen = width * height * 3;
        !            38:        buf.reset(new uint8 [buflen]);
        !            39:        memset(&buf[0], 0x70, buflen);
        !            40:        image.reset(new wxImage(width, height, buf.get(), true));
        !            41:        bitmap.reset(new wxBitmap(*image));
        !            42: }

unix.superglobalmegacorp.com

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