mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 08:44:19 -04:00
*** empty log message ***
This commit is contained in:
parent
c8aa47494b
commit
0124053db8
@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
#include <string_utils.h>
|
#include <string_utils.h>
|
||||||
#include <executionEnvironment.h>
|
#include <executionEnvironment.h>
|
||||||
|
#include <bamReader.h>
|
||||||
|
#include <bamWriter.h>
|
||||||
|
|
||||||
bool PNMFileType::_did_init_pnm = false;
|
bool PNMFileType::_did_init_pnm = false;
|
||||||
TypeHandle PNMFileType::_type_handle;
|
TypeHandle PNMFileType::_type_handle;
|
||||||
@ -152,3 +154,17 @@ init_pnm() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PNMFileType::write_datagram
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description: Fills the indicated datagram up with a binary
|
||||||
|
// representation of the current object, in preparation
|
||||||
|
// for writing to a Bam file.
|
||||||
|
//
|
||||||
|
// None of the particular PNMFileType objects store any
|
||||||
|
// extra data--at least, not yet--so we just define this
|
||||||
|
// up here to do nothing.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void PNMFileType::
|
||||||
|
write_datagram(BamWriter *, Datagram &) {
|
||||||
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "pnmimage_base.h"
|
#include "pnmimage_base.h"
|
||||||
|
|
||||||
#include <typeHandle.h>
|
#include <typeHandle.h>
|
||||||
|
#include <typedWriteable.h>
|
||||||
|
|
||||||
class PNMReader;
|
class PNMReader;
|
||||||
class PNMWriter;
|
class PNMWriter;
|
||||||
@ -21,7 +22,7 @@ class PNMWriter;
|
|||||||
// represent particular image file types that PNMImage
|
// represent particular image file types that PNMImage
|
||||||
// supports.
|
// supports.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
class EXPCL_PANDA PNMFileType : public TypedObject {
|
class EXPCL_PANDA PNMFileType : public TypedWriteable {
|
||||||
protected:
|
protected:
|
||||||
PNMFileType();
|
PNMFileType();
|
||||||
|
|
||||||
@ -47,14 +48,23 @@ protected:
|
|||||||
private:
|
private:
|
||||||
static bool _did_init_pnm;
|
static bool _did_init_pnm;
|
||||||
|
|
||||||
|
|
||||||
|
// The TypedWriteable interface follows.
|
||||||
|
public:
|
||||||
|
static void register_with_read_factory(void);
|
||||||
|
virtual void write_datagram(BamWriter *writer, Datagram &datagram);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static TypedWriteable *make_PNMFileType(const FactoryParams ¶ms);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static TypeHandle get_class_type() {
|
static TypeHandle get_class_type() {
|
||||||
return _type_handle;
|
return _type_handle;
|
||||||
}
|
}
|
||||||
static void init_type() {
|
static void init_type() {
|
||||||
TypedObject::init_type();
|
TypedWriteable::init_type();
|
||||||
register_type(_type_handle, "PNMFileType",
|
register_type(_type_handle, "PNMFileType",
|
||||||
TypedObject::get_class_type());
|
TypedWriteable::get_class_type());
|
||||||
}
|
}
|
||||||
virtual TypeHandle get_type() const {
|
virtual TypeHandle get_type() const {
|
||||||
return get_class_type();
|
return get_class_type();
|
||||||
|
@ -67,7 +67,7 @@ get_num_types() const {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
PNMFileType *PNMFileTypeRegistry::
|
PNMFileType *PNMFileTypeRegistry::
|
||||||
get_type(int n) const {
|
get_type(int n) const {
|
||||||
nassertr(n >= 0 && n < _types.size(), NULL);
|
nassertr(n >= 0 && n < (int)_types.size(), NULL);
|
||||||
return _types[n];
|
return _types[n];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,6 +143,25 @@ get_type_from_magic_number(const string &magic_number) const {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PNMFileTypeRegistry::get_type_by_handle
|
||||||
|
// Access: Public
|
||||||
|
// Description: Returns the PNMFileType instance stored in the
|
||||||
|
// registry for the given TypeHandle, e.g. as retrieved
|
||||||
|
// by a previous call to get_type() on the type
|
||||||
|
// instance.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
PNMFileType *PNMFileTypeRegistry::
|
||||||
|
get_type_by_handle(TypeHandle handle) const {
|
||||||
|
Handles::const_iterator hi;
|
||||||
|
hi = _handles.find(handle);
|
||||||
|
if (hi != _handles.end()) {
|
||||||
|
return (*hi).second;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (PNMFileType *)NULL;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: PNMFileTypeRegistry::write_types
|
// Function: PNMFileTypeRegistry::write_types
|
||||||
// Access: Public
|
// Access: Public
|
||||||
@ -183,7 +202,8 @@ write_types(ostream &out, int indent_level) const {
|
|||||||
void PNMFileTypeRegistry::
|
void PNMFileTypeRegistry::
|
||||||
register_type(PNMFileType *type) {
|
register_type(PNMFileType *type) {
|
||||||
// Make sure we haven't already registered this type.
|
// Make sure we haven't already registered this type.
|
||||||
if (find(_types.begin(), _types.end(), type) != _types.end()) {
|
Handles::iterator hi = _handles.find(type->get_type());
|
||||||
|
if (hi != _handles.end()) {
|
||||||
pnmimage_cat.warning()
|
pnmimage_cat.warning()
|
||||||
<< "Attempt to register PNMFileType " << type->get_name()
|
<< "Attempt to register PNMFileType " << type->get_name()
|
||||||
<< " (" << type->get_type() << ") more than once.\n";
|
<< " (" << type->get_type() << ") more than once.\n";
|
||||||
@ -191,6 +211,7 @@ register_type(PNMFileType *type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_types.push_back(type);
|
_types.push_back(type);
|
||||||
|
_handles.insert(Handles::value_type(type->get_type(), type));
|
||||||
|
|
||||||
// Collect the unique extensions associated with the type.
|
// Collect the unique extensions associated with the type.
|
||||||
set<string> unique_extensions;
|
set<string> unique_extensions;
|
||||||
|
@ -10,8 +10,6 @@
|
|||||||
|
|
||||||
#include <typeHandle.h>
|
#include <typeHandle.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
class PNMFileType;
|
class PNMFileType;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -33,6 +31,7 @@ public:
|
|||||||
|
|
||||||
PNMFileType *get_type_from_extension(const string &filename) const;
|
PNMFileType *get_type_from_extension(const string &filename) const;
|
||||||
PNMFileType *get_type_from_magic_number(const string &magic_number) const;
|
PNMFileType *get_type_from_magic_number(const string &magic_number) const;
|
||||||
|
PNMFileType *get_type_by_handle(TypeHandle handle) const;
|
||||||
|
|
||||||
void write_types(ostream &out, int indent_level = 0) const;
|
void write_types(ostream &out, int indent_level = 0) const;
|
||||||
|
|
||||||
@ -47,6 +46,9 @@ private:
|
|||||||
typedef map<string, Types> Extensions;
|
typedef map<string, Types> Extensions;
|
||||||
Extensions _extensions;
|
Extensions _extensions;
|
||||||
|
|
||||||
|
typedef map<TypeHandle, PNMFileType *> Handles;
|
||||||
|
Handles _handles;
|
||||||
|
|
||||||
bool _requires_sort;
|
bool _requires_sort;
|
||||||
|
|
||||||
static PNMFileTypeRegistry *_global_ptr;
|
static PNMFileTypeRegistry *_global_ptr;
|
||||||
|
@ -109,6 +109,7 @@ ConfigureFn(config_pnmimagetypes) {
|
|||||||
<< "Invalid img-header-type: " << img_header_type_str << "\n";
|
<< "Invalid img-header-type: " << img_header_type_str << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Register each type with the PNMFileTypeRegistry.
|
||||||
PNMFileTypeRegistry *tr = PNMFileTypeRegistry::get_ptr();
|
PNMFileTypeRegistry *tr = PNMFileTypeRegistry::get_ptr();
|
||||||
|
|
||||||
tr->register_type(new PNMFileTypePNM);
|
tr->register_type(new PNMFileTypePNM);
|
||||||
@ -123,4 +124,18 @@ ConfigureFn(config_pnmimagetypes) {
|
|||||||
#ifdef HAVE_JPEG
|
#ifdef HAVE_JPEG
|
||||||
tr->register_type(new PNMFileTypeJPG);
|
tr->register_type(new PNMFileTypeJPG);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Also register with the Bam reader.
|
||||||
|
PNMFileTypePNM::register_with_read_factory();
|
||||||
|
PNMFileTypeSGI::register_with_read_factory();
|
||||||
|
PNMFileTypeAlias::register_with_read_factory();
|
||||||
|
PNMFileTypeRadiance::register_with_read_factory();
|
||||||
|
PNMFileTypeTIFF::register_with_read_factory();
|
||||||
|
PNMFileTypeYUV::register_with_read_factory();
|
||||||
|
PNMFileTypeIMG::register_with_read_factory();
|
||||||
|
PNMFileTypeSoftImage::register_with_read_factory();
|
||||||
|
PNMFileTypeBMP::register_with_read_factory();
|
||||||
|
#ifdef HAVE_JPEG
|
||||||
|
PNMFileTypeJPG::register_with_read_factory();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,9 @@
|
|||||||
#include "pnmFileTypeAlias.h"
|
#include "pnmFileTypeAlias.h"
|
||||||
#include "config_pnmimagetypes.h"
|
#include "config_pnmimagetypes.h"
|
||||||
|
|
||||||
|
#include <pnmFileTypeRegistry.h>
|
||||||
|
#include <bamReader.h>
|
||||||
|
|
||||||
// Since Alias image files don't have a magic number, we'll make a
|
// Since Alias image files don't have a magic number, we'll make a
|
||||||
// little sanity check on the size of the image. If either the width
|
// little sanity check on the size of the image. If either the width
|
||||||
// or height is larger than this, it must be bogus.
|
// or height is larger than this, it must be bogus.
|
||||||
@ -373,3 +376,32 @@ write_row(xel *row_data, xelval *) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PNMFileTypeAlias::register_with_read_factory
|
||||||
|
// Access: Public, Static
|
||||||
|
// Description: Registers the current object as something that can be
|
||||||
|
// read from a Bam file.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void PNMFileTypeAlias::
|
||||||
|
register_with_read_factory() {
|
||||||
|
BamReader::get_factory()->
|
||||||
|
register_factory(get_class_type(), make_PNMFileTypeAlias);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PNMFileTypeAlias::make_PNMFileTypeAlias
|
||||||
|
// Access: Protected, Static
|
||||||
|
// Description: This method is called by the BamReader when an object
|
||||||
|
// of this type is encountered in a Bam file; it should
|
||||||
|
// allocate and return a new object with all the data
|
||||||
|
// read.
|
||||||
|
//
|
||||||
|
// In the case of the PNMFileType objects, since these
|
||||||
|
// objects are all shared, we just pull the object from
|
||||||
|
// the registry.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
TypedWriteable *PNMFileTypeAlias::
|
||||||
|
make_PNMFileTypeAlias(const FactoryParams ¶ms) {
|
||||||
|
return PNMFileTypeRegistry::get_ptr()->get_type_by_handle(get_class_type());
|
||||||
|
}
|
||||||
|
@ -49,6 +49,13 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// The TypedWriteable interface follows.
|
||||||
|
public:
|
||||||
|
static void register_with_read_factory();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static TypedWriteable *make_PNMFileTypeAlias(const FactoryParams ¶ms);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static TypeHandle get_class_type() {
|
static TypeHandle get_class_type() {
|
||||||
return _type_handle;
|
return _type_handle;
|
||||||
|
@ -6,6 +6,9 @@
|
|||||||
#include "pnmFileTypeBMP.h"
|
#include "pnmFileTypeBMP.h"
|
||||||
#include "config_pnmimagetypes.h"
|
#include "config_pnmimagetypes.h"
|
||||||
|
|
||||||
|
#include <pnmFileTypeRegistry.h>
|
||||||
|
#include <bamReader.h>
|
||||||
|
|
||||||
static const char * const extensions[] = {
|
static const char * const extensions[] = {
|
||||||
"bmp"
|
"bmp"
|
||||||
};
|
};
|
||||||
@ -118,3 +121,32 @@ make_writer(FILE *file, bool owns_file) {
|
|||||||
return new Writer(this, file, owns_file);
|
return new Writer(this, file, owns_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PNMFileTypeBMP::register_with_read_factory
|
||||||
|
// Access: Public, Static
|
||||||
|
// Description: Registers the current object as something that can be
|
||||||
|
// read from a Bam file.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void PNMFileTypeBMP::
|
||||||
|
register_with_read_factory() {
|
||||||
|
BamReader::get_factory()->
|
||||||
|
register_factory(get_class_type(), make_PNMFileTypeBMP);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PNMFileTypeBMP::make_PNMFileTypeBMP
|
||||||
|
// Access: Protected, Static
|
||||||
|
// Description: This method is called by the BamReader when an object
|
||||||
|
// of this type is encountered in a Bam file; it should
|
||||||
|
// allocate and return a new object with all the data
|
||||||
|
// read.
|
||||||
|
//
|
||||||
|
// In the case of the PNMFileType objects, since these
|
||||||
|
// objects are all shared, we just pull the object from
|
||||||
|
// the registry.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
TypedWriteable *PNMFileTypeBMP::
|
||||||
|
make_PNMFileTypeBMP(const FactoryParams ¶ms) {
|
||||||
|
return PNMFileTypeRegistry::get_ptr()->get_type_by_handle(get_class_type());
|
||||||
|
}
|
||||||
|
@ -62,6 +62,13 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// The TypedWriteable interface follows.
|
||||||
|
public:
|
||||||
|
static void register_with_read_factory();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static TypedWriteable *make_PNMFileTypeBMP(const FactoryParams ¶ms);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static TypeHandle get_class_type() {
|
static TypeHandle get_class_type() {
|
||||||
return _type_handle;
|
return _type_handle;
|
||||||
|
@ -6,6 +6,9 @@
|
|||||||
#include "pnmFileTypeIMG.h"
|
#include "pnmFileTypeIMG.h"
|
||||||
#include "config_pnmimagetypes.h"
|
#include "config_pnmimagetypes.h"
|
||||||
|
|
||||||
|
#include <pnmFileTypeRegistry.h>
|
||||||
|
#include <bamReader.h>
|
||||||
|
|
||||||
// Since raw image files don't have a magic number, we'll make a little
|
// Since raw image files don't have a magic number, we'll make a little
|
||||||
// sanity check on the size of the image. If either the width or height is
|
// sanity check on the size of the image. If either the width or height is
|
||||||
// larger than this, it must be bogus.
|
// larger than this, it must be bogus.
|
||||||
@ -332,3 +335,32 @@ write_row(xel *row_data, xelval *) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PNMFileTypeIMG::register_with_read_factory
|
||||||
|
// Access: Public, Static
|
||||||
|
// Description: Registers the current object as something that can be
|
||||||
|
// read from a Bam file.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void PNMFileTypeIMG::
|
||||||
|
register_with_read_factory() {
|
||||||
|
BamReader::get_factory()->
|
||||||
|
register_factory(get_class_type(), make_PNMFileTypeIMG);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PNMFileTypeIMG::make_PNMFileTypeIMG
|
||||||
|
// Access: Protected, Static
|
||||||
|
// Description: This method is called by the BamReader when an object
|
||||||
|
// of this type is encountered in a Bam file; it should
|
||||||
|
// allocate and return a new object with all the data
|
||||||
|
// read.
|
||||||
|
//
|
||||||
|
// In the case of the PNMFileType objects, since these
|
||||||
|
// objects are all shared, we just pull the object from
|
||||||
|
// the registry.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
TypedWriteable *PNMFileTypeIMG::
|
||||||
|
make_PNMFileTypeIMG(const FactoryParams ¶ms) {
|
||||||
|
return PNMFileTypeRegistry::get_ptr()->get_type_by_handle(get_class_type());
|
||||||
|
}
|
||||||
|
@ -49,6 +49,13 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// The TypedWriteable interface follows.
|
||||||
|
public:
|
||||||
|
static void register_with_read_factory();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static TypedWriteable *make_PNMFileTypeIMG(const FactoryParams ¶ms);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static TypeHandle get_class_type() {
|
static TypeHandle get_class_type() {
|
||||||
return _type_handle;
|
return _type_handle;
|
||||||
|
@ -6,6 +6,9 @@
|
|||||||
#include "pnmFileTypeJPG.h"
|
#include "pnmFileTypeJPG.h"
|
||||||
#include "config_pnmimagetypes.h"
|
#include "config_pnmimagetypes.h"
|
||||||
|
|
||||||
|
#include <pnmFileTypeRegistry.h>
|
||||||
|
#include <bamReader.h>
|
||||||
|
|
||||||
static const char * const extensions[] = {
|
static const char * const extensions[] = {
|
||||||
"jpg", "jpeg"
|
"jpg", "jpeg"
|
||||||
};
|
};
|
||||||
@ -119,3 +122,32 @@ make_writer(FILE *file, bool owns_file) {
|
|||||||
return new Writer(this, file, owns_file);
|
return new Writer(this, file, owns_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PNMFileTypeJPG::register_with_read_factory
|
||||||
|
// Access: Public, Static
|
||||||
|
// Description: Registers the current object as something that can be
|
||||||
|
// read from a Bam file.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void PNMFileTypeJPG::
|
||||||
|
register_with_read_factory() {
|
||||||
|
BamReader::get_factory()->
|
||||||
|
register_factory(get_class_type(), make_PNMFileTypeJPG);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PNMFileTypeJPG::make_PNMFileTypeJPG
|
||||||
|
// Access: Protected, Static
|
||||||
|
// Description: This method is called by the BamReader when an object
|
||||||
|
// of this type is encountered in a Bam file; it should
|
||||||
|
// allocate and return a new object with all the data
|
||||||
|
// read.
|
||||||
|
//
|
||||||
|
// In the case of the PNMFileType objects, since these
|
||||||
|
// objects are all shared, we just pull the object from
|
||||||
|
// the registry.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
TypedWriteable *PNMFileTypeJPG::
|
||||||
|
make_PNMFileTypeJPG(const FactoryParams ¶ms) {
|
||||||
|
return PNMFileTypeRegistry::get_ptr()->get_type_by_handle(get_class_type());
|
||||||
|
}
|
||||||
|
@ -75,6 +75,13 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// The TypedWriteable interface follows.
|
||||||
|
public:
|
||||||
|
static void register_with_read_factory();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static TypedWriteable *make_PNMFileTypeJPG(const FactoryParams ¶ms);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static TypeHandle get_class_type() {
|
static TypeHandle get_class_type() {
|
||||||
return _type_handle;
|
return _type_handle;
|
||||||
|
@ -6,6 +6,9 @@
|
|||||||
#include "pnmFileTypePNM.h"
|
#include "pnmFileTypePNM.h"
|
||||||
#include "config_pnmimagetypes.h"
|
#include "config_pnmimagetypes.h"
|
||||||
|
|
||||||
|
#include <pnmFileTypeRegistry.h>
|
||||||
|
#include <bamReader.h>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "../pnm/pnm.h"
|
#include "../pnm/pnm.h"
|
||||||
#include "../pnm/ppm.h"
|
#include "../pnm/ppm.h"
|
||||||
@ -316,3 +319,32 @@ write_row(xel *row_data, xelval *) {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PNMFileTypePNM::register_with_read_factory
|
||||||
|
// Access: Public, Static
|
||||||
|
// Description: Registers the current object as something that can be
|
||||||
|
// read from a Bam file.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void PNMFileTypePNM::
|
||||||
|
register_with_read_factory() {
|
||||||
|
BamReader::get_factory()->
|
||||||
|
register_factory(get_class_type(), make_PNMFileTypePNM);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PNMFileTypePNM::make_PNMFileTypePNM
|
||||||
|
// Access: Protected, Static
|
||||||
|
// Description: This method is called by the BamReader when an object
|
||||||
|
// of this type is encountered in a Bam file; it should
|
||||||
|
// allocate and return a new object with all the data
|
||||||
|
// read.
|
||||||
|
//
|
||||||
|
// In the case of the PNMFileType objects, since these
|
||||||
|
// objects are all shared, we just pull the object from
|
||||||
|
// the registry.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
TypedWriteable *PNMFileTypePNM::
|
||||||
|
make_PNMFileTypePNM(const FactoryParams ¶ms) {
|
||||||
|
return PNMFileTypeRegistry::get_ptr()->get_type_by_handle(get_class_type());
|
||||||
|
}
|
||||||
|
@ -58,6 +58,14 @@ public:
|
|||||||
int _pnm_format;
|
int _pnm_format;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// The TypedWriteable interface follows.
|
||||||
|
public:
|
||||||
|
static void register_with_read_factory();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static TypedWriteable *make_PNMFileTypePNM(const FactoryParams ¶ms);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static TypeHandle get_class_type() {
|
static TypeHandle get_class_type() {
|
||||||
return _type_handle;
|
return _type_handle;
|
||||||
|
@ -6,6 +6,9 @@
|
|||||||
#include "pnmFileTypeRadiance.h"
|
#include "pnmFileTypeRadiance.h"
|
||||||
#include "config_pnmimagetypes.h"
|
#include "config_pnmimagetypes.h"
|
||||||
|
|
||||||
|
#include <pnmFileTypeRegistry.h>
|
||||||
|
#include <bamReader.h>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "color.h"
|
#include "color.h"
|
||||||
#include "resolu.h"
|
#include "resolu.h"
|
||||||
@ -335,3 +338,32 @@ write_row(xel *row_data, xelval *) {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PNMFileTypeRadiance::register_with_read_factory
|
||||||
|
// Access: Public, Static
|
||||||
|
// Description: Registers the current object as something that can be
|
||||||
|
// read from a Bam file.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void PNMFileTypeRadiance::
|
||||||
|
register_with_read_factory() {
|
||||||
|
BamReader::get_factory()->
|
||||||
|
register_factory(get_class_type(), make_PNMFileTypeRadiance);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PNMFileTypeRadiance::make_PNMFileTypeRadiance
|
||||||
|
// Access: Protected, Static
|
||||||
|
// Description: This method is called by the BamReader when an object
|
||||||
|
// of this type is encountered in a Bam file; it should
|
||||||
|
// allocate and return a new object with all the data
|
||||||
|
// read.
|
||||||
|
//
|
||||||
|
// In the case of the PNMFileType objects, since these
|
||||||
|
// objects are all shared, we just pull the object from
|
||||||
|
// the registry.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
TypedWriteable *PNMFileTypeRadiance::
|
||||||
|
make_PNMFileTypeRadiance(const FactoryParams ¶ms) {
|
||||||
|
return PNMFileTypeRegistry::get_ptr()->get_type_by_handle(get_class_type());
|
||||||
|
}
|
||||||
|
@ -52,6 +52,13 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// The TypedWriteable interface follows.
|
||||||
|
public:
|
||||||
|
static void register_with_read_factory();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static TypedWriteable *make_PNMFileTypeRadiance(const FactoryParams ¶ms);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static TypeHandle get_class_type() {
|
static TypeHandle get_class_type() {
|
||||||
return _type_handle;
|
return _type_handle;
|
||||||
|
@ -7,6 +7,9 @@
|
|||||||
#include "config_pnmimagetypes.h"
|
#include "config_pnmimagetypes.h"
|
||||||
#include "sgi.h"
|
#include "sgi.h"
|
||||||
|
|
||||||
|
#include <pnmFileTypeRegistry.h>
|
||||||
|
#include <bamReader.h>
|
||||||
|
|
||||||
static const char * const extensions[] = {
|
static const char * const extensions[] = {
|
||||||
"rgb", "rgba", "sgi"
|
"rgb", "rgba", "sgi"
|
||||||
};
|
};
|
||||||
@ -122,3 +125,32 @@ make_writer(FILE *file, bool owns_file) {
|
|||||||
return new Writer(this, file, owns_file);
|
return new Writer(this, file, owns_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PNMFileTypeSGI::register_with_read_factory
|
||||||
|
// Access: Public, Static
|
||||||
|
// Description: Registers the current object as something that can be
|
||||||
|
// read from a Bam file.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void PNMFileTypeSGI::
|
||||||
|
register_with_read_factory() {
|
||||||
|
BamReader::get_factory()->
|
||||||
|
register_factory(get_class_type(), make_PNMFileTypeSGI);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PNMFileTypeSGI::make_PNMFileTypeSGI
|
||||||
|
// Access: Protected, Static
|
||||||
|
// Description: This method is called by the BamReader when an object
|
||||||
|
// of this type is encountered in a Bam file; it should
|
||||||
|
// allocate and return a new object with all the data
|
||||||
|
// read.
|
||||||
|
//
|
||||||
|
// In the case of the PNMFileType objects, since these
|
||||||
|
// objects are all shared, we just pull the object from
|
||||||
|
// the registry.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
TypedWriteable *PNMFileTypeSGI::
|
||||||
|
make_PNMFileTypeSGI(const FactoryParams ¶ms) {
|
||||||
|
return PNMFileTypeRegistry::get_ptr()->get_type_by_handle(get_class_type());
|
||||||
|
}
|
||||||
|
@ -97,6 +97,13 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// The TypedWriteable interface follows.
|
||||||
|
public:
|
||||||
|
static void register_with_read_factory();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static TypedWriteable *make_PNMFileTypeSGI(const FactoryParams ¶ms);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static TypeHandle get_class_type() {
|
static TypeHandle get_class_type() {
|
||||||
return _type_handle;
|
return _type_handle;
|
||||||
|
@ -6,6 +6,9 @@
|
|||||||
#include "pnmFileTypeSoftImage.h"
|
#include "pnmFileTypeSoftImage.h"
|
||||||
#include "config_pnmimagetypes.h"
|
#include "config_pnmimagetypes.h"
|
||||||
|
|
||||||
|
#include <pnmFileTypeRegistry.h>
|
||||||
|
#include <bamReader.h>
|
||||||
|
|
||||||
static const float imageVersionNumber = 3.0;
|
static const float imageVersionNumber = 3.0;
|
||||||
static const int imageCommentLength = 80;
|
static const int imageCommentLength = 80;
|
||||||
static const char imageComment[imageCommentLength+1] =
|
static const char imageComment[imageCommentLength+1] =
|
||||||
@ -745,3 +748,32 @@ write_row(xel *row_data, xelval *alpha_data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PNMFileTypeSoftImage::register_with_read_factory
|
||||||
|
// Access: Public, Static
|
||||||
|
// Description: Registers the current object as something that can be
|
||||||
|
// read from a Bam file.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void PNMFileTypeSoftImage::
|
||||||
|
register_with_read_factory() {
|
||||||
|
BamReader::get_factory()->
|
||||||
|
register_factory(get_class_type(), make_PNMFileTypeSoftImage);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PNMFileTypeSoftImage::make_PNMFileTypeSoftImage
|
||||||
|
// Access: Protected, Static
|
||||||
|
// Description: This method is called by the BamReader when an object
|
||||||
|
// of this type is encountered in a Bam file; it should
|
||||||
|
// allocate and return a new object with all the data
|
||||||
|
// read.
|
||||||
|
//
|
||||||
|
// In the case of the PNMFileType objects, since these
|
||||||
|
// objects are all shared, we just pull the object from
|
||||||
|
// the registry.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
TypedWriteable *PNMFileTypeSoftImage::
|
||||||
|
make_PNMFileTypeSoftImage(const FactoryParams ¶ms) {
|
||||||
|
return PNMFileTypeRegistry::get_ptr()->get_type_by_handle(get_class_type());
|
||||||
|
}
|
||||||
|
@ -56,6 +56,13 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// The TypedWriteable interface follows.
|
||||||
|
public:
|
||||||
|
static void register_with_read_factory();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static TypedWriteable *make_PNMFileTypeSoftImage(const FactoryParams ¶ms);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static TypeHandle get_class_type() {
|
static TypeHandle get_class_type() {
|
||||||
return _type_handle;
|
return _type_handle;
|
||||||
|
@ -6,6 +6,13 @@
|
|||||||
#include "pnmFileTypeTIFF.h"
|
#include "pnmFileTypeTIFF.h"
|
||||||
#include "config_pnmimagetypes.h"
|
#include "config_pnmimagetypes.h"
|
||||||
|
|
||||||
|
#include <pnmFileTypeRegistry.h>
|
||||||
|
#include <bamReader.h>
|
||||||
|
|
||||||
|
// Tiff will want to re-typedef these things.
|
||||||
|
#define int32 tiff_int32
|
||||||
|
#define uint32 tiff_uint32
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "../pnm/ppmcmap.h"
|
#include "../pnm/ppmcmap.h"
|
||||||
#include "../tiff/tiff.h"
|
#include "../tiff/tiff.h"
|
||||||
@ -777,3 +784,32 @@ write_data(xel *array, xelval *alpha) {
|
|||||||
|
|
||||||
return _y_size;
|
return _y_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PNMFileTypeTIFF::register_with_read_factory
|
||||||
|
// Access: Public, Static
|
||||||
|
// Description: Registers the current object as something that can be
|
||||||
|
// read from a Bam file.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void PNMFileTypeTIFF::
|
||||||
|
register_with_read_factory() {
|
||||||
|
BamReader::get_factory()->
|
||||||
|
register_factory(get_class_type(), make_PNMFileTypeTIFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PNMFileTypeTIFF::make_PNMFileTypeTIFF
|
||||||
|
// Access: Protected, Static
|
||||||
|
// Description: This method is called by the BamReader when an object
|
||||||
|
// of this type is encountered in a Bam file; it should
|
||||||
|
// allocate and return a new object with all the data
|
||||||
|
// read.
|
||||||
|
//
|
||||||
|
// In the case of the PNMFileType objects, since these
|
||||||
|
// objects are all shared, we just pull the object from
|
||||||
|
// the registry.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
TypedWriteable *PNMFileTypeTIFF::
|
||||||
|
make_PNMFileTypeTIFF(const FactoryParams ¶ms) {
|
||||||
|
return PNMFileTypeRegistry::get_ptr()->get_type_by_handle(get_class_type());
|
||||||
|
}
|
||||||
|
@ -61,6 +61,13 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// The TypedWriteable interface follows.
|
||||||
|
public:
|
||||||
|
static void register_with_read_factory();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static TypedWriteable *make_PNMFileTypeTIFF(const FactoryParams ¶ms);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static TypeHandle get_class_type() {
|
static TypeHandle get_class_type() {
|
||||||
return _type_handle;
|
return _type_handle;
|
||||||
|
@ -51,6 +51,9 @@
|
|||||||
#include "pnmFileTypeYUV.h"
|
#include "pnmFileTypeYUV.h"
|
||||||
#include "config_pnmimagetypes.h"
|
#include "config_pnmimagetypes.h"
|
||||||
|
|
||||||
|
#include <pnmFileTypeRegistry.h>
|
||||||
|
#include <bamReader.h>
|
||||||
|
|
||||||
/* x must be signed for the following to work correctly */
|
/* x must be signed for the following to work correctly */
|
||||||
#define limit(x) (xelval)(((x>0xffffff)?0xff0000:((x<=0xffff)?0:x&0xff0000))>>16)
|
#define limit(x) (xelval)(((x>0xffffff)?0xff0000:((x<=0xffff)?0:x&0xff0000))>>16)
|
||||||
|
|
||||||
@ -381,3 +384,32 @@ write_row(xel *row_data, xelval *) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PNMFileTypeYUV::register_with_read_factory
|
||||||
|
// Access: Public, Static
|
||||||
|
// Description: Registers the current object as something that can be
|
||||||
|
// read from a Bam file.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void PNMFileTypeYUV::
|
||||||
|
register_with_read_factory() {
|
||||||
|
BamReader::get_factory()->
|
||||||
|
register_factory(get_class_type(), make_PNMFileTypeYUV);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PNMFileTypeYUV::make_PNMFileTypeYUV
|
||||||
|
// Access: Protected, Static
|
||||||
|
// Description: This method is called by the BamReader when an object
|
||||||
|
// of this type is encountered in a Bam file; it should
|
||||||
|
// allocate and return a new object with all the data
|
||||||
|
// read.
|
||||||
|
//
|
||||||
|
// In the case of the PNMFileType objects, since these
|
||||||
|
// objects are all shared, we just pull the object from
|
||||||
|
// the registry.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
TypedWriteable *PNMFileTypeYUV::
|
||||||
|
make_PNMFileTypeYUV(const FactoryParams ¶ms) {
|
||||||
|
return PNMFileTypeRegistry::get_ptr()->get_type_by_handle(get_class_type());
|
||||||
|
}
|
||||||
|
@ -57,6 +57,13 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// The TypedWriteable interface follows.
|
||||||
|
public:
|
||||||
|
static void register_with_read_factory();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static TypedWriteable *make_PNMFileTypeYUV(const FactoryParams ¶ms);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static TypeHandle get_class_type() {
|
static TypeHandle get_class_type() {
|
||||||
return _type_handle;
|
return _type_handle;
|
||||||
|
@ -239,12 +239,23 @@ read_object(void)
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: BamReader::read_pointer
|
// Function: BamReader::read_pointer
|
||||||
// Access: Public
|
// Access: Public
|
||||||
// Description: Utility function provided to correctly read in objects
|
// Description: The interface for reading a pointer to another object
|
||||||
// from the Datagram source, that any other object contains
|
// from a Bam file. Objects reading themselves from a
|
||||||
// pointers to. Will correctly handle all circular references
|
// Bam file should call this when they expect to read a
|
||||||
// Any caller of this function should pass a pointer to itself
|
// pointer, passing in the datagram iterator and a
|
||||||
// because the pointer request will be stored and completed
|
// pointer to their own object, i.e. 'this'.
|
||||||
// at a later pointer when the object is actually generated
|
//
|
||||||
|
// Rather than returning a pointer immediately, this
|
||||||
|
// function reads the internal pointer information from
|
||||||
|
// the datagram and queues up the request. The pointer
|
||||||
|
// itself may not be available until later (it may be a
|
||||||
|
// pointer to an object that appears later in the Bam
|
||||||
|
// file). Later, when all pointers are available, the
|
||||||
|
// complete_pointers() callback function will be called
|
||||||
|
// with an array of actual pointers, one for time
|
||||||
|
// read_pointer() was called. It is then the calling
|
||||||
|
// object's responsibilty to store these pointers in the
|
||||||
|
// object properly.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void BamReader::
|
void BamReader::
|
||||||
read_pointer(DatagramIterator& scan, TypedWriteable* forWhom)
|
read_pointer(DatagramIterator& scan, TypedWriteable* forWhom)
|
||||||
@ -264,6 +275,20 @@ read_pointer(DatagramIterator& scan, TypedWriteable* forWhom)
|
|||||||
queue(objId);
|
queue(objId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: BamReader::read_pointers
|
||||||
|
// Access: Public
|
||||||
|
// Description: A convenience function to read a contiguous list of
|
||||||
|
// pointers. This is equivalent to calling
|
||||||
|
// read_pointer() count times.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void BamReader::
|
||||||
|
read_pointers(DatagramIterator &scan, TypedWriteable *forWhom, int count) {
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
read_pointer(scan, forWhom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: BamReader::register_finalize
|
// Function: BamReader::register_finalize
|
||||||
// Access: Public
|
// Access: Public
|
||||||
|
@ -65,6 +65,7 @@ public:
|
|||||||
//points to, it needs to pass a reference to itself, that BamReader
|
//points to, it needs to pass a reference to itself, that BamReader
|
||||||
//can register in itself for later "fixing"
|
//can register in itself for later "fixing"
|
||||||
void read_pointer(DatagramIterator &scan, TypedWriteable* forWhom);
|
void read_pointer(DatagramIterator &scan, TypedWriteable* forWhom);
|
||||||
|
void read_pointers(DatagramIterator &scan, TypedWriteable* forWhom, int count);
|
||||||
|
|
||||||
//At any time you can call this function to try and resolve all
|
//At any time you can call this function to try and resolve all
|
||||||
//outstanding pointer requests. Will resolve all requests that
|
//outstanding pointer requests. Will resolve all requests that
|
||||||
|
Loading…
x
Reference in New Issue
Block a user