Revision: 68889
          http://sourceforge.net/p/brlcad/code/68889
Author:   bob1961
Date:     2016-09-22 18:55:44 +0000 (Thu, 22 Sep 2016)
Log Message:
-----------
Forgot to add png2fb.c

Modified Paths:
--------------
    brlcad/trunk/src/libtclcad/tclcad_obj.c

Added Paths:
-----------
    brlcad/trunk/src/libged/png2fb.c

Added: brlcad/trunk/src/libged/png2fb.c
===================================================================
--- brlcad/trunk/src/libged/png2fb.c                            (rev 0)
+++ brlcad/trunk/src/libged/png2fb.c    2016-09-22 18:55:44 UTC (rev 68889)
@@ -0,0 +1,184 @@
+/*                        P N G - F B . C
+ * BRL-CAD
+ *
+ * Copyright (c) 1998-2016 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ *
+ */
+/** @file png-fb.c
+ *
+ * Program to take PNG (Portable Network Graphics) files and send them to a 
framebuffer.
+ *
+ */
+
+#include "common.h"
+
+#include <stdlib.h>
+
+#include "bio.h"
+#include "bu/getopt.h"
+#include "ged.h"
+
+static int multiple_lines = 0; /* Streamlined operation */
+
+static char *file_name;
+static FILE *fp_in;
+
+static int file_xoff=0, file_yoff=0;
+static int scr_xoff=0, scr_yoff=0;
+static int clear = 0;
+static int zoom = 0;
+static int inverse = 0;                /* Draw upside-down */
+static int one_line_only = 0;  /* insist on 1-line writes */
+static int verbose = 0;
+static int header_only = 0;
+
+static double def_screen_gamma=1.0;    /* Don't add more gamma, by default */
+/* Particularly because on SGI, the system provides gamma correction,
+ * so programs like this one don't have to.
+ */
+
+static char usage[] = "\
+Usage: png2fb [-H -i -c -v -z -1] [-m #lines]\n\
+       [-g screen_gamma]\n\
+       [-x file_xoff] [-y file_yoff] [-X scr_xoff] [-Y scr_yoff]\n\
+       [-S squarescrsize] [file.png]\n";
+
+int
+get_args(int argc, char **argv)
+{
+    int c;
+
+    bu_optind = 1;
+    while ((c = bu_getopt(argc, argv, "1m:g:HicvzF:x:y:X:Y:S:W:N:h?")) != -1) {
+       switch (c) {
+           case '1':
+               one_line_only = 1;
+               break;
+           case 'm':
+               multiple_lines = atoi(bu_optarg);
+               break;
+           case 'g':
+               def_screen_gamma = atof(bu_optarg);
+               break;
+           case 'H':
+               header_only = 1;
+               break;
+           case 'i':
+               inverse = 1;
+               break;
+           case 'c':
+               clear = 1;
+               break;
+           case 'v':
+               verbose = 1;
+               break;
+           case 'z':
+               zoom = 1;
+               break;
+           case 'x':
+               file_xoff = atoi(bu_optarg);
+               break;
+           case 'y':
+               file_yoff = atoi(bu_optarg);
+               break;
+           case 'X':
+               scr_xoff = atoi(bu_optarg);
+               break;
+           case 'Y':
+               scr_yoff = atoi(bu_optarg);
+               break;
+           default:            /* '?''h' */
+               return 0;
+       }
+    }
+
+    if (bu_optind >= argc) {
+       if (isatty(fileno(stdin)))
+           return 0;
+       file_name = "-";
+       fp_in = stdin;
+       setmode(fileno(fp_in), O_BINARY);
+    } else {
+       file_name = argv[bu_optind];
+       if ((fp_in = fopen(file_name, "rb")) == NULL) {
+           perror(file_name);
+           fprintf(stderr,
+                   "png-fb: cannot open \"%s\" for reading\n",
+                   file_name);
+           return 0;
+       }
+    }
+
+    if (argc > ++bu_optind)
+       fprintf(stderr, "png-fb: excess argument(s) ignored\n");
+
+    return 1;          /* OK */
+}
+
+
+int
+ged_png2fb(struct ged *gedp, int argc, const char *argv[])
+{
+    int ret;
+
+    GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR);
+    GED_CHECK_FBSERV(gedp, GED_ERROR);
+    GED_CHECK_FBSERV_FBP(gedp, GED_ERROR);
+    GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR);
+
+    /* initialize result */
+    bu_vls_trunc(gedp->ged_result_str, 0);
+
+    /* must be wanting help */
+    if (argc == 1) {
+       bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage);
+       return GED_HELP;
+    }
+
+    if (!get_args(argc, (char **)argv)) {
+       bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage);
+       return GED_HELP;
+    }
+
+    ret = fb_read_png(gedp->ged_fbsp->fbs_fbp, fp_in,
+                     file_xoff, file_yoff,
+                     scr_xoff, scr_yoff,
+                     clear, zoom, inverse,
+                     one_line_only, multiple_lines,
+                     verbose, header_only,
+                     def_screen_gamma,
+                     gedp->ged_result_str);
+
+    if (fp_in != stdin)
+       fclose(fp_in);
+
+    if (ret == BRLCAD_OK)
+       return GED_OK;
+
+    return GED_ERROR;
+}
+
+
+/*
+ * Local Variables:
+ * mode: C
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * c-file-style: "stroustrup"
+ * End:
+ * ex: shiftwidth=4 tabstop=8
+ */


Property changes on: brlcad/trunk/src/libged/png2fb.c
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: brlcad/trunk/src/libtclcad/tclcad_obj.c
===================================================================
--- brlcad/trunk/src/libtclcad/tclcad_obj.c     2016-09-22 15:37:15 UTC (rev 
68888)
+++ brlcad/trunk/src/libtclcad/tclcad_obj.c     2016-09-22 18:55:44 UTC (rev 
68889)
@@ -1247,7 +1247,7 @@
     {"pix",    "file", TO_UNLIMITED, to_pix, GED_FUNC_PTR_NULL},
     {"png",    "file", TO_UNLIMITED, to_png, GED_FUNC_PTR_NULL},
 #endif
-    /*{"png2fb",       "[options] [file.png]", TO_UNLIMITED, to_view_func, 
ged_png2fb},*/
+    {"png2fb",         "[options] [file.png]", TO_UNLIMITED, to_view_func, 
ged_png2fb},
     {"pngwf",  "[options] file.png", 16, to_view_func, ged_png},
     {"poly_circ_mode", "x y", TO_UNLIMITED, to_poly_circ_mode, 
GED_FUNC_PTR_NULL},
     {"poly_cont_build",        "x y", TO_UNLIMITED, to_poly_cont_build, 
GED_FUNC_PTR_NULL},

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
_______________________________________________
BRL-CAD Source Commits mailing list
brlcad-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to