*** empty log message ***

This commit is contained in:
David Rose 2000-11-09 21:14:02 +00:00
parent 173d6df423
commit 5e2c066e84
18 changed files with 109 additions and 70 deletions

View File

@ -1026,9 +1026,10 @@ rotate_mat(NumType angle, LVecBase3<NumType> axis,
}
// Normalize the axis.
NumType length = axis.dot(axis);
nassertr(length != 0.0, ident_mat());
axis /= length;
NumType length2 = axis.dot(axis);
// Cannot rotate about a zero-length axis.
nassertr(length2 != 0.0, ident_mat());
axis /= csqrt(length2);
double s = sin(deg_2_rad(angle));
double c = cos(deg_2_rad(angle));

View File

@ -144,10 +144,10 @@ init_pnm() {
pm_init(&argc, argv);
// Now deallocate all the stuff we just allocated.
for (i = 0; i < argc; i++) {
delete[] argv[i];
}
// We can delete the argv array itself, but we cannot free the
// results of the strdup() calls we just made, since the pnm
// library might keep pointers to it. But this is a one-time
// leak.
delete[] argv;
}
}

View File

@ -1,9 +1,5 @@
/* 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.
*
@ -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 */
{
register int i, j, beg, cnt;
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);
/* put magic header */
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);
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 */
{
register int i, j;
int code, val;
/* determine scanline type */
if (len < MINELEN | len > MAXELEN)
if (len < MINELEN || len > MAXELEN)
return(oldreadcolrs(scanline, len, fp));
if ((i = getc(fp)) == EOF)
return(-1);
@ -177,7 +173,7 @@ int oldreadcolrs(register COLR *scanline, int len, register FILE *fp)
/* write out a scanline */
fwritescan(register COLOR *scanline, int len, FILE *fp)
int fwritescan(register COLOR *scanline, int len, FILE *fp)
{
COLR *clrscan;
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 */
{
register COLR *clrscan;

View File

@ -1,9 +1,5 @@
/* 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
*/
@ -33,7 +29,7 @@ extern double pow(double, double);
#endif
setcolrcor(double (*f)(double, double), double a2)
int setcolrcor(double (*f)(double, double), double a2)
/* set brightness correction */
{
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 */
{
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)
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 */
{
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 */
{
register int nexpo;
if (g_mant == NULL | g_nexp == NULL)
if (g_mant == NULL || g_nexp == NULL)
return(-1);
while (len-- > 0) {
nexpo = g_nexp[scan[0][RED]];

View File

@ -1,9 +1,5 @@
/* 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.
*
@ -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) */
{
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 */
{
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) */
{
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? */
{
return(formatval(NULL, s));
@ -211,6 +211,7 @@ copymatch(char *pat, char *str)
* if fout is not NULL.
*/
int
checkheader(FILE *fin, char *fmt, FILE *fout)
{
struct check cdat;

View File

@ -82,6 +82,7 @@ get_suggested_extension() const {
////////////////////////////////////////////////////////////////////
PNMReader *PNMFileTypeAlias::
make_reader(FILE *file, bool owns_file, const string &magic_number) {
init_pnm();
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::
make_writer(FILE *file, bool owns_file) {
init_pnm();
return new Writer(this, file, owns_file);
}

View File

@ -101,6 +101,7 @@ matches_magic_number(const string &magic_number) const {
////////////////////////////////////////////////////////////////////
PNMReader *PNMFileTypeBMP::
make_reader(FILE *file, bool owns_file, const string &magic_number) {
init_pnm();
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::
make_writer(FILE *file, bool owns_file) {
init_pnm();
return new Writer(this, file, owns_file);
}

View File

@ -31,8 +31,11 @@ extern "C" {
* without express or implied warranty.
*
* $Log$
* Revision 1.1 2000/10/04 01:14:42 drose
* Initial revision
* Revision 1.2 2000/11/09 21:14:02 drose
* *** 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
* 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));
static int BMPreadrgbtable ARGS((FILE *fp, unsigned long *ppos,
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 char er_read[] = "%s: read error";
static char er_seek[] = "%s: seek error";
//static char er_seek[] = "%s: seek error";
static int
GetByte(FILE *fp)
@ -500,7 +498,7 @@ Reader(PNMFileType *type, FILE *file, bool owns_file, string magic_number) :
indexed = true;
rc = BMPreadrgbtable(file, &pos, cBitCount, classv, R, G, B);
if (rc != BMPlenrgbtable(classv, cBitCount)) {
if (rc != (int)BMPlenrgbtable(classv, cBitCount)) {
pnmimage_bmp_cat.warning()
<< rc << "-byte RGB table, expected "
<< BMPlenrgbtable(classv, cBitCount) << " bytes\n";

View File

@ -35,8 +35,11 @@ extern "C" {
* without express or implied warranty.
*
* $Log$
* Revision 1.1 2000/10/04 01:14:42 drose
* Initial revision
* Revision 1.2 2000/11/09 21:14:02 drose
* *** 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
* 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 BMPwritergbtable ARGS((FILE *fp, int classv, int bpp, int colors,
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 void BMPEncode ARGS((FILE *fp, int classv, int x, int y, pixel **pixels,
int colors, colorhash_table cht, pixval *R, pixval *G, pixval *B));

View File

@ -82,6 +82,7 @@ get_suggested_extension() const {
////////////////////////////////////////////////////////////////////
PNMReader *PNMFileTypeIMG::
make_reader(FILE *file, bool owns_file, const string &magic_number) {
init_pnm();
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::
make_writer(FILE *file, bool owns_file) {
init_pnm();
return new Writer(this, file, owns_file);
}

View File

@ -112,6 +112,7 @@ matches_magic_number(const string &magic_number) const {
////////////////////////////////////////////////////////////////////
PNMReader *PNMFileTypePNM::
make_reader(FILE *file, bool owns_file, const string &magic_number) {
init_pnm();
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::
make_writer(FILE *file, bool owns_file) {
init_pnm();
return new Writer(this, file, owns_file);
}
@ -284,6 +286,9 @@ write_header() {
case PNMImageHeader::CT_four_channel:
_pnm_format = PPM_TYPE;
break;
default:
break;
}
pnm_writepnminit(_file, _x_size, _y_size, _maxval, _pnm_format, 0);

View File

@ -121,6 +121,7 @@ matches_magic_number(const string &magic_number) const {
////////////////////////////////////////////////////////////////////
PNMReader *PNMFileTypeRadiance::
make_reader(FILE *file, bool owns_file, const string &magic_number) {
init_pnm();
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::
make_writer(FILE *file, bool owns_file) {
init_pnm();
return new Writer(this, file, owns_file);
}

View File

@ -105,6 +105,7 @@ matches_magic_number(const string &magic_number) const {
////////////////////////////////////////////////////////////////////
PNMReader *PNMFileTypeSGI::
make_reader(FILE *file, bool owns_file, const string &magic_number) {
init_pnm();
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::
make_writer(FILE *file, bool owns_file) {
init_pnm();
return new Writer(this, file, owns_file);
}

View File

@ -48,7 +48,7 @@ static void * xmalloc (int bytes);
#define MALLOC(n, type) (type *)xmalloc((n) * sizeof(type))
static char * compression_name (char compr);
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 void read_channel (FILE *ifp, int xsize, int ysize,
int zsize, int bpc, TabEntry *table,
@ -91,7 +91,9 @@ Reader(PNMFileType *type, FILE *file, bool owns_file, string magic_number) :
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;
if( pixmax > PNM_MAXMAXVAL ) {
@ -115,7 +117,7 @@ Reader(PNMFileType *type, FILE *file, bool owns_file, string magic_number) :
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 */
pnmimage_sgi_cat.debug()
<< "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) {
nassertv(magic_number.size() == 4);
nassertr(magic_number.size() == 4, false);
head->magic =
((unsigned char)magic_number[0] << 8) |
((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);
read_bytes(ifp, 404, head->dummy2);
if( head->magic != SGI_MAGIC )
pm_error("bad magic number - not an SGI image");
if( head->storage != 0 && head->storage != 1 )
pm_error("unknown compression type");
if( head->bpc < 1 || head->bpc > 2 )
pm_error("illegal precision value %d (only 1-2 allowed)", head->bpc );
if( head->colormap != CMAP_NORMAL )
pm_message("unsupported non-normal pixel data (%d)",
head->colormap);
if (head->magic != SGI_MAGIC) {
pnmimage_sgi_cat.error()
<< "Invalid magic number: not an SGI image file.\n";
return false;
}
if (head->storage != 0 && head->storage != 1) {
pnmimage_sgi_cat.error()
<< "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 */
switch( head->dimension ) {
@ -262,14 +278,20 @@ read_header(FILE *ifp, Header *head, const string &magic_number) {
break;
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;
break;
}
break;
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;
}

View File

@ -277,6 +277,7 @@ matches_magic_number(const string &magic_number) const {
////////////////////////////////////////////////////////////////////
PNMReader *PNMFileTypeSoftImage::
make_reader(FILE *file, bool owns_file, const string &magic_number) {
init_pnm();
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::
make_writer(FILE *file, bool owns_file) {
init_pnm();
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);
_y_size = read_ushort(_file);
float ratio = read_float(_file);
int fields = read_ushort(_file);
/* float ratio = */ read_float(_file);
/* int fields = */ read_ushort(_file);
read_ushort(_file);
int chained, size, channel;
@ -464,8 +466,11 @@ read_row(xel *row_data, xelval *alpha_data) {
return false;
}
break;
default:
break;
}
return true;
}

View File

@ -199,6 +199,7 @@ matches_magic_number(const string &magic_number) const {
////////////////////////////////////////////////////////////////////
PNMReader *PNMFileTypeTIFF::
make_reader(FILE *file, bool owns_file, const string &magic_number) {
init_pnm();
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::
make_writer(FILE *file, bool owns_file) {
init_pnm();
return new Writer(this, file, owns_file);
}
@ -608,6 +610,9 @@ write_data(xel *array, xelval *alpha) {
chv = (colorhist_vector) 0;
grayscale = true;
break;
default:
break;
}
/* Open output file. */
@ -651,6 +656,9 @@ write_data(xel *array, xelval *alpha) {
i = 8 / bitspersample;
bytesperrow = ( _x_size + i - 1 ) / i;
break;
default:
break;
}
if ( tiff_rowsperstrip == 0 )

View File

@ -125,6 +125,7 @@ get_suggested_extension() const {
////////////////////////////////////////////////////////////////////
PNMReader *PNMFileTypeYUV::
make_reader(FILE *file, bool owns_file, const string &magic_number) {
init_pnm();
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::
make_writer(FILE *file, bool owns_file) {
init_pnm();
return new Writer(this, file, owns_file);
}
@ -218,7 +220,7 @@ supports_read_row() const {
////////////////////////////////////////////////////////////////////
bool PNMFileTypeYUV::Reader::
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;
int col;

View File

@ -1,9 +1,5 @@
/* 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.
*/