Visualization Library 2.1.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
ioTIFF.hpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2020, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
32 #if !defined(ioTIFF_INCLUDE_ONCE)
33 #define ioTIFF_INCLUDE_ONCE
34 
37 #include <vlCore/Image.hpp>
38 
39 namespace vl
40 {
41  class VirtualFile;
42  class String;
43  class Image;
44 
45  VLCORE_EXPORT ref<Image> loadTIFF(VirtualFile* file);
46  VLCORE_EXPORT ref<Image> loadTIFF(const String& path);
47  VLCORE_EXPORT bool isTIFF(VirtualFile* file);
48  VLCORE_EXPORT bool saveTIFF(const Image* src, const String& path);
49  VLCORE_EXPORT bool saveTIFF(const Image* src, VirtualFile* file);
50 
51  //---------------------------------------------------------------------------
52  // LoadWriterTIFF
53  //---------------------------------------------------------------------------
58  {
60  public:
61 
62  LoadWriterTIFF(): ResourceLoadWriter("|tif|tiff|", "|tif|tiff|")
63  {
64  VL_DEBUG_SET_OBJECT_NAME()
65  }
66 
68  {
70  ref<Image> img = loadTIFF(path);
71  if (img)
72  res_db->resources().push_back(img);
73  return res_db;
74  }
75 
77  {
79  ref<Image> img = loadTIFF(file);
80  if (img)
81  res_db->resources().push_back(img);
82  return res_db;
83  }
84 
85  bool writeResource(const String& path, ResourceDatabase* resource) const
86  {
87  bool ok = true;
88  for(unsigned i=0; i<resource->count<Image>(); ++i)
89  ok &= saveTIFF(resource->get<Image>(i), path);
90  return ok;
91  }
92 
93  bool writeResource(VirtualFile* file, ResourceDatabase* resource) const
94  {
95  bool ok = true;
96  for(unsigned i=0; i<resource->count<Image>(); ++i)
97  ok &= saveTIFF(resource->get<Image>(i), file);
98  return ok;
99  }
100  };
101 }
102 
103 #endif
An abstract class representing a file.
Definition: VirtualFile.hpp:60
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
Definition: String.hpp:62
ref< ResourceDatabase > loadResource(VirtualFile *file) const
Definition: ioTIFF.hpp:76
bool writeResource(const String &path, ResourceDatabase *resource) const
Definition: ioTIFF.hpp:85
VLCORE_EXPORT bool saveTIFF(const Image *src, const String &path)
Definition: ioTIFF.cpp:194
size_t count() const
Don&#39;t use inside loops! Counts the number object of the specified type.
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
Definition: TypeInfo.hpp:122
VLCORE_EXPORT ref< Image > loadTIFF(VirtualFile *file)
Definition: ioTIFF.cpp:121
Visualization Library main namespace.
ref< ResourceDatabase > loadResource(const String &path) const
Definition: ioTIFF.hpp:67
void get(std::vector< ref< T > > &resources, bool clear_vector=true)
Returns all the objects of the specified type in the given vector.
The LoadWriterTIFF class is a ResourceLoadWriter capable of reading TIFF files.
Definition: ioTIFF.hpp:57
bool writeResource(VirtualFile *file, ResourceDatabase *resource) const
Definition: ioTIFF.hpp:93
Implements a generic 1d, 2d, 3d and cubemap image that can have mipmaps.
Definition: Image.hpp:54
The ref<> class is used to reference-count an Object.
Definition: Object.hpp:55
The ResourceLoadWriter class is an abstract class used to implement read/write support for one or mor...
VLCORE_EXPORT bool isTIFF(VirtualFile *file)
Definition: ioTIFF.cpp:168
The ResourceDatabase class contains and manipulates a set of resources.