mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 18:31:55 -04:00
even more options
This commit is contained in:
parent
07f576a596
commit
10ca7149ac
@ -188,7 +188,15 @@ generate_images(const Filename &archive_dir, TextMaker *text_maker) {
|
||||
photo->_full_x_size = photo_image.get_x_size();
|
||||
photo->_full_y_size = photo_image.get_y_size();
|
||||
|
||||
if (!dummy_mode && generate_index_image) {
|
||||
if (dummy_mode) {
|
||||
// In dummy mode, we may or may not actually have a reduced
|
||||
// image. In either case, ignore the file and compute its
|
||||
// appropriate size from the source image.
|
||||
compute_reduction(photo_image, reduced_image, reduced_width, reduced_height);
|
||||
photo->_reduced_x_size = reduced_image.get_x_size();
|
||||
photo->_reduced_y_size = reduced_image.get_y_size();
|
||||
|
||||
} else if (generate_index_image) {
|
||||
// Now read the reduced image from disk, so we can put it on
|
||||
// the index image.
|
||||
nout << "Reading " << reduced_filename << "\n";
|
||||
@ -241,7 +249,7 @@ generate_images(const Filename &archive_dir, TextMaker *text_maker) {
|
||||
pinfo._y_place + y_center);
|
||||
|
||||
if (text_maker != (TextMaker *)NULL) {
|
||||
text_maker->generate_into(photo->get_name(), index_image,
|
||||
text_maker->generate_into(photo->get_frame_number(), index_image,
|
||||
pinfo._x_place + thumb_width / 2,
|
||||
pinfo._y_place + thumb_height + thumb_caption_height);
|
||||
}
|
||||
@ -597,7 +605,7 @@ compose_href(const Filename &rel_dir, const Filename &user_prefix,
|
||||
// the dest_image to the computed size.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void IndexImage::
|
||||
compute_reduction(const PNMImage &source_image, PNMImage &dest_image,
|
||||
compute_reduction(const PNMImageHeader &source_image, PNMImage &dest_image,
|
||||
int x_size, int y_size) {
|
||||
double x_scale = (double)x_size / (double)source_image.get_x_size();
|
||||
double y_scale = (double)y_size / (double)source_image.get_y_size();
|
||||
|
@ -28,6 +28,7 @@ class RollDirectory;
|
||||
class Photo;
|
||||
class TextMaker;
|
||||
class PNMImage;
|
||||
class PNMImageHeader;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : IndexImage
|
||||
@ -58,7 +59,7 @@ private:
|
||||
Filename compose_href(const Filename &rel_dir, const Filename &user_prefix,
|
||||
const Filename &basename = Filename());
|
||||
|
||||
static void compute_reduction(const PNMImage &source_image,
|
||||
static void compute_reduction(const PNMImageHeader &source_image,
|
||||
PNMImage &dest_image,
|
||||
int x_size, int y_size);
|
||||
static void draw_box(PNMImage &image);
|
||||
|
@ -28,8 +28,8 @@ int thumb_height = 100;
|
||||
int thumb_caption_height = 12;
|
||||
int caption_font_size = 12;
|
||||
|
||||
int thumb_x_space = 14;
|
||||
int thumb_y_space = 14;
|
||||
int thumb_x_space = 12;
|
||||
int thumb_y_space = 12;
|
||||
|
||||
double frame_reduction_factor = 0.75;
|
||||
int frame_outer_bevel = 2;
|
||||
@ -46,6 +46,9 @@ bool force_regenerate = false;
|
||||
bool format_rose = false;
|
||||
bool dummy_mode = false;
|
||||
bool draw_frames = false;
|
||||
bool omit_roll_headers = false;
|
||||
bool caption_frame_numbers = false;
|
||||
|
||||
|
||||
// Computed parameters
|
||||
int thumb_count_x;
|
||||
|
@ -88,6 +88,16 @@ extern bool dummy_mode;
|
||||
// True to draw frames (slide mounts) around each thumbnail image.
|
||||
extern bool draw_frames;
|
||||
|
||||
// True to avoid introducing each roll directory on the index page
|
||||
// with its own little header. This also ignored the roll.cm file if
|
||||
// it exists.
|
||||
extern bool omit_roll_headers;
|
||||
|
||||
// True to caption photos with just a frame number instead of the
|
||||
// whole image basename. This only works if the photo image filenames
|
||||
// consist of the roll directory name concatenated with a frame number.
|
||||
extern bool caption_frame_numbers;
|
||||
|
||||
|
||||
void finalize_parameters();
|
||||
|
||||
|
@ -130,6 +130,12 @@ Indexify() {
|
||||
"-up are not explicitly specified.",
|
||||
&Indexify::dispatch_none, &_generate_icons);
|
||||
|
||||
add_option
|
||||
("omitrh", "", 0,
|
||||
"Omits roll headers introducing each roll directory, including any "
|
||||
"headers defined in roll.cm files.",
|
||||
&Indexify::dispatch_none, &omit_roll_headers);
|
||||
|
||||
add_option
|
||||
("caption", "size[,spacing]", 0,
|
||||
"Specifies the font size in pixels of the thumbnail captions. If the "
|
||||
@ -138,6 +144,14 @@ Indexify() {
|
||||
"-caption 0 to disable thumbnail captions.",
|
||||
&Indexify::dispatch_caption, NULL);
|
||||
|
||||
add_option
|
||||
("fnum", "", 0,
|
||||
"Writes the frame number of each thumbnail image into the caption "
|
||||
"on the index page, instead of the image filename. This only works "
|
||||
"if the photo image filenames consist of the roll directory name "
|
||||
"concatenated with a frame number.",
|
||||
&Indexify::dispatch_none, &caption_frame_numbers);
|
||||
|
||||
add_option
|
||||
("fontaa", "factor", 0,
|
||||
"Specifies a scale factor to apply to the fonts used for captioning "
|
||||
|
@ -17,6 +17,8 @@
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "photo.h"
|
||||
#include "indexParameters.h"
|
||||
#include "rollDirectory.h"
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -30,6 +32,20 @@ Photo(RollDirectory *dir, const Filename &basename) :
|
||||
_basename(basename)
|
||||
{
|
||||
_name = _basename.get_basename_wo_extension();
|
||||
_frame_number = _name;
|
||||
if (caption_frame_numbers) {
|
||||
const string &dirname = _dir->get_basename();
|
||||
|
||||
// If the initial prefix of the filename is the same as the roll
|
||||
// directory, lop it off when caption_frame_numbers is in effect.
|
||||
if (_frame_number.substr(0, dirname.length()) == dirname) {
|
||||
_frame_number = _frame_number.substr(dirname.length());
|
||||
while (_frame_number.length() > 1 && _frame_number[0] == '0') {
|
||||
_frame_number = _frame_number.substr(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_full_x_size = 0;
|
||||
_full_y_size = 0;
|
||||
_reduced_x_size = 0;
|
||||
@ -58,6 +74,19 @@ get_name() const {
|
||||
return _name;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Photo::get_frame_number
|
||||
// Access: Public
|
||||
// Description: Returns the string describing the photo within the
|
||||
// roll directory. This is usually the same string
|
||||
// reported by get_name(), but it may be just the frame
|
||||
// number if caption_frame_numbers is in effect.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
const string &Photo::
|
||||
get_frame_number() const {
|
||||
return _frame_number;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Photo::output
|
||||
// Access: Public
|
||||
|
@ -35,6 +35,7 @@ public:
|
||||
|
||||
const Filename &get_basename() const;
|
||||
const string &get_name() const;
|
||||
const string &get_frame_number() const;
|
||||
|
||||
void output(ostream &out) const;
|
||||
|
||||
@ -48,6 +49,7 @@ private:
|
||||
RollDirectory *_dir;
|
||||
Filename _basename;
|
||||
string _name;
|
||||
string _frame_number;
|
||||
};
|
||||
|
||||
INLINE ostream &operator << (ostream &out, const Photo &p) {
|
||||
|
@ -299,18 +299,20 @@ generate_html(ostream &root_html, const Filename &archive_dir,
|
||||
const Filename &roll_dir_root) {
|
||||
nassertr(!_index_images.empty(), false);
|
||||
|
||||
Filename cm_filename(_dir, _basename);
|
||||
cm_filename.set_extension("cm");
|
||||
if (cm_filename.exists()) {
|
||||
// If the comment file for the roll exists, insert its contents
|
||||
// here instead of the generic header.
|
||||
if (!insert_html_comment(root_html, cm_filename)) {
|
||||
return false;
|
||||
if (!omit_roll_headers) {
|
||||
Filename cm_filename(_dir, _basename);
|
||||
cm_filename.set_extension("cm");
|
||||
if (cm_filename.exists()) {
|
||||
// If the comment file for the roll exists, insert its contents
|
||||
// here instead of the generic header.
|
||||
if (!insert_html_comment(root_html, cm_filename)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
} else {
|
||||
root_html
|
||||
<< "<h2>" << _name << "</h2>\n";
|
||||
}
|
||||
|
||||
} else {
|
||||
root_html
|
||||
<< "<h2>" << _name << "</h2>\n";
|
||||
}
|
||||
|
||||
nout << "Generating " << Filename(archive_dir, "html/")
|
||||
|
Loading…
x
Reference in New Issue
Block a user