Revision: 56314
http://sourceforge.net/p/brlcad/code/56314
Author: brlcad
Date: 2013-07-30 04:59:41 +0000 (Tue, 30 Jul 2013)
Log Message:
-----------
icv_image_save() cannot fail to do what it's told or we'll have to update all
possible caller code to have pix fallback recovery code. no reason that cannot
happen here. guess the format, but use PIX for anything unrecognized. note
some bad fixed-size buffer assumptions already getting introduced.
Modified Paths:
--------------
brlcad/trunk/src/libicv/fileformat.c
Modified: brlcad/trunk/src/libicv/fileformat.c
===================================================================
--- brlcad/trunk/src/libicv/fileformat.c 2013-07-30 04:55:38 UTC (rev
56313)
+++ brlcad/trunk/src/libicv/fileformat.c 2013-07-30 04:59:41 UTC (rev
56314)
@@ -84,6 +84,11 @@
* extension as well.
*
* I suck. I'll fix this later. Honest.
+ *
+ * FIXME: assuming trimmedname is BUFSIZ is a crash waiting to bite
+ * someone down the road. should pass a size or use a vls or have it
+ * return the string as as return type (making the int type be an int*
+ * argument instead that gets set).
*/
int
icv_guess_file_format(const char *filename, char *trimmedname)
@@ -428,20 +433,11 @@
int
icv_image_save(icv_image_t* bif, const char* filename, ICV_IMAGE_FORMAT format)
{
- char buf[BUFSIZ];
- ICV_IMAGE_FORMAT guess_format; /**< Needed to guess the image format */
+ char buf[BUFSIZ] = {0};
- if (format == ICV_IMAGE_AUTO || ICV_IMAGE_AUTO_NO_PIX) {
- guess_format = icv_guess_file_format(filename, buf);
- if(guess_format == ICV_IMAGE_UNKNOWN) {
- if (format == ICV_IMAGE_AUTO_NO_PIX) {
- bu_log("icv_image_save : Error Recognizing ICV format\n");
- return 0;
- } else
- format = ICV_IMAGE_PIX;
- } else
- format = guess_format;
- }
+ if (format == ICV_IMAGE_AUTO || format == ICV_IMAGE_AUTO_NO_PIX) {
+ format = icv_guess_file_format(filename, buf);
+ }
switch(format) {
/* case ICV_IMAGE_BMP:
@@ -450,15 +446,14 @@
return ppm_save(bif, filename);
case ICV_IMAGE_PNG:
return png_save(bif, filename);
- case ICV_IMAGE_PIX :
+ case ICV_IMAGE_PIX:
return pix_save(bif, filename);
- case ICV_IMAGE_BW :
+ case ICV_IMAGE_BW:
return bw_save(bif, filename);
- default :
- bu_log("icv_image_save : Format not implemented\n");
- return 0;
+ default:
+ bu_log("Unrecognized format. Outputting in PIX format.\n");
+ return pix_save(bif, filename);
}
-
}
int
icv_image_writeline(icv_image_t *bif, int y, void *data, ICV_DATA type)
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent
caught up. So what steps can you take to put your SQL databases under
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits