Panda3D

Loading...
Searching...
No Matches
pnmFileTypeIMG.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 pnmFileTypeIMG.h
10 * @author drose
11 * @date 2000-06-17
12 */
13
14#ifndef PNMFILETYPEIMG_H
15#define PNMFILETYPEIMG_H
16
17#include "pandabase.h"
18
19#ifdef HAVE_IMG
20
21#include "pnmFileType.h"
22#include "pnmReader.h"
23#include "pnmWriter.h"
24
25/**
26 * For reading and writing headerless R,G,B files.
27 */
28 class EXPCL_PANDA_PNMIMAGETYPES PNMFileTypeIMG : public PNMFileType {
29 public:
30 PNMFileTypeIMG();
31
32 virtual std::string get_name() const;
33
34 virtual int get_num_extensions() const;
35 virtual std::string get_extension(int n) const;
36 virtual std::string get_suggested_extension() const;
37
38 virtual PNMReader *make_reader(std::istream *file, bool owns_file = true,
39 const std::string &magic_number = std::string());
40 virtual PNMWriter *make_writer(std::ostream *file, bool owns_file = true);
41
42 public:
43 class Reader : public PNMReader {
44 public:
45 Reader(PNMFileType *type, std::istream *file, bool owns_file, std::string magic_number);
46
47 virtual bool supports_read_row() const;
48 virtual bool read_row(xel *array, xelval *alpha, int x_size, int y_size);
49 };
50
51 class Writer : public PNMWriter {
52 public:
53 Writer(PNMFileType *type, std::ostream *file, bool owns_file);
54
55 virtual bool supports_write_row() const;
56 virtual bool write_header();
57 virtual bool write_row(xel *array, xelval *alpha);
58 };
59
60
61 // The TypedWritable interface follows.
62 public:
63 static void register_with_read_factory();
64
65 protected:
66 static TypedWritable *make_PNMFileTypeIMG(const FactoryParams &params);
67
68 public:
69 static TypeHandle get_class_type() {
70 return _type_handle;
71 }
72 static void init_type() {
73 PNMFileType::init_type();
74 register_type(_type_handle, "PNMFileTypeIMG",
75 PNMFileType::get_class_type());
76 }
77 virtual TypeHandle get_type() const {
78 return get_class_type();
79 }
80 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
81
82 private:
83 static TypeHandle _type_handle;
84};
85
86#endif // HAVE_IMG
87
88#endif
PNMFileType
This is the base class of a family of classes that represent particular image file types that PNMImag...
Definition pnmFileType.h:32
PNMFileType::get_suggested_extension
get_suggested_extension
Returns a suitable filename extension (without a leading dot) to suggest for files of this type,...
Definition pnmFileType.h:49
PNMFileType::make_reader
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.
Definition pnmFileType.cxx:96
PNMFileType::get_num_extensions
get_num_extensions
Returns the number of different possible filename extensions associated with this particular file typ...
Definition pnmFileType.h:44
PNMFileType::make_writer
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.
Definition pnmFileType.cxx:106
PNMFileType::get_extension
get_extension
Returns the nth possible filename extension associated with this particular file type,...
Definition pnmFileType.h:44
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pnmFileType.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pnmReader.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pnmWriter.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition register_type.I:22