-
-
Notifications
You must be signed in to change notification settings - Fork 82
/
Copy pathFilePNG.hpp
80 lines (56 loc) · 3.56 KB
/
FilePNG.hpp
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*#######################################################################################
Copyright (c) 2017-2019 Kasugaccho
Copyright (c) 2018-2019 As Project
https://github.com/Kasugaccho/DungeonTemplateLibrary
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#######################################################################################*/
#ifndef INCLUDED_DUNGEON_TEMPLATE_LIBRARY_DTL_STORAGE_FILE_PNG_HPP
#define INCLUDED_DUNGEON_TEMPLATE_LIBRARY_DTL_STORAGE_FILE_PNG_HPP
/*#######################################################################################
日本語リファレンス (Reference-JP)
https://github.com/Kasugaccho/DungeonTemplateLibrary/wiki/dtl::storage::FilePNG-(ストレージクラス)/
#######################################################################################*/
#include <DTL/Base/Struct.hpp>
#include <DTL/Storage/FileBaseBin.hpp>
#include <DTL/Type/SizeT.hpp>
#include <DTL/Type/UniquePtr.hpp>
#ifndef STB_IMAGE_WRITE_IMPLEMENTATION
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include <DTL/ThirdParty/STB/stb_image_write.h>
#endif
/*#######################################################################################
[概要] "dtl名前空間"とは"DungeonTemplateLibrary"の全ての機能が含まれる名前空間である。
[Summary] The "dtl" is a namespace that contains all the functions of "DungeonTemplateLibrary".
#######################################################################################*/
namespace dtl {
inline namespace storage { //"dtl::storage"名前空間に属する
/*#######################################################################################
[概要] FilePNGとは "PNG形式の画像ファイルを出力する" 機能を持つクラスである。
#######################################################################################*/
template<typename Matrix_Var_, typename UniquePtr_ = DTL_TYPE_UNIQUE_PTR<unsigned char[]>>
class FilePNG : public ::dtl::storage::FileBaseBin<FilePNG<Matrix_Var_, UniquePtr_>, Matrix_Var_, UniquePtr_> {
///// エイリアス (Alias) /////
using Index_Size = ::dtl::type::size;
using FileBase_t = ::dtl::storage::FileBaseBin<FilePNG, Matrix_Var_, UniquePtr_>;
friend FileBase_t;
///// メンバ変数 (Member Variable) /////
int stride_in_bytes{};
///// 基本処理 /////
int writeFile(char const* filename, int width, int height, int color_num, const void* data) const {
return ::stbi_write_png(filename, width, height, color_num, data, this->stride_in_bytes);
}
public:
///// コンストラクタ (Constructor) /////
using FileBase_t::FileBase_t;
constexpr FilePNG(const ::std::string& write_value_, const ::dtl::type::size color_num_, const int stride_in_bytes_)
:FileBase_t(write_value_, color_num_), stride_in_bytes(stride_in_bytes_) {}
constexpr FilePNG(const ::dtl::base::MatrixRange& matrix_range_, const ::std::string& write_value_, const ::dtl::type::size color_num_, const int stride_in_bytes_)
:FileBase_t(matrix_range_, write_value_, color_num_), stride_in_bytes(stride_in_bytes_) {}
constexpr FilePNG(const Index_Size end_x_, const Index_Size end_y_, const Index_Size width_, const Index_Size height_, const ::std::string& write_value_, const ::dtl::type::size color_num_, const int stride_in_bytes_)
:FileBase_t(end_x_, end_y_, width_, height_, write_value_, color_num_), stride_in_bytes(stride_in_bytes_) {}
};
}
}
#endif //Included Dungeon Template Library