vsgXchange: include/vsgXchange/images.h Source File

vsgXchange 1.1.9 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 // vsg::Options::setValue(str, value) supported options:
79 static constexpr const char* image_format = "image_format";
80
81 bool readOptions(vsg::Options& options, vsg::CommandLine& arguments) const override;
82
83 private:
84 std::set<vsg::Path> _supportedExtensions;
85 };
86
88 class VSGXCHANGE_DECLSPEC ktx : public vsg::Inherit<vsg::ReaderWriter, ktx>
89 {
90 public:
91 ktx();
92
93 vsg::ref_ptr<vsg::Object> read(const vsg::Path& filename, vsg::ref_ptr<const vsg::Options> options = {}) const override;
94 vsg::ref_ptr<vsg::Object> read(std::istream& fin, vsg::ref_ptr<const vsg::Options> options = {}) const override;
95 vsg::ref_ptr<vsg::Object> read(const uint8_t* ptr, size_t size, vsg::ref_ptr<const vsg::Options> options = {}) const override;
96
97 bool getFeatures(Features& features) const override;
98
99 private:
100 ~ktx();
101
102 class Implementation;
103 Implementation* _implementation;
104 };
105
107 class openexr : public vsg::Inherit<vsg::ReaderWriter, openexr>
108 {
109 public:
110 openexr();
111
112 vsg::ref_ptr<vsg::Object> read(const vsg::Path& filename, vsg::ref_ptr<const vsg::Options> options = {}) const override;
113 vsg::ref_ptr<vsg::Object> read(std::istream& fin, vsg::ref_ptr<const vsg::Options> options = {}) const override;
114 vsg::ref_ptr<vsg::Object> read(const uint8_t* ptr, size_t size, vsg::ref_ptr<const vsg::Options> options = {}) const override;
115
116 bool write(const vsg::Object* object, const vsg::Path& filename, vsg::ref_ptr<const vsg::Options> = {}) const override;
117 bool write(const vsg::Object* object, std::ostream& fout, vsg::ref_ptr<const vsg::Options> = {}) const override;
118
119 bool getFeatures(Features& features) const override;
120
121 private:
122 std::set<vsg::Path> _supportedExtensions;
123 };
124
125} // namespace vsgXchange
126
127EVSG_type_name(vsgXchange::images);
128EVSG_type_name(vsgXchange::stbi);
129EVSG_type_name(vsgXchange::dds);
130EVSG_type_name(vsgXchange::ktx);
131EVSG_type_name(vsgXchange::openexr);
vsgXchange::dds
add dds support using local build of tinydds.
Definition images.h:68
vsgXchange::dds::readOptions
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 (...
vsgXchange::images
Definition images.h:37
vsgXchange::ktx
add ktx using using local build of libktx
Definition images.h:89
vsgXchange::openexr
optional .exr support using OpenEXR library
Definition images.h:108
vsgXchange::stbi
add png, jpeg and gif support using local build of stbi.
Definition images.h:44
vsgXchange::stbi::image_format
static constexpr const char * image_format
set the int quality value when writing out to image as jpeg file.
Definition images.h:58
vsgXchange::stbi::readOptions
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 (...