mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
all image formats switchable
This commit is contained in:
parent
8a44eb5b92
commit
885b114766
@ -850,6 +850,12 @@ DTOOL_CONFIG=[
|
||||
("HAVE_PNG", 'UNDEF', 'UNDEF'),
|
||||
("HAVE_JPEG", 'UNDEF', 'UNDEF'),
|
||||
("HAVE_TIFF", 'UNDEF', 'UNDEF'),
|
||||
("HAVE_SGI_RGB", '1', '1'),
|
||||
("HAVE_TGA", '1', '1'),
|
||||
("HAVE_IMG", '1', '1'),
|
||||
("HAVE_SOFTIMAGE_PIC", '1', '1'),
|
||||
("HAVE_BMP", '1', '1'),
|
||||
("HAVE_PNM", '1', '1'),
|
||||
("HAVE_VRPN", 'UNDEF', 'UNDEF'),
|
||||
("HAVE_FMODEX", 'UNDEF', 'UNDEF'),
|
||||
("HAVE_OPENAL", 'UNDEF', 'UNDEF'),
|
||||
|
@ -11,7 +11,7 @@
|
||||
$[TARGET]_composite1.cxx $[TARGET]_composite2.cxx
|
||||
|
||||
#define SOURCES \
|
||||
config_pnmimagetypes.h pnmFileTypeAlias.h pnmFileTypeBMP.h \
|
||||
config_pnmimagetypes.h pnmFileTypeBMP.h \
|
||||
pnmFileTypeIMG.h \
|
||||
pnmFileTypePNG.h \
|
||||
pnmFileTypePNM.h \
|
||||
@ -21,7 +21,7 @@
|
||||
pnmFileTypeJPG.h
|
||||
|
||||
#define INCLUDED_SOURCES \
|
||||
config_pnmimagetypes.cxx pnmFileTypeAlias.cxx \
|
||||
config_pnmimagetypes.cxx \
|
||||
pnmFileTypeBMPReader.cxx pnmFileTypeBMPWriter.cxx \
|
||||
pnmFileTypeBMP.cxx \
|
||||
pnmFileTypeIMG.cxx \
|
||||
|
@ -14,7 +14,6 @@
|
||||
|
||||
#include "config_pnmimagetypes.h"
|
||||
#include "pnmFileTypeSGI.h"
|
||||
#include "pnmFileTypeAlias.h"
|
||||
#include "pnmFileTypeTGA.h"
|
||||
#include "pnmFileTypeIMG.h"
|
||||
#include "pnmFileTypeSoftImage.h"
|
||||
@ -33,7 +32,6 @@
|
||||
|
||||
Configure(config_pnmimagetypes);
|
||||
NotifyCategoryDefName(pnmimage_sgi, "sgi", pnmimage_cat);
|
||||
NotifyCategoryDefName(pnmimage_alias, "alias", pnmimage_cat);
|
||||
NotifyCategoryDefName(pnmimage_tga, "tga", pnmimage_cat);
|
||||
NotifyCategoryDefName(pnmimage_img, "img", pnmimage_cat);
|
||||
NotifyCategoryDefName(pnmimage_soft, "soft", pnmimage_cat);
|
||||
@ -179,59 +177,61 @@ init_libpnmimagetypes() {
|
||||
initialized = true;
|
||||
|
||||
init_libpnmimage();
|
||||
PNMFileTypeSGI::init_type();
|
||||
PNMFileTypeAlias::init_type();
|
||||
PNMFileTypeTGA::init_type();
|
||||
PNMFileTypeIMG::init_type();
|
||||
PNMFileTypeSoftImage::init_type();
|
||||
PNMFileTypeBMP::init_type();
|
||||
PNMFileTypePNM::init_type();
|
||||
#ifdef HAVE_JPEG
|
||||
PNMFileTypeJPG::init_type();
|
||||
#endif
|
||||
#ifdef HAVE_PNG
|
||||
PNMFileTypePNG::init_type();
|
||||
#endif
|
||||
#ifdef HAVE_TIFF
|
||||
PNMFileTypeTIFF::init_type();
|
||||
#endif
|
||||
|
||||
// Register each type with the PNMFileTypeRegistry.
|
||||
PNMFileTypeRegistry *tr = PNMFileTypeRegistry::get_global_ptr();
|
||||
|
||||
#ifdef HAVE_SGI_RGB
|
||||
PNMFileTypeSGI::init_type();
|
||||
PNMFileTypeSGI::register_with_read_factory();
|
||||
tr->register_type(new PNMFileTypeSGI);
|
||||
tr->register_type(new PNMFileTypeAlias);
|
||||
tr->register_type(new PNMFileTypeTGA);
|
||||
tr->register_type(new PNMFileTypeIMG);
|
||||
tr->register_type(new PNMFileTypeSoftImage);
|
||||
tr->register_type(new PNMFileTypeBMP);
|
||||
tr->register_type(new PNMFileTypePNM);
|
||||
#ifdef HAVE_JPEG
|
||||
tr->register_type(new PNMFileTypeJPG);
|
||||
#endif
|
||||
#ifdef HAVE_PNG
|
||||
tr->register_type(new PNMFileTypePNG);
|
||||
#endif
|
||||
#ifdef HAVE_TIFF
|
||||
tr->register_type(new PNMFileTypeTIFF);
|
||||
#endif
|
||||
|
||||
// Also register with the Bam reader.
|
||||
PNMFileTypeSGI::register_with_read_factory();
|
||||
PNMFileTypeAlias::register_with_read_factory();
|
||||
#ifdef HAVE_TGA
|
||||
PNMFileTypeTGA::init_type();
|
||||
PNMFileTypeTGA::register_with_read_factory();
|
||||
tr->register_type(new PNMFileTypeTGA);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_IMG
|
||||
PNMFileTypeIMG::init_type();
|
||||
PNMFileTypeIMG::register_with_read_factory();
|
||||
tr->register_type(new PNMFileTypeIMG);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SOFTIMAGE_PIC
|
||||
PNMFileTypeSoftImage::init_type();
|
||||
PNMFileTypeSoftImage::register_with_read_factory();
|
||||
tr->register_type(new PNMFileTypeSoftImage);
|
||||
#endif // HAVE_SOFTIMAGE_PIC
|
||||
|
||||
#ifdef HAVE_BMP
|
||||
PNMFileTypeBMP::init_type();
|
||||
PNMFileTypeBMP::register_with_read_factory();
|
||||
tr->register_type(new PNMFileTypeBMP);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PNM
|
||||
PNMFileTypePNM::init_type();
|
||||
PNMFileTypePNM::register_with_read_factory();
|
||||
tr->register_type(new PNMFileTypePNM);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_JPEG
|
||||
PNMFileTypeJPG::init_type();
|
||||
PNMFileTypeJPG::register_with_read_factory();
|
||||
tr->register_type(new PNMFileTypeJPG);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PNG
|
||||
PNMFileTypePNG::init_type();
|
||||
PNMFileTypePNG::register_with_read_factory();
|
||||
tr->register_type(new PNMFileTypePNG);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TIFF
|
||||
PNMFileTypeTIFF::init_type();
|
||||
PNMFileTypeTIFF::register_with_read_factory();
|
||||
tr->register_type(new PNMFileTypeTIFF);
|
||||
#endif
|
||||
|
||||
// And register with the PandaSystem.
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include "sgi.h"
|
||||
|
||||
NotifyCategoryDecl(pnmimage_sgi, EXPCL_PANDA_PNMIMAGETYPES, EXPTP_PANDA_PNMIMAGETYPES);
|
||||
NotifyCategoryDecl(pnmimage_alias, EXPCL_PANDA_PNMIMAGETYPES, EXPTP_PANDA_PNMIMAGETYPES);
|
||||
NotifyCategoryDecl(pnmimage_tiff, EXPCL_PANDA_PNMIMAGETYPES, EXPTP_PANDA_PNMIMAGETYPES);
|
||||
NotifyCategoryDecl(pnmimage_tga, EXPCL_PANDA_PNMIMAGETYPES, EXPTP_PANDA_PNMIMAGETYPES);
|
||||
NotifyCategoryDecl(pnmimage_img, EXPCL_PANDA_PNMIMAGETYPES, EXPTP_PANDA_PNMIMAGETYPES);
|
||||
|
@ -1,416 +0,0 @@
|
||||
// Filename: pnmFileTypeAlias.cxx
|
||||
// Created by: drose (17Jun00)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
//
|
||||
// All use of this software is subject to the terms of the revised BSD
|
||||
// license. You should have received a copy of this license along
|
||||
// with this source code in a file named "LICENSE."
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pnmFileTypeAlias.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
|
||||
// little sanity check on the size of the image. If either the width
|
||||
// or height is larger than this, it must be bogus.
|
||||
#define INSANE_SIZE 20000
|
||||
|
||||
static const char * const extensions_alias[] = {
|
||||
"pix", "als"
|
||||
};
|
||||
static const int num_extensions_alias = sizeof(extensions_alias) / sizeof(const char *);
|
||||
|
||||
TypeHandle PNMFileTypeAlias::_type_handle;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PNMFileTypeAlias::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PNMFileTypeAlias::
|
||||
PNMFileTypeAlias() {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PNMFileTypeAlias::get_name
|
||||
// Access: Public, Virtual
|
||||
// Description: Returns a few words describing the file type.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
string PNMFileTypeAlias::
|
||||
get_name() const {
|
||||
return "Alias";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PNMFileTypeAlias::get_num_extensions
|
||||
// Access: Public, Virtual
|
||||
// Description: Returns the number of different possible filename
|
||||
// extensions associated with this particular file type.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int PNMFileTypeAlias::
|
||||
get_num_extensions() const {
|
||||
return num_extensions_alias;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PNMFileTypeAlias::get_extension
|
||||
// Access: Public, Virtual
|
||||
// Description: Returns the nth possible filename extension
|
||||
// associated with this particular file type, without a
|
||||
// leading dot.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
string PNMFileTypeAlias::
|
||||
get_extension(int n) const {
|
||||
nassertr(n >= 0 && n < num_extensions_alias, string());
|
||||
return extensions_alias[n];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PNMFileTypeAlias::get_suggested_extension
|
||||
// Access: Public, Virtual
|
||||
// Description: Returns a suitable filename extension (without a
|
||||
// leading dot) to suggest for files of this type, or
|
||||
// empty string if no suggestions are available.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
string PNMFileTypeAlias::
|
||||
get_suggested_extension() const {
|
||||
return "pix";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PNMFileTypeAlias::make_reader
|
||||
// Access: Public, Virtual
|
||||
// Description: Allocates and returns a new PNMReader suitable for
|
||||
// reading from this file type, if possible. If reading
|
||||
// from this file type is not supported, returns NULL.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PNMReader *PNMFileTypeAlias::
|
||||
make_reader(istream *file, bool owns_file, const string &magic_number) {
|
||||
init_pnm();
|
||||
return new Reader(this, file, owns_file, magic_number);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PNMFileTypeAlias::make_writer
|
||||
// Access: Public, Virtual
|
||||
// Description: Allocates and returns a new PNMWriter suitable for
|
||||
// reading from this file type, if possible. If writing
|
||||
// files of this type is not supported, returns NULL.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PNMWriter *PNMFileTypeAlias::
|
||||
make_writer(ostream *file, bool owns_file) {
|
||||
init_pnm();
|
||||
return new Writer(this, file, owns_file);
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline unsigned short
|
||||
read_ushort(istream *file) {
|
||||
unsigned short x;
|
||||
return pm_readbigshort(file, (short *)&x)==0 ? x : 0;
|
||||
}
|
||||
|
||||
inline unsigned char
|
||||
read_uchar_ALIAS(istream *file) {
|
||||
int x;
|
||||
x = file->get();
|
||||
return (x!=EOF) ? (unsigned char)x : 0;
|
||||
}
|
||||
|
||||
inline void
|
||||
write_ushort(ostream *file, unsigned short x) {
|
||||
pm_writebigshort(file, (short)x);
|
||||
}
|
||||
|
||||
inline void
|
||||
write_uchar_ALIAS(ostream *file, unsigned char x) {
|
||||
file->put(x);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PNMFileTypeAlias::Reader::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PNMFileTypeAlias::Reader::
|
||||
Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) :
|
||||
PNMReader(type, file, owns_file)
|
||||
{
|
||||
if (!read_magic_number(_file, magic_number, 4)) {
|
||||
// Although Alias files have no magic number, they do have a
|
||||
// number of ushorts at the beginning. If these aren't present,
|
||||
// we have a problem.
|
||||
if (pnmimage_alias_cat.is_debug()) {
|
||||
pnmimage_alias_cat.debug()
|
||||
<< "Alias image file appears to be empty.\n";
|
||||
}
|
||||
_is_valid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
_x_size =
|
||||
((unsigned char)magic_number[0] << 8) |
|
||||
((unsigned char)magic_number[1]);
|
||||
_y_size =
|
||||
((unsigned char)magic_number[2] << 8) |
|
||||
((unsigned char)magic_number[3]);
|
||||
|
||||
if (_x_size == 0 || _y_size == 0 ||
|
||||
_x_size > INSANE_SIZE || _y_size > INSANE_SIZE) {
|
||||
_is_valid = false;
|
||||
pnmimage_alias_cat.debug()
|
||||
<< "File is not a valid Alias image.\n";
|
||||
return;
|
||||
}
|
||||
|
||||
read_ushort(_file);
|
||||
read_ushort(_file);
|
||||
|
||||
int bpp = read_ushort(_file);
|
||||
|
||||
switch (bpp) {
|
||||
case 8:
|
||||
_num_channels = 1;
|
||||
break;
|
||||
|
||||
case 24:
|
||||
_num_channels = 3;
|
||||
break;
|
||||
|
||||
default:
|
||||
_is_valid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
_maxval = 255;
|
||||
|
||||
if (pnmimage_alias_cat.is_debug()) {
|
||||
pnmimage_alias_cat.debug()
|
||||
<< "Reading Alias " << *this << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PNMFileTypeAlias::Reader::supports_read_row
|
||||
// Access: Public, Virtual
|
||||
// Description: Returns true if this particular PNMReader supports a
|
||||
// streaming interface to reading the data: that is, it
|
||||
// is capable of returning the data one row at a time,
|
||||
// via repeated calls to read_row(). Returns false if
|
||||
// the only way to read from this file is all at once,
|
||||
// via read_data().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool PNMFileTypeAlias::Reader::
|
||||
supports_read_row() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PNMFileTypeAlias::Reader::read_row
|
||||
// Access: Public, Virtual
|
||||
// Description: If supports_read_row(), above, returns true, this
|
||||
// function may be called repeatedly to read the image,
|
||||
// one horizontal row at a time, beginning from the top.
|
||||
// Returns true if the row is successfully read, false
|
||||
// if there is an error or end of file.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool PNMFileTypeAlias::Reader::
|
||||
read_row(xel *row_data, xelval *, int x_size, int) {
|
||||
if (!is_valid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int x;
|
||||
int num;
|
||||
unsigned char red, grn, blu;
|
||||
|
||||
x = 0;
|
||||
while (x < x_size) {
|
||||
num = read_uchar_ALIAS(_file);
|
||||
if (num==0 || x+num > x_size) {
|
||||
return false;
|
||||
}
|
||||
blu = read_uchar_ALIAS(_file);
|
||||
|
||||
if (get_color_type() == PNMImageHeader::CT_color) {
|
||||
grn = read_uchar_ALIAS(_file);
|
||||
red = read_uchar_ALIAS(_file);
|
||||
while (num>0) {
|
||||
PPM_ASSIGN(row_data[x], red, grn, blu);
|
||||
x++;
|
||||
num--;
|
||||
}
|
||||
} else {
|
||||
while (num>0) {
|
||||
PPM_PUTB(row_data[x], blu);
|
||||
x++;
|
||||
num--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static unsigned char last_red = 0, last_blu = 0, last_grn = 0;
|
||||
static int num_count = 0;
|
||||
|
||||
static void
|
||||
flush_color(ostream *file) {
|
||||
if (num_count>0) {
|
||||
write_uchar_ALIAS(file, num_count);
|
||||
write_uchar_ALIAS(file, last_blu);
|
||||
write_uchar_ALIAS(file, last_grn);
|
||||
write_uchar_ALIAS(file, last_red);
|
||||
num_count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
write_color(ostream *file,
|
||||
unsigned char red, unsigned char blu, unsigned char grn) {
|
||||
if (red==last_red && blu==last_blu && grn==last_grn && num_count<0377) {
|
||||
num_count++;
|
||||
} else {
|
||||
flush_color(file);
|
||||
last_red = red;
|
||||
last_grn = grn;
|
||||
last_blu = blu;
|
||||
num_count = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PNMFileTypeAlias::Writer::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PNMFileTypeAlias::Writer::
|
||||
Writer(PNMFileType *type, ostream *file, bool owns_file) :
|
||||
PNMWriter(type, file, owns_file)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PNMFileTypeAlias::Writer::supports_write_row
|
||||
// Access: Public, Virtual
|
||||
// Description: Returns true if this particular PNMWriter supports a
|
||||
// streaming interface to writing the data: that is, it
|
||||
// is capable of writing the image one row at a time,
|
||||
// via repeated calls to write_row(). Returns false if
|
||||
// the only way to write from this file is all at once,
|
||||
// via write_data().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool PNMFileTypeAlias::Writer::
|
||||
supports_write_row() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PNMFileTypeAlias::Writer::write_header
|
||||
// Access: Public, Virtual
|
||||
// Description: If supports_write_row(), above, returns true, this
|
||||
// function may be called to write out the image header
|
||||
// in preparation to writing out the image data one row
|
||||
// at a time. Returns true if the header is
|
||||
// successfully written, false if there is an error.
|
||||
//
|
||||
// It is the user's responsibility to fill in the header
|
||||
// data via calls to set_x_size(), set_num_channels(),
|
||||
// etc., or copy_header_from(), before calling
|
||||
// write_header().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool PNMFileTypeAlias::Writer::
|
||||
write_header() {
|
||||
write_ushort(_file, _x_size);
|
||||
write_ushort(_file, _y_size);
|
||||
|
||||
write_ushort(_file, 0);
|
||||
write_ushort(_file, 0);
|
||||
|
||||
// We'll always write full-color Alias images, even if the source
|
||||
// was grayscale. Many programs don't seem to understand grayscale
|
||||
// Alias images.
|
||||
write_ushort(_file, 24);
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PNMFileTypeAlias::Writer::write_row
|
||||
// Access: Public, Virtual
|
||||
// Description: If supports_write_row(), above, returns true, this
|
||||
// function may be called repeatedly to write the image,
|
||||
// one horizontal row at a time, beginning from the top.
|
||||
// Returns true if the row is successfully written,
|
||||
// false if there is an error.
|
||||
//
|
||||
// You must first call write_header() before writing the
|
||||
// individual rows. It is also important to delete the
|
||||
// PNMWriter class after successfully writing the last
|
||||
// row. Failing to do this may result in some data not
|
||||
// getting flushed!
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool PNMFileTypeAlias::Writer::
|
||||
write_row(xel *row_data, xelval *) {
|
||||
int x;
|
||||
unsigned char red, grn, blu;
|
||||
|
||||
bool grayscale = is_grayscale();
|
||||
|
||||
for (x = 0; x < _x_size; x++) {
|
||||
if (grayscale) {
|
||||
red = grn = blu = (unsigned char)(255*PPM_GETB(row_data[x]) / _maxval);
|
||||
} else {
|
||||
red = (unsigned char)(255*PPM_GETR(row_data[x]) / _maxval);
|
||||
grn = (unsigned char)(255*PPM_GETG(row_data[x]) / _maxval);
|
||||
blu = (unsigned char)(255*PPM_GETB(row_data[x]) / _maxval);
|
||||
}
|
||||
|
||||
write_color(_file, red, blu, grn);
|
||||
}
|
||||
flush_color(_file);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// 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.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
TypedWritable *PNMFileTypeAlias::
|
||||
make_PNMFileTypeAlias(const FactoryParams ¶ms) {
|
||||
return PNMFileTypeRegistry::get_global_ptr()->get_type_by_handle(get_class_type());
|
||||
}
|
@ -1,88 +0,0 @@
|
||||
// Filename: pnmFileTypeAlias.h
|
||||
// Created by: drose (17Jun00)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
//
|
||||
// All use of this software is subject to the terms of the revised BSD
|
||||
// license. You should have received a copy of this license along
|
||||
// with this source code in a file named "LICENSE."
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef PNMFILETYPEALIAS_H
|
||||
#define PNMFILETYPEALIAS_H
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#include "pnmFileType.h"
|
||||
#include "pnmReader.h"
|
||||
#include "pnmWriter.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : PNMFileTypeAlias
|
||||
// Description : For reading and Alias native image files.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDA_PNMIMAGETYPES PNMFileTypeAlias : public PNMFileType {
|
||||
public:
|
||||
PNMFileTypeAlias();
|
||||
|
||||
virtual string get_name() const;
|
||||
|
||||
virtual int get_num_extensions() const;
|
||||
virtual string get_extension(int n) const;
|
||||
virtual string get_suggested_extension() const;
|
||||
|
||||
virtual PNMReader *make_reader(istream *file, bool owns_file = true,
|
||||
const string &magic_number = string());
|
||||
virtual PNMWriter *make_writer(ostream *file, bool owns_file = true);
|
||||
|
||||
public:
|
||||
class Reader : public PNMReader {
|
||||
public:
|
||||
Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number);
|
||||
|
||||
virtual bool supports_read_row() const;
|
||||
virtual bool read_row(xel *array, xelval *alpha, int x_size, int y_size);
|
||||
};
|
||||
|
||||
class Writer : public PNMWriter {
|
||||
public:
|
||||
Writer(PNMFileType *type, ostream *file, bool owns_file);
|
||||
|
||||
virtual bool supports_write_row() const;
|
||||
virtual bool write_header();
|
||||
virtual bool write_row(xel *array, xelval *alpha);
|
||||
};
|
||||
|
||||
|
||||
// The TypedWritable interface follows.
|
||||
public:
|
||||
static void register_with_read_factory();
|
||||
|
||||
protected:
|
||||
static TypedWritable *make_PNMFileTypeAlias(const FactoryParams ¶ms);
|
||||
|
||||
public:
|
||||
static TypeHandle get_class_type() {
|
||||
return _type_handle;
|
||||
}
|
||||
static void init_type() {
|
||||
PNMFileType::init_type();
|
||||
register_type(_type_handle, "PNMFileTypeAlias",
|
||||
PNMFileType::get_class_type());
|
||||
}
|
||||
virtual TypeHandle get_type() const {
|
||||
return get_class_type();
|
||||
}
|
||||
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
|
||||
|
||||
private:
|
||||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -13,6 +13,9 @@
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pnmFileTypeBMP.h"
|
||||
|
||||
#ifdef HAVE_BMP
|
||||
|
||||
#include "config_pnmimagetypes.h"
|
||||
|
||||
#include "pnmFileTypeRegistry.h"
|
||||
@ -159,3 +162,5 @@ TypedWritable *PNMFileTypeBMP::
|
||||
make_PNMFileTypeBMP(const FactoryParams ¶ms) {
|
||||
return PNMFileTypeRegistry::get_global_ptr()->get_type_by_handle(get_class_type());
|
||||
}
|
||||
|
||||
#endif // HAVE_BMP
|
||||
|
@ -17,6 +17,8 @@
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#ifdef HAVE_BMP
|
||||
|
||||
#include "pnmFileType.h"
|
||||
#include "pnmReader.h"
|
||||
#include "pnmWriter.h"
|
||||
@ -96,6 +98,6 @@ private:
|
||||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#endif // HAVE_BMP
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -13,6 +13,9 @@
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pnmFileTypeBMP.h"
|
||||
|
||||
#ifdef HAVE_BMP
|
||||
|
||||
#include "config_pnmimagetypes.h"
|
||||
#include "bmp.h"
|
||||
#include "pnmbitio.h"
|
||||
@ -507,3 +510,5 @@ read_data(xel *array, xelval *) {
|
||||
|
||||
return _y_size;
|
||||
}
|
||||
|
||||
#endif // HAVE_BMP
|
||||
|
@ -13,6 +13,9 @@
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pnmFileTypeBMP.h"
|
||||
|
||||
#ifdef HAVE_BMP
|
||||
|
||||
#include "config_pnmimagetypes.h"
|
||||
|
||||
#include "pnmImage.h"
|
||||
@ -630,3 +633,5 @@ write_data(xel *array, xelval *) {
|
||||
|
||||
return _y_size;
|
||||
}
|
||||
|
||||
#endif // HAVE_BMP
|
||||
|
@ -13,6 +13,9 @@
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pnmFileTypeIMG.h"
|
||||
|
||||
#ifdef HAVE_IMG
|
||||
|
||||
#include "config_pnmimagetypes.h"
|
||||
|
||||
#include "pnmFileTypeRegistry.h"
|
||||
@ -373,3 +376,5 @@ TypedWritable *PNMFileTypeIMG::
|
||||
make_PNMFileTypeIMG(const FactoryParams ¶ms) {
|
||||
return PNMFileTypeRegistry::get_global_ptr()->get_type_by_handle(get_class_type());
|
||||
}
|
||||
|
||||
#endif // HAVE_IMG
|
||||
|
@ -17,6 +17,8 @@
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#ifdef HAVE_IMG
|
||||
|
||||
#include "pnmFileType.h"
|
||||
#include "pnmReader.h"
|
||||
#include "pnmWriter.h"
|
||||
@ -83,6 +85,8 @@ private:
|
||||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#endif // HAVE_IMG
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -13,6 +13,9 @@
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pnmFileTypePNM.h"
|
||||
|
||||
#ifdef HAVE_PNM
|
||||
|
||||
#include "config_pnmimagetypes.h"
|
||||
|
||||
#include "pnmFileTypeRegistry.h"
|
||||
@ -1273,3 +1276,5 @@ TypedWritable *PNMFileTypePNM::
|
||||
make_PNMFileTypePNM(const FactoryParams ¶ms) {
|
||||
return PNMFileTypeRegistry::get_global_ptr()->get_type_by_handle(get_class_type());
|
||||
}
|
||||
|
||||
#endif // HAVE_PNM
|
||||
|
@ -17,6 +17,8 @@
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#ifdef HAVE_PNM
|
||||
|
||||
#include "pnmFileType.h"
|
||||
#include "pnmReader.h"
|
||||
#include "pnmWriter.h"
|
||||
@ -93,6 +95,8 @@ private:
|
||||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#endif // HAVE_PNM
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -13,6 +13,9 @@
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pnmFileTypeSGI.h"
|
||||
|
||||
#ifdef HAVE_SGI_RGB
|
||||
|
||||
#include "config_pnmimagetypes.h"
|
||||
#include "sgi.h"
|
||||
|
||||
@ -163,3 +166,5 @@ TypedWritable *PNMFileTypeSGI::
|
||||
make_PNMFileTypeSGI(const FactoryParams ¶ms) {
|
||||
return PNMFileTypeRegistry::get_global_ptr()->get_type_by_handle(get_class_type());
|
||||
}
|
||||
|
||||
#endif // HAVE_SGI_RGB
|
||||
|
@ -17,6 +17,8 @@
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#ifdef HAVE_SGI_RGB
|
||||
|
||||
#include "pnmFileType.h"
|
||||
#include "pnmReader.h"
|
||||
#include "pnmWriter.h"
|
||||
@ -131,6 +133,8 @@ private:
|
||||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#endif // HAVE_SGI_RGB
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -13,6 +13,9 @@
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pnmFileTypeSGI.h"
|
||||
|
||||
#ifdef HAVE_SGI_RGB
|
||||
|
||||
#include "config_pnmimagetypes.h"
|
||||
#include "sgi.h"
|
||||
|
||||
@ -515,3 +518,4 @@ compression_name(char compr) {
|
||||
}
|
||||
}
|
||||
|
||||
#endif // HAVE_SGI_RGB
|
||||
|
@ -13,6 +13,9 @@
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pnmFileTypeSGI.h"
|
||||
|
||||
#ifdef HAVE_SGI_RGB
|
||||
|
||||
#include "config_pnmimagetypes.h"
|
||||
#include "sgi.h"
|
||||
|
||||
@ -368,3 +371,4 @@ rle_compress(ScanElem *inbuf, int size) {
|
||||
return(out);
|
||||
}
|
||||
|
||||
#endif // HAVE_SGI_RGB
|
||||
|
@ -13,6 +13,9 @@
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pnmFileTypeSoftImage.h"
|
||||
|
||||
#ifdef HAVE_SOFTIMAGE_PIC
|
||||
|
||||
#include "config_pnmimagetypes.h"
|
||||
|
||||
#include "pnmFileTypeRegistry.h"
|
||||
@ -787,3 +790,5 @@ TypedWritable *PNMFileTypeSoftImage::
|
||||
make_PNMFileTypeSoftImage(const FactoryParams ¶ms) {
|
||||
return PNMFileTypeRegistry::get_global_ptr()->get_type_by_handle(get_class_type());
|
||||
}
|
||||
|
||||
#endif // HAVE_SOFTIMAGE_PIC
|
||||
|
@ -17,6 +17,8 @@
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#ifdef HAVE_SOFTIMAGE_PIC
|
||||
|
||||
#include "pnmFileType.h"
|
||||
#include "pnmReader.h"
|
||||
#include "pnmWriter.h"
|
||||
@ -90,6 +92,8 @@ private:
|
||||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#endif // HAVE_SOFTIMAGE_PIC
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -43,6 +43,9 @@
|
||||
*/
|
||||
|
||||
#include "pnmFileTypeTGA.h"
|
||||
|
||||
#ifdef HAVE_TGA
|
||||
|
||||
#include "config_pnmimagetypes.h"
|
||||
|
||||
#include "pnmFileTypeRegistry.h"
|
||||
@ -940,3 +943,5 @@ put_rgb( pixel* pP, pixval maxval ) {
|
||||
_file->put( PPM_GETR( p ) );
|
||||
}
|
||||
}
|
||||
|
||||
#endif // HAVE_TGA
|
||||
|
@ -17,6 +17,8 @@
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#ifdef HAVE_TGA
|
||||
|
||||
#include "pnmFileType.h"
|
||||
#include "pnmReader.h"
|
||||
#include "pnmWriter.h"
|
||||
@ -117,6 +119,8 @@ private:
|
||||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#endif // HAVE_TGA
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "config_pnmimagetypes.cxx"
|
||||
#include "pnmFileTypeAlias.cxx"
|
||||
#include "pnmFileTypeBMPReader.cxx"
|
||||
#include "pnmFileTypeBMPWriter.cxx"
|
||||
#include "pnmFileTypeIMG.cxx"
|
||||
|
Loading…
x
Reference in New Issue
Block a user