Revision: 76451
http://sourceforge.net/p/brlcad/code/76451
Author: starseeker
Date: 2020-07-23 20:04:19 +0000 (Thu, 23 Jul 2020)
Log Message:
-----------
Cherrypick r75565 and r75566 - fix for bw-png on Windows
Modified Paths:
--------------
brlcad/branches/RELEASE/NEWS
brlcad/branches/RELEASE/TODO
brlcad/branches/RELEASE/src/util/bw-png.c
Property Changed:
----------------
brlcad/branches/RELEASE/
brlcad/branches/RELEASE/NEWS
Index: brlcad/branches/RELEASE
===================================================================
--- brlcad/branches/RELEASE 2020-07-23 19:58:35 UTC (rev 76450)
+++ brlcad/branches/RELEASE 2020-07-23 20:04:19 UTC (rev 76451)
Property changes on: brlcad/branches/RELEASE
___________________________________________________________________
Modified: svn:mergeinfo
## -6,4 +6,4 ##
/brlcad/branches/opencl:65867-66137
/brlcad/branches/osg:62110-62113
/brlcad/branches/prep-cache:68236-68933
-/brlcad/trunk:36844-37285,37571-38764,38777-38845,41559-43155,43159-43908,44241-44324,44326-44385,44710-45373,45377,45379-47342,47370-68122,68125-74976,74981,74991,75000,75056,75063-75064,75077-75078,75084,75325,75375,75377-75378,75387,75470-75472,75477,75492,75495,75549,75656-75661,75672,75675,75678,75811
\ No newline at end of property
+/brlcad/trunk:36844-37285,37571-38764,38777-38845,41559-43155,43159-43908,44241-44324,44326-44385,44710-45373,45377,45379-47342,47370-68122,68125-74976,74981,74991,75000,75056,75063-75064,75077-75078,75084,75325,75375,75377-75378,75387,75470-75472,75477,75492,75495,75549,75565-75566,75656-75661,75672,75675,75678,75811
\ No newline at end of property
Modified: brlcad/branches/RELEASE/NEWS
===================================================================
--- brlcad/branches/RELEASE/NEWS 2020-07-23 19:58:35 UTC (rev 76450)
+++ brlcad/branches/RELEASE/NEWS 2020-07-23 20:04:19 UTC (rev 76451)
@@ -15,6 +15,7 @@
* added 3dm-g failure message about supported versions - Cliff Yapp
* fixed MGED "in" command support for datums - Sean Morrison
+* fixed bw-png writing corrupted png files on Windows - Sean Morrison
----------------------------------------------------------------------
Property changes on: brlcad/branches/RELEASE/NEWS
___________________________________________________________________
Modified: svn:mergeinfo
## -7,4 +7,4 ##
/brlcad/branches/osg/NEWS:62110-62113
/brlcad/branches/prep-cache/NEWS:68236-68933
/brlcad/trunk:68170-68252
-/brlcad/trunk/NEWS:36844-37285,37571-38764,38777-38845,41559-43155,43159-43908,44241-44324,44326-44385,44710-45373,45377,45379-47342,47370-68122,68125-74373,74376-74976,75056,75375,75377-75378,75811
\ No newline at end of property
+/brlcad/trunk/NEWS:36844-37285,37571-38764,38777-38845,41559-43155,43159-43908,44241-44324,44326-44385,44710-45373,45377,45379-47342,47370-68122,68125-74373,74376-74976,75056,75375,75377-75378,75565-75566,75811
\ No newline at end of property
Modified: brlcad/branches/RELEASE/TODO
===================================================================
--- brlcad/branches/RELEASE/TODO 2020-07-23 19:58:35 UTC (rev 76450)
+++ brlcad/branches/RELEASE/TODO 2020-07-23 20:04:19 UTC (rev 76451)
@@ -131,6 +131,10 @@
THESE ARE UNSCHEDULED BACKLOG TASKS
-----------------------------------
+* audit/fix all of the src/util and src/fb utilities to ensure they
+ set binary mode (setmode O_BINARY) when writing out files. at quick
+ glance, there are many (about 50) that still do not.
+
* replace los references/terminology with span, len, dist, factor, etc
accordingly since los is ambiguous and a source of user confusion.
Modified: brlcad/branches/RELEASE/src/util/bw-png.c
===================================================================
--- brlcad/branches/RELEASE/src/util/bw-png.c 2020-07-23 19:58:35 UTC (rev
76450)
+++ brlcad/branches/RELEASE/src/util/bw-png.c 2020-07-23 20:04:19 UTC (rev
76451)
@@ -112,6 +112,7 @@
unsigned char **rows;
png_structp png_p;
png_infop info_p;
+ FILE *outfp = stdout;
if (!get_args(argc, argv)) {
(void)fputs(usage, stderr);
@@ -129,6 +130,13 @@
}
}
+ setmode(fileno(outfp), O_BINARY);
+
+ if (isatty(fileno(outfp))) {
+ fprintf(stderr, "cv: trying to send binary output to terminal\n");
+ return 5;
+ }
+
png_p = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png_p)
bu_exit(EXIT_FAILURE, "Could not create PNG write structure\n");
@@ -149,7 +157,7 @@
if (fread(scanbuf, SIZE, 1, infp) != 1)
bu_exit(EXIT_FAILURE, "bw-png: Short read\n");
- png_init_io(png_p, stdout);
+ png_init_io(png_p, outfp);
png_set_filter(png_p, 0, PNG_FILTER_NONE);
png_set_compression_level(png_p, 9);
png_set_IHDR(png_p, info_p, file_width, file_height, 8,
@@ -159,6 +167,10 @@
png_write_info(png_p, info_p);
png_write_image(png_p, rows);
png_write_end(png_p, NULL);
+
+ if (outfp != stdout)
+ fclose(outfp);
+
return 0;
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits