Panda3D
Loading...
Searching...
No Matches
pnmFileTypeEXR.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file pnmFileTypeEXR.h
10 * @author drose
11 * @date 2000-06-17
12 */
13
14#ifndef PNMFILETYPEEXR_H
15#define PNMFILETYPEEXR_H
16
17#include "pandabase.h"
18
19#ifdef HAVE_OPENEXR
20
21#include "pnmFileType.h"
22#include "pnmReader.h"
23#include "pnmWriter.h"
24
25#include <ImfInputFile.h>
26#include <OpenEXRConfig.h>
27
28#ifdef OPENEXR_IMF_NAMESPACE
29namespace IMF = OPENEXR_IMF_NAMESPACE;
30#else
31namespace IMF = Imf;
32#endif
33
34class ImfStdIstream;
35
36/**
37 * For reading and writing EXR floating-point or integer files.
38 */
39class EXPCL_PANDA_PNMIMAGETYPES PNMFileTypeEXR : public PNMFileType {
40public:
41 PNMFileTypeEXR();
42
43 virtual std::string get_name() const;
44
45 virtual int get_num_extensions() const;
46 virtual std::string get_extension(int n) const;
47 virtual std::string get_suggested_extension() const;
48
49 virtual bool has_magic_number() const;
50 virtual bool matches_magic_number(const std::string &magic_number) const;
51
52 virtual PNMReader *make_reader(std::istream *file, bool owns_file = true,
53 const std::string &magic_number = std::string());
54 virtual PNMWriter *make_writer(std::ostream *file, bool owns_file = true);
55
56public:
57 class Reader : public PNMReader {
58 public:
59 Reader(PNMFileType *type, std::istream *file, bool owns_file, std::string magic_number);
60 virtual ~Reader();
61
62 virtual bool is_floating_point();
63 virtual bool read_pfm(PfmFile &pfm);
64 virtual int read_data(xel *array, xelval *alpha);
65
66 private:
67 class ImfStdIstream *_strm;
68 IMF::InputFile _imf_file;
69
70 typedef std::vector<std::string> ChannelNames;
71 ChannelNames _channel_names;
72 };
73
74 class Writer : public PNMWriter {
75 public:
76 Writer(PNMFileType *type, std::ostream *file, bool owns_file);
77
78 virtual bool supports_floating_point();
79 virtual bool supports_integer();
80 virtual bool write_pfm(const PfmFile &pfm);
81 virtual int write_data(xel *array, xelval *alpha);
82 };
83
84private:
85
86 // The TypedWritable interface follows.
87public:
88 static void register_with_read_factory();
89
90protected:
91 static TypedWritable *make_PNMFileTypeEXR(const FactoryParams &params);
92
93public:
94 static TypeHandle get_class_type() {
95 return _type_handle;
96 }
97 static void init_type() {
98 PNMFileType::init_type();
99 register_type(_type_handle, "PNMFileTypeEXR",
100 PNMFileType::get_class_type());
101 }
102 virtual TypeHandle get_type() const {
103 return get_class_type();
104 }
105 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
106
107private:
108 static TypeHandle _type_handle;
109};
110
111#endif // HAVE_OPENEXR
112
113#endif
An instance of this class is passed to the Factory when requesting it to do its business and construc...
This is the base class of a family of classes that represent particular image file types that PNMImag...
Definition pnmFileType.h:32
virtual bool has_magic_number() const
Returns true if this particular file type uses a magic number to identify it, false otherwise.
get_suggested_extension
Returns a suitable filename extension (without a leading dot) to suggest for files of this type,...
Definition pnmFileType.h:49
virtual PNMReader * make_reader(std::istream *file, bool owns_file=true, const std::string &magic_number=std::string())
Allocates and returns a new PNMReader suitable for reading from this file type, if possible.
get_num_extensions
Returns the number of different possible filename extensions associated with this particular file typ...
Definition pnmFileType.h:44
virtual PNMWriter * make_writer(std::ostream *file, bool owns_file=true)
Allocates and returns a new PNMWriter suitable for reading from this file type, if possible.
get_extension
Returns the nth possible filename extension associated with this particular file type,...
Definition pnmFileType.h:44
virtual bool matches_magic_number(const std::string &magic_number) const
Returns true if the indicated "magic number" byte stream (the initial few bytes read from the file) m...
This is an abstract base class that defines the interface for reading image files of various types.
Definition pnmReader.h:27
This is an abstract base class that defines the interface for writing image files of various types.
Definition pnmWriter.h:27
Defines a pfm file, a 2-d table of floating-point numbers, either 3-component or 1-component,...
Definition pfmFile.h:31
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
Base class for objects that can be written to and read from Bam files.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...