mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
*** empty log message ***
This commit is contained in:
parent
173d6df423
commit
5e2c066e84
@ -1026,9 +1026,10 @@ rotate_mat(NumType angle, LVecBase3<NumType> axis,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Normalize the axis.
|
// Normalize the axis.
|
||||||
NumType length = axis.dot(axis);
|
NumType length2 = axis.dot(axis);
|
||||||
nassertr(length != 0.0, ident_mat());
|
// Cannot rotate about a zero-length axis.
|
||||||
axis /= length;
|
nassertr(length2 != 0.0, ident_mat());
|
||||||
|
axis /= csqrt(length2);
|
||||||
|
|
||||||
double s = sin(deg_2_rad(angle));
|
double s = sin(deg_2_rad(angle));
|
||||||
double c = cos(deg_2_rad(angle));
|
double c = cos(deg_2_rad(angle));
|
||||||
|
@ -144,10 +144,10 @@ init_pnm() {
|
|||||||
|
|
||||||
pm_init(&argc, argv);
|
pm_init(&argc, argv);
|
||||||
|
|
||||||
// Now deallocate all the stuff we just allocated.
|
// We can delete the argv array itself, but we cannot free the
|
||||||
for (i = 0; i < argc; i++) {
|
// results of the strdup() calls we just made, since the pnm
|
||||||
delete[] argv[i];
|
// library might keep pointers to it. But this is a one-time
|
||||||
}
|
// leak.
|
||||||
delete[] argv;
|
delete[] argv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
/* Copyright (c) 1991 Regents of the University of California */
|
/* Copyright (c) 1991 Regents of the University of California */
|
||||||
|
|
||||||
#ifndef lint
|
|
||||||
static char SCCSid[] = "@(#)color.c 2.8 3/26/94 LBL";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* color.c - routines for color calculations.
|
* color.c - routines for color calculations.
|
||||||
*
|
*
|
||||||
@ -48,13 +44,13 @@ tempbuffer(unsigned len) /* get a temporary buffer */
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fwritecolrs(register COLR *scanline, unsigned len, register FILE *fp)
|
int fwritecolrs(register COLR *scanline, unsigned len, register FILE *fp)
|
||||||
/* write out a colr scanline */
|
/* write out a colr scanline */
|
||||||
{
|
{
|
||||||
register int i, j, beg, cnt;
|
register int i, j, beg, cnt;
|
||||||
int c2;
|
int c2;
|
||||||
|
|
||||||
if (len < MINELEN | len > MAXELEN) /* OOBs, write out flat */
|
if (len < MINELEN || len > MAXELEN) /* OOBs, write out flat */
|
||||||
return(fwrite((char *)scanline,sizeof(COLR),len,fp) - len);
|
return(fwrite((char *)scanline,sizeof(COLR),len,fp) - len);
|
||||||
/* put magic header */
|
/* put magic header */
|
||||||
putc(2, fp);
|
putc(2, fp);
|
||||||
@ -99,13 +95,13 @@ fwritecolrs(register COLR *scanline, unsigned len, register FILE *fp)
|
|||||||
|
|
||||||
int oldreadcolrs(register COLR *scanline, int len, register FILE *fp);
|
int oldreadcolrs(register COLR *scanline, int len, register FILE *fp);
|
||||||
|
|
||||||
freadcolrs(register COLR *scanline, int len, register FILE *fp)
|
int freadcolrs(register COLR *scanline, int len, register FILE *fp)
|
||||||
/* read in an encoded colr scanline */
|
/* read in an encoded colr scanline */
|
||||||
{
|
{
|
||||||
register int i, j;
|
register int i, j;
|
||||||
int code, val;
|
int code, val;
|
||||||
/* determine scanline type */
|
/* determine scanline type */
|
||||||
if (len < MINELEN | len > MAXELEN)
|
if (len < MINELEN || len > MAXELEN)
|
||||||
return(oldreadcolrs(scanline, len, fp));
|
return(oldreadcolrs(scanline, len, fp));
|
||||||
if ((i = getc(fp)) == EOF)
|
if ((i = getc(fp)) == EOF)
|
||||||
return(-1);
|
return(-1);
|
||||||
@ -177,7 +173,7 @@ int oldreadcolrs(register COLR *scanline, int len, register FILE *fp)
|
|||||||
|
|
||||||
|
|
||||||
/* write out a scanline */
|
/* write out a scanline */
|
||||||
fwritescan(register COLOR *scanline, int len, FILE *fp)
|
int fwritescan(register COLOR *scanline, int len, FILE *fp)
|
||||||
{
|
{
|
||||||
COLR *clrscan;
|
COLR *clrscan;
|
||||||
int n;
|
int n;
|
||||||
@ -199,7 +195,7 @@ fwritescan(register COLOR *scanline, int len, FILE *fp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
freadscan(register COLOR *scanline, int len, FILE *fp)
|
int freadscan(register COLOR *scanline, int len, FILE *fp)
|
||||||
/* read in a scanline */
|
/* read in a scanline */
|
||||||
{
|
{
|
||||||
register COLR *clrscan;
|
register COLR *clrscan;
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
/* Copyright (c) 1992 Regents of the University of California */
|
/* Copyright (c) 1992 Regents of the University of California */
|
||||||
|
|
||||||
#ifndef lint
|
|
||||||
static char SCCSid[] = "@(#)colrops.c 2.4 10/2/92 LBL";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Integer operations on COLR scanlines
|
* Integer operations on COLR scanlines
|
||||||
*/
|
*/
|
||||||
@ -33,7 +29,7 @@ extern double pow(double, double);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
setcolrcor(double (*f)(double, double), double a2)
|
int setcolrcor(double (*f)(double, double), double a2)
|
||||||
/* set brightness correction */
|
/* set brightness correction */
|
||||||
{
|
{
|
||||||
double mult;
|
double mult;
|
||||||
@ -53,7 +49,7 @@ setcolrcor(double (*f)(double, double), double a2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
setcolrinv(double (*f)(double, double), double a2)
|
int setcolrinv(double (*f)(double, double), double a2)
|
||||||
/* set inverse brightness correction */
|
/* set inverse brightness correction */
|
||||||
{
|
{
|
||||||
double mult;
|
double mult;
|
||||||
@ -79,7 +75,7 @@ setcolrinv(double (*f)(double, double), double a2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
setcolrgam(double g) /* set gamma conversion */
|
int setcolrgam(double g) /* set gamma conversion */
|
||||||
{
|
{
|
||||||
if (setcolrcor(pow, 1.0/g) < 0)
|
if (setcolrcor(pow, 1.0/g) < 0)
|
||||||
return(-1);
|
return(-1);
|
||||||
@ -87,7 +83,7 @@ setcolrgam(double g) /* set gamma conversion */
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
colrs_gambs(register COLR *scan, int len)
|
int colrs_gambs(register COLR *scan, int len)
|
||||||
/* convert scanline of colrs to gamma bytes */
|
/* convert scanline of colrs to gamma bytes */
|
||||||
{
|
{
|
||||||
register int i, expo;
|
register int i, expo;
|
||||||
@ -135,12 +131,12 @@ colrs_gambs(register COLR *scan, int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
gambs_colrs(register COLR *scan, int len)
|
int gambs_colrs(register COLR *scan, int len)
|
||||||
/* convert gamma bytes to colr scanline */
|
/* convert gamma bytes to colr scanline */
|
||||||
{
|
{
|
||||||
register int nexpo;
|
register int nexpo;
|
||||||
|
|
||||||
if (g_mant == NULL | g_nexp == NULL)
|
if (g_mant == NULL || g_nexp == NULL)
|
||||||
return(-1);
|
return(-1);
|
||||||
while (len-- > 0) {
|
while (len-- > 0) {
|
||||||
nexpo = g_nexp[scan[0][RED]];
|
nexpo = g_nexp[scan[0][RED]];
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
/* Copyright (c) 1994 Regents of the University of California */
|
/* Copyright (c) 1994 Regents of the University of California */
|
||||||
|
|
||||||
#ifndef lint
|
|
||||||
static char SCCSid[] = "@(#)header.c 2.4 2/27/94 LBL";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* header.c - routines for reading and writing information headers.
|
* header.c - routines for reading and writing information headers.
|
||||||
*
|
*
|
||||||
@ -42,6 +38,7 @@ newheader(char *s, register FILE *fp) /* identifying line of information header
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
headidval(register char *r, register char *s) /* get header id (return true if is id) */
|
headidval(register char *r, register char *s) /* get header id (return true if is id) */
|
||||||
{
|
{
|
||||||
register char *cp = HDRSTR;
|
register char *cp = HDRSTR;
|
||||||
@ -54,6 +51,7 @@ headidval(register char *r, register char *s) /* get header id (return true if
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
isheadid(char *s) /* check to see if line is header id */
|
isheadid(char *s) /* check to see if line is header id */
|
||||||
{
|
{
|
||||||
return(headidval(NULL, s));
|
return(headidval(NULL, s));
|
||||||
@ -82,6 +80,7 @@ printargs(int ac, char **av, register FILE *fp) /* print arguments to a file */
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
formatval(register char *r, register char *s) /* get format value (return true if format) */
|
formatval(register char *r, register char *s) /* get format value (return true if format) */
|
||||||
{
|
{
|
||||||
register char *cp = FMTSTR;
|
register char *cp = FMTSTR;
|
||||||
@ -97,6 +96,7 @@ formatval(register char *r, register char *s) /* get format value (return true
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
isformat(char *s) /* is line a format line? */
|
isformat(char *s) /* is line a format line? */
|
||||||
{
|
{
|
||||||
return(formatval(NULL, s));
|
return(formatval(NULL, s));
|
||||||
@ -211,6 +211,7 @@ copymatch(char *pat, char *str)
|
|||||||
* if fout is not NULL.
|
* if fout is not NULL.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
checkheader(FILE *fin, char *fmt, FILE *fout)
|
checkheader(FILE *fin, char *fmt, FILE *fout)
|
||||||
{
|
{
|
||||||
struct check cdat;
|
struct check cdat;
|
||||||
|
@ -82,6 +82,7 @@ get_suggested_extension() const {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
PNMReader *PNMFileTypeAlias::
|
PNMReader *PNMFileTypeAlias::
|
||||||
make_reader(FILE *file, bool owns_file, const string &magic_number) {
|
make_reader(FILE *file, bool owns_file, const string &magic_number) {
|
||||||
|
init_pnm();
|
||||||
return new Reader(this, file, owns_file, magic_number);
|
return new Reader(this, file, owns_file, magic_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,6 +95,7 @@ make_reader(FILE *file, bool owns_file, const string &magic_number) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
PNMWriter *PNMFileTypeAlias::
|
PNMWriter *PNMFileTypeAlias::
|
||||||
make_writer(FILE *file, bool owns_file) {
|
make_writer(FILE *file, bool owns_file) {
|
||||||
|
init_pnm();
|
||||||
return new Writer(this, file, owns_file);
|
return new Writer(this, file, owns_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,6 +101,7 @@ matches_magic_number(const string &magic_number) const {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
PNMReader *PNMFileTypeBMP::
|
PNMReader *PNMFileTypeBMP::
|
||||||
make_reader(FILE *file, bool owns_file, const string &magic_number) {
|
make_reader(FILE *file, bool owns_file, const string &magic_number) {
|
||||||
|
init_pnm();
|
||||||
return new Reader(this, file, owns_file, magic_number);
|
return new Reader(this, file, owns_file, magic_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,6 +114,7 @@ make_reader(FILE *file, bool owns_file, const string &magic_number) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
PNMWriter *PNMFileTypeBMP::
|
PNMWriter *PNMFileTypeBMP::
|
||||||
make_writer(FILE *file, bool owns_file) {
|
make_writer(FILE *file, bool owns_file) {
|
||||||
|
init_pnm();
|
||||||
return new Writer(this, file, owns_file);
|
return new Writer(this, file, owns_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,8 +31,11 @@ extern "C" {
|
|||||||
* without express or implied warranty.
|
* without express or implied warranty.
|
||||||
*
|
*
|
||||||
* $Log$
|
* $Log$
|
||||||
* Revision 1.1 2000/10/04 01:14:42 drose
|
* Revision 1.2 2000/11/09 21:14:02 drose
|
||||||
* Initial revision
|
* *** empty log message ***
|
||||||
|
*
|
||||||
|
* Revision 1.1.1.1 2000/10/04 01:14:42 drose
|
||||||
|
*
|
||||||
*
|
*
|
||||||
* Revision 1.10 1992/11/24 19:38:17 dws
|
* Revision 1.10 1992/11/24 19:38:17 dws
|
||||||
* Added code to verify that reading occurred at the correct offsets.
|
* Added code to verify that reading occurred at the correct offsets.
|
||||||
@ -83,15 +86,10 @@ static void BMPreadinfoheader ARGS((FILE *fp, unsigned long *ppos,
|
|||||||
int *pclassv));
|
int *pclassv));
|
||||||
static int BMPreadrgbtable ARGS((FILE *fp, unsigned long *ppos,
|
static int BMPreadrgbtable ARGS((FILE *fp, unsigned long *ppos,
|
||||||
unsigned short cBitCount, int classv, pixval *R, pixval *G, pixval *B));
|
unsigned short cBitCount, int classv, pixval *R, pixval *G, pixval *B));
|
||||||
static int BMPreadrow ARGS((FILE *fp, unsigned long *ppos, pixel *row,
|
|
||||||
unsigned long cx, unsigned short cBitCount, pixval *R, pixval *G, pixval *B));
|
|
||||||
static pixel ** BMPreadbits ARGS((FILE *fp, unsigned long *ppos,
|
|
||||||
unsigned long offBits, unsigned long cx, unsigned long cy,
|
|
||||||
unsigned short cBitCount, int classv, pixval *R, pixval *G, pixval *B));
|
|
||||||
|
|
||||||
static const char *ifname = "BMP";
|
static const char *ifname = "BMP";
|
||||||
static char er_read[] = "%s: read error";
|
static char er_read[] = "%s: read error";
|
||||||
static char er_seek[] = "%s: seek error";
|
//static char er_seek[] = "%s: seek error";
|
||||||
|
|
||||||
static int
|
static int
|
||||||
GetByte(FILE *fp)
|
GetByte(FILE *fp)
|
||||||
@ -500,7 +498,7 @@ Reader(PNMFileType *type, FILE *file, bool owns_file, string magic_number) :
|
|||||||
indexed = true;
|
indexed = true;
|
||||||
rc = BMPreadrgbtable(file, &pos, cBitCount, classv, R, G, B);
|
rc = BMPreadrgbtable(file, &pos, cBitCount, classv, R, G, B);
|
||||||
|
|
||||||
if (rc != BMPlenrgbtable(classv, cBitCount)) {
|
if (rc != (int)BMPlenrgbtable(classv, cBitCount)) {
|
||||||
pnmimage_bmp_cat.warning()
|
pnmimage_bmp_cat.warning()
|
||||||
<< rc << "-byte RGB table, expected "
|
<< rc << "-byte RGB table, expected "
|
||||||
<< BMPlenrgbtable(classv, cBitCount) << " bytes\n";
|
<< BMPlenrgbtable(classv, cBitCount) << " bytes\n";
|
||||||
|
@ -35,8 +35,11 @@ extern "C" {
|
|||||||
* without express or implied warranty.
|
* without express or implied warranty.
|
||||||
*
|
*
|
||||||
* $Log$
|
* $Log$
|
||||||
* Revision 1.1 2000/10/04 01:14:42 drose
|
* Revision 1.2 2000/11/09 21:14:02 drose
|
||||||
* Initial revision
|
* *** empty log message ***
|
||||||
|
*
|
||||||
|
* Revision 1.1.1.1 2000/10/04 01:14:42 drose
|
||||||
|
*
|
||||||
*
|
*
|
||||||
* Revision 1.9 1992/11/24 19:39:33 dws
|
* Revision 1.9 1992/11/24 19:39:33 dws
|
||||||
* Added copyright.
|
* Added copyright.
|
||||||
@ -85,10 +88,6 @@ static int BMPwriteinfoheader ARGS((FILE *fp, int classv, unsigned long bitcount
|
|||||||
static int BMPwritergb ARGS((FILE *fp, int classv, pixval R, pixval G, pixval B));
|
static int BMPwritergb ARGS((FILE *fp, int classv, pixval R, pixval G, pixval B));
|
||||||
static int BMPwritergbtable ARGS((FILE *fp, int classv, int bpp, int colors,
|
static int BMPwritergbtable ARGS((FILE *fp, int classv, int bpp, int colors,
|
||||||
pixval *R, pixval *G, pixval *B));
|
pixval *R, pixval *G, pixval *B));
|
||||||
static int BMPwriterow ARGS((FILE *fp, pixel *row, unsigned long cx,
|
|
||||||
unsigned short bpp, colorhash_table cht));
|
|
||||||
static int BMPwritebits ARGS((FILE *fp, unsigned long cx, unsigned long cy,
|
|
||||||
unsigned short cBitCount, pixel **pixels, colorhash_table cht));
|
|
||||||
static int colorstobpp ARGS((int colors));
|
static int colorstobpp ARGS((int colors));
|
||||||
static void BMPEncode ARGS((FILE *fp, int classv, int x, int y, pixel **pixels,
|
static void BMPEncode ARGS((FILE *fp, int classv, int x, int y, pixel **pixels,
|
||||||
int colors, colorhash_table cht, pixval *R, pixval *G, pixval *B));
|
int colors, colorhash_table cht, pixval *R, pixval *G, pixval *B));
|
||||||
|
@ -82,6 +82,7 @@ get_suggested_extension() const {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
PNMReader *PNMFileTypeIMG::
|
PNMReader *PNMFileTypeIMG::
|
||||||
make_reader(FILE *file, bool owns_file, const string &magic_number) {
|
make_reader(FILE *file, bool owns_file, const string &magic_number) {
|
||||||
|
init_pnm();
|
||||||
return new Reader(this, file, owns_file, magic_number);
|
return new Reader(this, file, owns_file, magic_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,6 +95,7 @@ make_reader(FILE *file, bool owns_file, const string &magic_number) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
PNMWriter *PNMFileTypeIMG::
|
PNMWriter *PNMFileTypeIMG::
|
||||||
make_writer(FILE *file, bool owns_file) {
|
make_writer(FILE *file, bool owns_file) {
|
||||||
|
init_pnm();
|
||||||
return new Writer(this, file, owns_file);
|
return new Writer(this, file, owns_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,6 +112,7 @@ matches_magic_number(const string &magic_number) const {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
PNMReader *PNMFileTypePNM::
|
PNMReader *PNMFileTypePNM::
|
||||||
make_reader(FILE *file, bool owns_file, const string &magic_number) {
|
make_reader(FILE *file, bool owns_file, const string &magic_number) {
|
||||||
|
init_pnm();
|
||||||
return new Reader(this, file, owns_file, magic_number);
|
return new Reader(this, file, owns_file, magic_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,6 +125,7 @@ make_reader(FILE *file, bool owns_file, const string &magic_number) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
PNMWriter *PNMFileTypePNM::
|
PNMWriter *PNMFileTypePNM::
|
||||||
make_writer(FILE *file, bool owns_file) {
|
make_writer(FILE *file, bool owns_file) {
|
||||||
|
init_pnm();
|
||||||
return new Writer(this, file, owns_file);
|
return new Writer(this, file, owns_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,6 +286,9 @@ write_header() {
|
|||||||
case PNMImageHeader::CT_four_channel:
|
case PNMImageHeader::CT_four_channel:
|
||||||
_pnm_format = PPM_TYPE;
|
_pnm_format = PPM_TYPE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
pnm_writepnminit(_file, _x_size, _y_size, _maxval, _pnm_format, 0);
|
pnm_writepnminit(_file, _x_size, _y_size, _maxval, _pnm_format, 0);
|
||||||
|
@ -121,6 +121,7 @@ matches_magic_number(const string &magic_number) const {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
PNMReader *PNMFileTypeRadiance::
|
PNMReader *PNMFileTypeRadiance::
|
||||||
make_reader(FILE *file, bool owns_file, const string &magic_number) {
|
make_reader(FILE *file, bool owns_file, const string &magic_number) {
|
||||||
|
init_pnm();
|
||||||
return new Reader(this, file, owns_file, magic_number);
|
return new Reader(this, file, owns_file, magic_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,6 +134,7 @@ make_reader(FILE *file, bool owns_file, const string &magic_number) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
PNMWriter *PNMFileTypeRadiance::
|
PNMWriter *PNMFileTypeRadiance::
|
||||||
make_writer(FILE *file, bool owns_file) {
|
make_writer(FILE *file, bool owns_file) {
|
||||||
|
init_pnm();
|
||||||
return new Writer(this, file, owns_file);
|
return new Writer(this, file, owns_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,6 +105,7 @@ matches_magic_number(const string &magic_number) const {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
PNMReader *PNMFileTypeSGI::
|
PNMReader *PNMFileTypeSGI::
|
||||||
make_reader(FILE *file, bool owns_file, const string &magic_number) {
|
make_reader(FILE *file, bool owns_file, const string &magic_number) {
|
||||||
|
init_pnm();
|
||||||
return new Reader(this, file, owns_file, magic_number);
|
return new Reader(this, file, owns_file, magic_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,6 +118,7 @@ make_reader(FILE *file, bool owns_file, const string &magic_number) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
PNMWriter *PNMFileTypeSGI::
|
PNMWriter *PNMFileTypeSGI::
|
||||||
make_writer(FILE *file, bool owns_file) {
|
make_writer(FILE *file, bool owns_file) {
|
||||||
|
init_pnm();
|
||||||
return new Writer(this, file, owns_file);
|
return new Writer(this, file, owns_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ static void * xmalloc (int bytes);
|
|||||||
#define MALLOC(n, type) (type *)xmalloc((n) * sizeof(type))
|
#define MALLOC(n, type) (type *)xmalloc((n) * sizeof(type))
|
||||||
static char * compression_name (char compr);
|
static char * compression_name (char compr);
|
||||||
static void read_bytes (FILE *ifp, int n, char *buf);
|
static void read_bytes (FILE *ifp, int n, char *buf);
|
||||||
static void read_header(FILE *ifp, Header *head, const string &magic_number);
|
static bool read_header(FILE *ifp, Header *head, const string &magic_number);
|
||||||
static TabEntry * read_table (FILE *ifp, int tablen);
|
static TabEntry * read_table (FILE *ifp, int tablen);
|
||||||
static void read_channel (FILE *ifp, int xsize, int ysize,
|
static void read_channel (FILE *ifp, int xsize, int ysize,
|
||||||
int zsize, int bpc, TabEntry *table,
|
int zsize, int bpc, TabEntry *table,
|
||||||
@ -91,7 +91,9 @@ Reader(PNMFileType *type, FILE *file, bool owns_file, string magic_number) :
|
|||||||
|
|
||||||
Header head;
|
Header head;
|
||||||
|
|
||||||
::read_header(file, &head, magic_number);
|
if (!::read_header(file, &head, magic_number)) {
|
||||||
|
_is_valid = false;
|
||||||
|
}
|
||||||
|
|
||||||
long pixmax = (head.bpc == 1) ? MAXVAL_BYTE : MAXVAL_WORD;
|
long pixmax = (head.bpc == 1) ? MAXVAL_BYTE : MAXVAL_WORD;
|
||||||
if( pixmax > PNM_MAXMAXVAL ) {
|
if( pixmax > PNM_MAXMAXVAL ) {
|
||||||
@ -115,7 +117,7 @@ Reader(PNMFileType *type, FILE *file, bool owns_file, string magic_number) :
|
|||||||
|
|
||||||
current_row = _y_size - 1;
|
current_row = _y_size - 1;
|
||||||
|
|
||||||
if (pnmimage_sgi_cat.is_debug()) {
|
if (_is_valid && pnmimage_sgi_cat.is_debug()) {
|
||||||
head.name[79] = '\0'; /* just to be safe */
|
head.name[79] = '\0'; /* just to be safe */
|
||||||
pnmimage_sgi_cat.debug()
|
pnmimage_sgi_cat.debug()
|
||||||
<< "Read RGB image:\n"
|
<< "Read RGB image:\n"
|
||||||
@ -214,9 +216,9 @@ read_row(xel *row_data, xelval *alpha_data) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static bool
|
||||||
read_header(FILE *ifp, Header *head, const string &magic_number) {
|
read_header(FILE *ifp, Header *head, const string &magic_number) {
|
||||||
nassertv(magic_number.size() == 4);
|
nassertr(magic_number.size() == 4, false);
|
||||||
head->magic =
|
head->magic =
|
||||||
((unsigned char)magic_number[0] << 8) |
|
((unsigned char)magic_number[0] << 8) |
|
||||||
((unsigned char)magic_number[1]);
|
((unsigned char)magic_number[1]);
|
||||||
@ -233,15 +235,29 @@ read_header(FILE *ifp, Header *head, const string &magic_number) {
|
|||||||
head->colormap = get_big_long(ifp);
|
head->colormap = get_big_long(ifp);
|
||||||
read_bytes(ifp, 404, head->dummy2);
|
read_bytes(ifp, 404, head->dummy2);
|
||||||
|
|
||||||
if( head->magic != SGI_MAGIC )
|
if (head->magic != SGI_MAGIC) {
|
||||||
pm_error("bad magic number - not an SGI image");
|
pnmimage_sgi_cat.error()
|
||||||
if( head->storage != 0 && head->storage != 1 )
|
<< "Invalid magic number: not an SGI image file.\n";
|
||||||
pm_error("unknown compression type");
|
return false;
|
||||||
if( head->bpc < 1 || head->bpc > 2 )
|
}
|
||||||
pm_error("illegal precision value %d (only 1-2 allowed)", head->bpc );
|
|
||||||
if( head->colormap != CMAP_NORMAL )
|
if (head->storage != 0 && head->storage != 1) {
|
||||||
pm_message("unsupported non-normal pixel data (%d)",
|
pnmimage_sgi_cat.error()
|
||||||
head->colormap);
|
<< "Unknown compression type.\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (head->bpc < 1 || head->bpc > 2) {
|
||||||
|
pnmimage_sgi_cat.error()
|
||||||
|
<< "Illegal precision value " << head->bpc << " (only 1-2 allowed)\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (head->colormap != CMAP_NORMAL) {
|
||||||
|
pnmimage_sgi_cat.error()
|
||||||
|
<< "Unsupported non-normal pixel data (" << head->colormap << ")\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* adjust ysize/zsize to dimension, just to be sure */
|
/* adjust ysize/zsize to dimension, just to be sure */
|
||||||
switch( head->dimension ) {
|
switch( head->dimension ) {
|
||||||
@ -262,14 +278,20 @@ read_header(FILE *ifp, Header *head, const string &magic_number) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
pm_message("%d-channel image, using only first 4 channels", head->zsize);
|
pnmimage_sgi_cat.warning()
|
||||||
|
<< "Using only first 4 channels of " << head->zsize
|
||||||
|
<< "-channel image.\n";
|
||||||
head->zsize = 4;
|
head->zsize = 4;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
pm_error("illegal dimension value %d (only 1-3 allowed)", head->dimension);
|
pnmimage_sgi_cat.error()
|
||||||
|
<< "Illegal dimension value " << head->dimension
|
||||||
|
<< " (only 1-3 allowed)\n";
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -277,6 +277,7 @@ matches_magic_number(const string &magic_number) const {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
PNMReader *PNMFileTypeSoftImage::
|
PNMReader *PNMFileTypeSoftImage::
|
||||||
make_reader(FILE *file, bool owns_file, const string &magic_number) {
|
make_reader(FILE *file, bool owns_file, const string &magic_number) {
|
||||||
|
init_pnm();
|
||||||
return new Reader(this, file, owns_file, magic_number);
|
return new Reader(this, file, owns_file, magic_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,6 +290,7 @@ make_reader(FILE *file, bool owns_file, const string &magic_number) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
PNMWriter *PNMFileTypeSoftImage::
|
PNMWriter *PNMFileTypeSoftImage::
|
||||||
make_writer(FILE *file, bool owns_file) {
|
make_writer(FILE *file, bool owns_file) {
|
||||||
|
init_pnm();
|
||||||
return new Writer(this, file, owns_file);
|
return new Writer(this, file, owns_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,8 +346,8 @@ Reader(PNMFileType *type, FILE *file, bool owns_file, string magic_number) :
|
|||||||
_x_size = read_ushort(_file);
|
_x_size = read_ushort(_file);
|
||||||
_y_size = read_ushort(_file);
|
_y_size = read_ushort(_file);
|
||||||
|
|
||||||
float ratio = read_float(_file);
|
/* float ratio = */ read_float(_file);
|
||||||
int fields = read_ushort(_file);
|
/* int fields = */ read_ushort(_file);
|
||||||
read_ushort(_file);
|
read_ushort(_file);
|
||||||
|
|
||||||
int chained, size, channel;
|
int chained, size, channel;
|
||||||
@ -464,8 +466,11 @@ read_row(xel *row_data, xelval *alpha_data) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,6 +199,7 @@ matches_magic_number(const string &magic_number) const {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
PNMReader *PNMFileTypeTIFF::
|
PNMReader *PNMFileTypeTIFF::
|
||||||
make_reader(FILE *file, bool owns_file, const string &magic_number) {
|
make_reader(FILE *file, bool owns_file, const string &magic_number) {
|
||||||
|
init_pnm();
|
||||||
return new Reader(this, file, owns_file, magic_number);
|
return new Reader(this, file, owns_file, magic_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,6 +212,7 @@ make_reader(FILE *file, bool owns_file, const string &magic_number) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
PNMWriter *PNMFileTypeTIFF::
|
PNMWriter *PNMFileTypeTIFF::
|
||||||
make_writer(FILE *file, bool owns_file) {
|
make_writer(FILE *file, bool owns_file) {
|
||||||
|
init_pnm();
|
||||||
return new Writer(this, file, owns_file);
|
return new Writer(this, file, owns_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -608,6 +610,9 @@ write_data(xel *array, xelval *alpha) {
|
|||||||
chv = (colorhist_vector) 0;
|
chv = (colorhist_vector) 0;
|
||||||
grayscale = true;
|
grayscale = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Open output file. */
|
/* Open output file. */
|
||||||
@ -651,6 +656,9 @@ write_data(xel *array, xelval *alpha) {
|
|||||||
i = 8 / bitspersample;
|
i = 8 / bitspersample;
|
||||||
bytesperrow = ( _x_size + i - 1 ) / i;
|
bytesperrow = ( _x_size + i - 1 ) / i;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( tiff_rowsperstrip == 0 )
|
if ( tiff_rowsperstrip == 0 )
|
||||||
|
@ -125,6 +125,7 @@ get_suggested_extension() const {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
PNMReader *PNMFileTypeYUV::
|
PNMReader *PNMFileTypeYUV::
|
||||||
make_reader(FILE *file, bool owns_file, const string &magic_number) {
|
make_reader(FILE *file, bool owns_file, const string &magic_number) {
|
||||||
|
init_pnm();
|
||||||
return new Reader(this, file, owns_file, magic_number);
|
return new Reader(this, file, owns_file, magic_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,6 +138,7 @@ make_reader(FILE *file, bool owns_file, const string &magic_number) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
PNMWriter *PNMFileTypeYUV::
|
PNMWriter *PNMFileTypeYUV::
|
||||||
make_writer(FILE *file, bool owns_file) {
|
make_writer(FILE *file, bool owns_file) {
|
||||||
|
init_pnm();
|
||||||
return new Writer(this, file, owns_file);
|
return new Writer(this, file, owns_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +220,7 @@ supports_read_row() const {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
bool PNMFileTypeYUV::Reader::
|
bool PNMFileTypeYUV::Reader::
|
||||||
read_row(xel *row_data, xelval *) {
|
read_row(xel *row_data, xelval *) {
|
||||||
long tmp, y, u, v, y1, r, g, b;
|
long y, u, v, y1, r, g, b;
|
||||||
unsigned char *yuvptr;
|
unsigned char *yuvptr;
|
||||||
int col;
|
int col;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
/* Copyright (c) 1991 Regents of the University of California */
|
/* Copyright (c) 1991 Regents of the University of California */
|
||||||
|
|
||||||
#ifndef lint
|
|
||||||
static char SCCSid[] = "@(#)resolu.c 2.2 11/28/91 LBL";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read and write image resolutions.
|
* Read and write image resolutions.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user