vsgXchange 1.1.6
VulkanSceneGraph 3rd party data integration library
 
Loading...
Searching...
No Matches
images.h
1#pragma once
2
3/* <editor-fold desc="MIT License">
4
5Copyright(c) 2021 Robert Osfield
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of
8this software and associated documentation files (the "Software"), to deal in
9the Software without restriction, including without limitation the rights to
10use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11the Software, and to permit persons to whom the Software is furnished to do so,
12subject to the following conditions:
13
14The above copyright notice and this permission notice shimages be included in images
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
24</editor-fold> */
25
26#include <vsg/io/ReaderWriter.h>
27#include <vsgXchange/Version.h>
28
29#include <memory>
30#include <unordered_set>
31
32namespace vsgXchange
33{
36 class VSGXCHANGE_DECLSPEC images : public vsg::Inherit<vsg::CompositeReaderWriter, images>
37 {
38 public:
39 images();
40 };
41
43 class VSGXCHANGE_DECLSPEC stbi : public vsg::Inherit<vsg::ReaderWriter, stbi>
44 {
45 public:
46 stbi();
47
48 vsg::ref_ptr<vsg::Object> read(const vsg::Path& filename, vsg::ref_ptr<const vsg::Options> options = {}) const override;
49 vsg::ref_ptr<vsg::Object> read(std::istream& fin, vsg::ref_ptr<const vsg::Options> options = {}) const override;
50 vsg::ref_ptr<vsg::Object> read(const uint8_t* ptr, size_t size, vsg::ref_ptr<const vsg::Options> options = {}) const override;
51 bool write(const vsg::Object* object, const vsg::Path& filename, vsg::ref_ptr<const vsg::Options> = {}) const override;
52 bool write(const vsg::Object* object, std::ostream& stream, vsg::ref_ptr<const vsg::Options> = {}) const override;
53
54 bool getFeatures(Features& features) const override;
55
56 // vsg::Options::setValue(str, value) supported options:
57 static constexpr const char* jpeg_quality = "jpeg_quality";
58 static constexpr const char* image_format = "image_format";
59
60 bool readOptions(vsg::Options& options, vsg::CommandLine& arguments) const override;
61
62 private:
63 std::set<vsg::Path> _supportedExtensions;
64 };
65
67 class VSGXCHANGE_DECLSPEC dds : public vsg::Inherit<vsg::ReaderWriter, dds>
68 {
69 public:
70 dds();
71
72 vsg::ref_ptr<vsg::Object> read(const vsg::Path& filename, vsg::ref_ptr<const vsg::Options> options = {}) const override;
73 vsg::ref_ptr<vsg::Object> read(std::istream& fin, vsg::ref_ptr<const vsg::Options> options = {}) const override;
74 vsg::ref_ptr<vsg::Object> read(const uint8_t* ptr, size_t size, vsg::ref_ptr<const vsg::Options> options = {}) const override;
75
76 bool getFeatures(Features& features) const override;
77
78 private:
79 std::set<vsg::Path> _supportedExtensions;
80 };
81
83 class VSGXCHANGE_DECLSPEC ktx : public vsg::Inherit<vsg::ReaderWriter, ktx>
84 {
85 public:
86 ktx();
87
88 vsg::ref_ptr<vsg::Object> read(const vsg::Path& filename, vsg::ref_ptr<const vsg::Options> options = {}) const override;
89 vsg::ref_ptr<vsg::Object> read(std::istream& fin, vsg::ref_ptr<const vsg::Options> options = {}) const override;
90 vsg::ref_ptr<vsg::Object> read(const uint8_t* ptr, size_t size, vsg::ref_ptr<const vsg::Options> options = {}) const override;
91
92 bool getFeatures(Features& features) const override;
93
94 private:
95 std::set<vsg::Path> _supportedExtensions;
96 };
97
99 class openexr : public vsg::Inherit<vsg::ReaderWriter, openexr>
100 {
101 public:
102 openexr();
103
104 vsg::ref_ptr<vsg::Object> read(const vsg::Path& filename, vsg::ref_ptr<const vsg::Options> options = {}) const override;
105 vsg::ref_ptr<vsg::Object> read(std::istream& fin, vsg::ref_ptr<const vsg::Options> options = {}) const override;
106 vsg::ref_ptr<vsg::Object> read(const uint8_t* ptr, size_t size, vsg::ref_ptr<const vsg::Options> options = {}) const override;
107
108 bool write(const vsg::Object* object, const vsg::Path& filename, vsg::ref_ptr<const vsg::Options> = {}) const override;
109 bool write(const vsg::Object* object, std::ostream& fout, vsg::ref_ptr<const vsg::Options> = {}) const override;
110
111 bool getFeatures(Features& features) const override;
112
113 private:
114 std::set<vsg::Path> _supportedExtensions;
115 };
116
117} // namespace vsgXchange
118
119EVSG_type_name(vsgXchange::images);
120EVSG_type_name(vsgXchange::stbi);
121EVSG_type_name(vsgXchange::dds);
122EVSG_type_name(vsgXchange::ktx);
123EVSG_type_name(vsgXchange::openexr);
add dds support using local build of tinydds.
Definition images.h:68
Definition images.h:37
add ktx using using local build of libktx
Definition images.h:84
optional .exr support using OpenEXR library
Definition images.h:100
add png, jpeg and gif support using local build of stbi.
Definition images.h:44
static constexpr const char * image_format
set the int quality value when writing out to image as jpeg file.
Definition images.h:58
bool readOptions(vsg::Options &options, vsg::CommandLine &arguments) const override
Override read image format (8bit RGB/RGBA default to sRGB) to be specified class of CoordinateSpace (...