Hello! I did not see (or perhaps I overlooked) a simple graphics image viewer applet in TC base or in the TCE/TCZ appbrowser, so I coded up one in FLTK.
This program's executable is tiny (> 6K!
) and loads images really fast. It supports:
* .JPG / JPEG
* .GIF
* .PNG
* .BMP
* .XBM
* .XPM
It can be also launced from the command line. Assuming it is placed in /usr/local/bin, or some other place in the search path, simply invoke:
# fl_picsee {{filename, which may include path}}
It works well with Rox-Filer if you set the run action to launch it. In Rox, right-click, select "Set Run Action...", then put something like the following in the "Enter a shell command" text field:
/usr/local/bin/fl_picsee "$@"
Downsides? It does not support scrolling and will not resize the image if it is too big to see on your screen. The full path and file name in the title will be clipped if the window title bar is not long enough (especially true for small images), and the window maximizing button does not really work. As I learn more about FLTK, I will try to address these shortcomings.
This 0.8.0 version is an alpha release only. I have not learned fully how to make a .tce or .tcz distribution, so I am posting the GPL source code. Perhaps Jason can package it for me once until I learn how to do it myself. Or if given permission, I can attach the binary directly.
This requires the 1.1 version of FLTK, which is standard in TC 1.3 (and earlier, I assume).
Please address bug reports and and comments to this thread. Hope you like it!
Source Code (EDIT, updated to version 0.8.1, which has some modifications to handle filenames that are too short or too long):
// fl_picsee -- A FLTK-based picture viewer
#define appver "0.8.1"
/* -------------------------------------------------------
Copyright 2009 Michael A. Losh
"FLTK Picture-See" (also known as "fl_picsee") is free software:
you can redistribute it and/or modify it under the terms of
the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
FLTK Picture-See 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with FLTK Picture-See. If not, see <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <FL/Fl.H>
#include <FL/fl_ask.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Shared_Image.H>
#include <FL/Fl_BMP_Image.H>
#include <FL/Fl_GIF_Image.H>
#include <FL/Fl_JPEG_Image.H>
#include <FL/Fl_PNG_Image.H>
#include <FL/Fl_XBM_Image.H>
#include <FL/Fl_XPM_Image.H>
#include <FL/Fl_Box.H>
int main(int argc, char** argv) {
int h, w;
int len = 0;
Fl_Image * fi_p = NULL;
char title[128] = "";
char filename[256];
char ext[8];
fl_register_images(); // initialize image lib
if (argc > 1) {
memset(filename, 0, 256);
strncpy(filename, argv[1], 255);
len = strlen(filename);
}
if (len > 4) {
printf("Loading image '%s'\n", filename);
sprintf(title, "%120s - FLTK Picture-See %s", filename, appver);
ext[0] = toupper(filename[len - 4]);
ext[1] = toupper(filename[len - 3]);
ext[2] = toupper(filename[len - 2]);
ext[3] = toupper(filename[len - 1]);
ext[4] = 0;
printf("File type appears to be '%s'\n", ext);
if (!strcmp(ext, ".JPG") || !strcmp(ext, "JPEG")) {
fi_p = new Fl_JPEG_Image(argv[1]);
}
else if (!strcmp(ext, ".PNG")) {
fi_p = new Fl_PNG_Image(argv[1]);
}
else if (!strcmp(ext, ".BMP")) {
fi_p = new Fl_BMP_Image(argv[1]);
}
else if (!strcmp(ext, ".GIF")) {
fi_p = new Fl_GIF_Image(argv[1]);
}
else if (!strcmp(ext, ".XBM")) {
fi_p = new Fl_XBM_Image(argv[1]);
}
else if (!strcmp(ext, ".XPM")) {
fi_p = new Fl_XPM_Image(argv[1]);
}
else {
fl_alert("File with name ending '%s' is not a known type. FLTK Picture-See will exit.\n", ext);
return -1;
}
h = fi_p->h();
if (h < 80) h = 80;
w = fi_p->w();
if (w < 120) w = 120;
Fl_Window win(w + 24, h + 24, title);
Fl_Box box(10,10, w + 2, h + 2);
box.image(fi_p);
win.show();
return(Fl::run());
}
}
--
Mike "Lockmoore" Losh