From 3339395d5b4056860e4ce44f59d6ab12e547c71e Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 6 Apr 2006 14:09:14 +0000 Subject: [PATCH] hard link if possible --- pandaapp/src/indexify/indexImage.cxx | 6 +++--- pandaapp/src/indexify/indexParameters.cxx | 25 ++++++++++++++--------- pandaapp/src/indexify/indexParameters.h | 20 ++++++++++-------- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/pandaapp/src/indexify/indexImage.cxx b/pandaapp/src/indexify/indexImage.cxx index 117482b311..e35b406f15 100644 --- a/pandaapp/src/indexify/indexImage.cxx +++ b/pandaapp/src/indexify/indexImage.cxx @@ -442,7 +442,7 @@ copy_reduced(const Filename &archive_dir) { for (pi = _photos.begin(); pi != _photos.end(); ++pi) { const PhotoInfo &pinfo = (*pi); int photo_index = pinfo._photo_index; - Photo *photo = _dir->get_photo(pinfo._photo_index); + Photo *photo = _dir->get_photo(photo_index); // Make sure we have a "reduced" image. PNMImage reduced_image; @@ -655,7 +655,7 @@ generate_reduced_html(ostream &html, Photo *photo, int photo_index, int pi, static const streampos MB = 1024 * 1024; static const streampos GB = 1024 * 1024 * 1024; string size_units; - double size_float; + double size_float = size; if (size > GB) { size_units = "GB"; @@ -699,7 +699,7 @@ generate_reduced_html(ostream &html, Photo *photo, int photo_index, int pi, static const streampos MB = 1024 * 1024; static const streampos GB = 1024 * 1024 * 1024; string size_units; - double size_float; + double size_float = size; if (size > GB) { size_units = "GB"; diff --git a/pandaapp/src/indexify/indexParameters.cxx b/pandaapp/src/indexify/indexParameters.cxx index 28d9ecf05e..164beb426e 100644 --- a/pandaapp/src/indexify/indexParameters.cxx +++ b/pandaapp/src/indexify/indexParameters.cxx @@ -19,24 +19,19 @@ #include "indexParameters.h" // User parameters -int max_index_width = 700; -int max_index_height = 700; - -int thumb_width = 150; -int thumb_height = 150; +int max_index_size_array[2] = { 700, 700 }; +int thumb_size_array[2] = { 150, 150 }; int thumb_caption_height = 12; int caption_font_size = 12; -int thumb_x_space = 12; -int thumb_y_space = 12; +int thumb_space_array[2] = { 12, 12 }; double frame_reduction_factor = 0.75; int frame_outer_bevel = 2; int frame_inner_bevel = 1; -int reduced_width = 800; -int reduced_height = 700; +int reduced_size_array[2] = { 800, 700 }; Filename archive_dir; @@ -126,7 +121,7 @@ finalize_parameters() { (max_index_width - thumb_x_space) / (thumb_width + thumb_x_space); thumb_count_y = (max_index_height - thumb_y_space) / (thumb_height + thumb_caption_height + thumb_y_space); - + max_thumbs = thumb_count_x * thumb_count_y; actual_index_width = thumb_x_space + thumb_count_x * (thumb_width + thumb_x_space); @@ -272,6 +267,16 @@ copy_file(const Filename &source_file, const Filename &dest_dir) { return false; } +#if defined(HAVE_UNISTD_H) && !defined(WIN32) + // Try to make a hard link. + string os_source_file = source_file.to_os_specific(); + string os_dest_file = dest_file.to_os_specific(); + if (link(os_source_file.c_str(), os_dest_file.c_str()) == 0) { + cerr << "Linked " << source_file << " to " << dest_file << "\n"; + return true; + } +#endif + ifstream in; if (!source_file.open_read(in)) { cerr << "Unable to read " << source_file << "\n"; diff --git a/pandaapp/src/indexify/indexParameters.h b/pandaapp/src/indexify/indexParameters.h index 92828d427d..1569e365f6 100644 --- a/pandaapp/src/indexify/indexParameters.h +++ b/pandaapp/src/indexify/indexParameters.h @@ -32,13 +32,15 @@ // fit the images it contains, and it will shrink horizontally to fit // a complete row of images (even if it does not contain a complete // row). It will never be larger than this. -extern int max_index_width; -extern int max_index_height; +extern int max_index_size_array[2]; +#define max_index_width (max_index_size_array[0]) +#define max_index_height (max_index_size_array[0]) // The size of the individual thumbnail images, including the frames // (if present). Thumbnail images are scaled to fit within this box. -extern int thumb_width; -extern int thumb_height; +extern int thumb_size_array[2]; +#define thumb_width (thumb_size_array[0]) +#define thumb_height (thumb_size_array[1]) // The total number of pixels reserved for the caption under each // thumbnail image. This is the caption_font_size plus whatever @@ -53,8 +55,9 @@ extern int caption_font_size; // The amount of space, in pixels, between each two neighboring // thumbnail images, and around the overall index image. -extern int thumb_x_space; -extern int thumb_y_space; +extern int thumb_space_array[2]; +#define thumb_x_space (thumb_space_array[0]) +#define thumb_y_space (thumb_space_array[1]) // The ratio by which the thumbnail images are reduced further when // frames are drawn, to allow room for a frame that resembles a slide @@ -68,8 +71,9 @@ extern int frame_inner_bevel; // The size of the reduced images on the individual image pages. The // source image will be scaled to fit within this rectangle. -extern int reduced_width; -extern int reduced_height; +extern int reduced_size_array[2]; +#define reduced_width (reduced_size_array[0]) +#define reduced_height (reduced_size_array[1]) // The directory at the root of the output hierarchy (or as specified // by -a on the command line).