blob: be39f7e0444809a03979bc5238f9882b0603e312 (
plain)
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
|
#include "Base.h"
#include <cru/base/io/CFileStream.h>
#include <cru/platform/bootstrap/GraphicsBootstrap.h>
#include <cru/platform/graphics/Factory.h>
#include <cru/platform/graphics/Image.h>
#include <cru/platform/graphics/ImageFactory.h>
CruPlatformGraphicsDemo::CruPlatformGraphicsDemo(std::string file_name,
int width, int height)
: file_name_(std::move(file_name)) {
factory_.reset(cru::platform::bootstrap::CreateGraphicsFactory());
image_ = factory_->GetImageFactory()->CreateBitmap(width, height);
painter_ = image_->CreatePainter();
}
CruPlatformGraphicsDemo::~CruPlatformGraphicsDemo() {
painter_->EndDraw();
cru::io::CFileStream file_stream(file_name_.c_str(), "wb");
factory_->GetImageFactory()->EncodeToStream(
image_.get(), &file_stream, cru::platform::graphics::ImageFormat::Png,
1.0f);
}
cru::platform::graphics::IGraphicsFactory*
CruPlatformGraphicsDemo::GetFactory() {
return factory_.get();
}
cru::platform::graphics::IImage* CruPlatformGraphicsDemo::GetImage() {
return image_.get();
}
cru::platform::graphics::IPainter* CruPlatformGraphicsDemo::GetPainter() {
return painter_.get();
}
|