-
Notifications
You must be signed in to change notification settings - Fork 3
/
bmp_array_example_main.cpp
54 lines (46 loc) · 1.53 KB
/
bmp_array_example_main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <nana/gui.hpp>
#include <nana/gui/widgets/button.hpp>
#include <nana/gui/widgets/label.hpp>
#include <nana/paint/image.hpp>
#include <nana/gui/widgets/picture.hpp>
#include <nana/gui/filebox.hpp>
#include <fstream>
#include "bmp_array_example.hpp"
int main()
{
using namespace nana;
using namespace std;
form fm{API::make_center(1024, 768), appear::decorate<appear::minimize, appear::maximize, appear::sizable>()};
fm.div("vert <text> < weight=283 <> <pic weight=283> <> > <weight=20> < weight=30 <> <btn weight=283> <> > <>");
fm.bgcolor(color{"#fbf9f5"});
label text{fm};
text.caption("<size=16 green>If all went well and the image loaded, you should see a cat below, or a green square otherwise.</>");
text.text_align(align::center, align_v::center);
text.format(true);
paint::image img;
img.open(arr_cat_283x283_bmp, sizeof arr_cat_283x283_bmp);
picture pic{fm};
pic.load(img);
pic.bgcolor(colors::light_green);
button btn{fm, "Save array to bmp file"};
btn.bgcolor(colors::white);
btn.events().click([&]
{
filebox fb{fm, false};
fb.title("Choose which bmp file you want to save the array to");
fb.init_file("cat_283x283");
fb.add_filter("Windows Bitmap (.bmp)", "*.bmp");
auto res = fb.show();
if(!res.empty())
{
ofstream file{res.front(), ios::binary};
file.write(reinterpret_cast<const char*>(arr_cat_283x283_bmp), sizeof arr_cat_283x283_bmp);
}
});
fm["text"] << text;
fm["pic"] << pic;
fm["btn"] << btn;
fm.collocate();
fm.show();
exec();
}