mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -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) {
|
||||
// Even though the reduced image would not be smaller, copy it
|
||||
// anyway when force_reduced is true.
|
||||
nout << "Reading " << photo_filename << "\n";
|
||||
if (!reduced_image.read(reader)) {
|
||||
nout << "Unable to read.\n";
|
||||
photo_filename.set_binary();
|
||||
if (!copy_file(photo_filename, reduced_dir)) {
|
||||
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 {
|
||||
// We're not making a reduced version. But maybe we still
|
||||
@ -332,6 +318,7 @@ make_reduced_image(Photo *photo, PNMImage &reduced_image,
|
||||
// If the reduced image already exists and is newer than the
|
||||
// source image, use it.
|
||||
|
||||
if (!force_reduced) {
|
||||
// We still read the image header to determine its size.
|
||||
PNMImageHeader photo_image;
|
||||
if (!photo_image.read_header(photo_filename)) {
|
||||
@ -375,6 +362,7 @@ make_reduced_image(Photo *photo, PNMImage &reduced_image,
|
||||
photo->_reduced_y_size = reduced_image.get_y_size();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user