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) {
|
} 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
|
||||||
@ -332,6 +318,7 @@ make_reduced_image(Photo *photo, PNMImage &reduced_image,
|
|||||||
// 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.
|
||||||
|
|
||||||
|
if (!force_reduced) {
|
||||||
// We still read the image header to determine its size.
|
// We still read the image header to determine its size.
|
||||||
PNMImageHeader photo_image;
|
PNMImageHeader photo_image;
|
||||||
if (!photo_image.read_header(photo_filename)) {
|
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();
|
photo->_reduced_y_size = reduced_image.get_y_size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user