Panda3D
pnmWriter.h
1 // Filename: pnmWriter.h
2 // Created by: drose (14Jun00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef PNMWRITER_H
16 #define PNMWRITER_H
17 
18 #include "pandabase.h"
19 
20 #include "pnmImageHeader.h"
21 class PfmFile;
22 
23 ////////////////////////////////////////////////////////////////////
24 // Class : PNMWriter
25 // Description : This is an abstract base class that defines the
26 // interface for writing image files of various types.
27 // Any particular image file type that can be written
28 // must define a class that inherits from PNMWriter to
29 // write it.
30 ////////////////////////////////////////////////////////////////////
31 class EXPCL_PANDA_PNMIMAGE PNMWriter : public PNMImageHeader {
32 protected:
33  INLINE PNMWriter(PNMFileType *type, ostream *file, bool owns_file);
34 
35 public:
36 
37  // It is important to delete the PNMWriter class after successfully
38  // writing the data. Failing to do this may result in some data not
39  // getting flushed!
40  virtual ~PNMWriter();
41 
42  INLINE PNMFileType *get_type() const;
43 
44  INLINE void set_color_type(ColorType type);
45  INLINE void set_num_channels(int num_channels);
46  INLINE void set_maxval(xelval maxval);
47  INLINE void set_x_size(int x_size);
48  INLINE void set_y_size(int y_size);
49 
50  INLINE void copy_header_from(const PNMImageHeader &header);
51 
52  virtual bool supports_floating_point();
53  virtual bool supports_integer();
54  virtual bool write_pfm(const PfmFile &pfm);
55 
56  virtual int write_data(xel *array, xelval *alpha);
57  virtual bool supports_write_row() const;
58  virtual bool supports_grayscale() const;
59  virtual bool write_header();
60  virtual bool write_row(xel *array, xelval *alpha);
61 
62  virtual bool supports_stream_write() const;
63 
64  INLINE bool is_valid() const;
65 
66 protected:
67  PNMFileType *_type;
68  bool _owns_file;
69  ostream *_file;
70  bool _is_valid;
71 };
72 
73 #include "pnmWriter.I"
74 
75 #endif
This is the base class of a family of classes that represent particular image file types that PNMImag...
Definition: pnmFileType.h:35
Defines a pfm file, a 2-d table of floating-point numbers, either 3-component or 1-component, or with a special extension, 2- or 4-component.
Definition: pfmFile.h:34
PNMFileType * get_type() const
If the file type is known (e.g.
This is an abstract base class that defines the interface for writing image files of various types...
Definition: pnmWriter.h:31
This is the base class of PNMImage, PNMReader, and PNMWriter.