mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
don't read headers unnecessarily
This commit is contained in:
parent
d21af49d00
commit
741ac58078
@ -290,24 +290,10 @@ make_reduced_image(Photo *photo, PNMImage &reduced_image,
|
|||||||
} else if (force_reduced) {
|
} else if (force_reduced) {
|
||||||
// Even though the reduced image would not be smaller, copy it
|
// Even though the reduced image would not be smaller, copy it
|
||||||
// anyway when force_reduced is true.
|
// anyway when force_reduced is true.
|
||||||
nout << "Reading " << photo_filename << "\n";
|
photo_filename.set_binary();
|
||||||
if (!reduced_image.read(reader)) {
|
if (!copy_file(photo_filename, reduced_dir)) {
|
||||||
nout << "Unable to read.\n";
|
return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
reader = NULL;
|
|
||||||
|
|
||||||
reduced_filename.make_dir();
|
|
||||||
nout << "Writing " << reduced_filename << "\n";
|
|
||||||
if (!reduced_image.write(reduced_filename)) {
|
|
||||||
nout << "Unable to write.\n";
|
|
||||||
delete reader;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
photo->_has_reduced = true;
|
|
||||||
|
|
||||||
photo->_reduced_x_size = reduced_image.get_x_size();
|
|
||||||
photo->_reduced_y_size = reduced_image.get_y_size();
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// We're not making a reduced version. But maybe we still
|
// We're not making a reduced version. But maybe we still
|
||||||
@ -331,48 +317,50 @@ make_reduced_image(Photo *photo, PNMImage &reduced_image,
|
|||||||
} else {
|
} else {
|
||||||
// If the reduced image already exists and is newer than the
|
// If the reduced image already exists and is newer than the
|
||||||
// source image, use it.
|
// source image, use it.
|
||||||
|
|
||||||
// We still read the image header to determine its size.
|
if (!force_reduced) {
|
||||||
PNMImageHeader photo_image;
|
// We still read the image header to determine its size.
|
||||||
if (!photo_image.read_header(photo_filename)) {
|
PNMImageHeader photo_image;
|
||||||
nout << "Unable to read " << photo_filename << "\n";
|
if (!photo_image.read_header(photo_filename)) {
|
||||||
return false;
|
nout << "Unable to read " << photo_filename << "\n";
|
||||||
}
|
return false;
|
||||||
|
|
||||||
photo->_full_x_size = photo_image.get_x_size();
|
|
||||||
photo->_full_y_size = photo_image.get_y_size();
|
|
||||||
photo->_has_reduced = true;
|
|
||||||
|
|
||||||
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";
|
|
||||||
|
|
||||||
if (!reduced_image.read(reduced_filename)) {
|
|
||||||
nout << "Unable to read.\n";
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
photo->_reduced_x_size = reduced_image.get_x_size();
|
photo->_full_x_size = photo_image.get_x_size();
|
||||||
photo->_reduced_y_size = reduced_image.get_y_size();
|
photo->_full_y_size = photo_image.get_y_size();
|
||||||
|
photo->_has_reduced = true;
|
||||||
|
|
||||||
} else {
|
if (dummy_mode) {
|
||||||
// If we're not generating an index image, we don't even need
|
// In dummy mode, we may or may not actually have a reduced
|
||||||
// the reduced image--just scan its header to get its size.
|
// image. In either case, ignore the file and compute its
|
||||||
if (!reduced_image.read_header(reduced_filename)) {
|
// appropriate size from the source image.
|
||||||
nout << "Unable to read " << reduced_filename << "\n";
|
compute_reduction(photo_image, reduced_image, reduced_width, reduced_height);
|
||||||
return false;
|
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";
|
||||||
|
|
||||||
|
if (!reduced_image.read(reduced_filename)) {
|
||||||
|
nout << "Unable to read.\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
photo->_reduced_x_size = reduced_image.get_x_size();
|
||||||
|
photo->_reduced_y_size = reduced_image.get_y_size();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// If we're not generating an index image, we don't even need
|
||||||
|
// the reduced image--just scan its header to get its size.
|
||||||
|
if (!reduced_image.read_header(reduced_filename)) {
|
||||||
|
nout << "Unable to read " << reduced_filename << "\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
photo->_reduced_x_size = reduced_image.get_x_size();
|
||||||
|
photo->_reduced_y_size = reduced_image.get_y_size();
|
||||||
}
|
}
|
||||||
photo->_reduced_x_size = reduced_image.get_x_size();
|
|
||||||
photo->_reduced_y_size = reduced_image.get_y_size();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user