mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
add -2
This commit is contained in:
parent
161e2cd5b3
commit
679e73b012
@ -30,6 +30,13 @@ ImageInfo() {
|
||||
set_program_description
|
||||
("This program reads the headers of a series of one or more "
|
||||
"image files and reports the image sizes to standard output.");
|
||||
|
||||
add_option
|
||||
("2", "", 0,
|
||||
"Report only images that have a non-power-of-two size in either "
|
||||
"dimension. Images whose dimensions are both a power of two will "
|
||||
"not be mentioned.",
|
||||
&ImageInfo::dispatch_none, &_report_power_2, NULL);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -52,9 +59,13 @@ run() {
|
||||
}
|
||||
} else {
|
||||
// Successfully read the image header.
|
||||
nout << filename << ": " << header.get_x_size() << " x "
|
||||
<< header.get_y_size() << " x " << header.get_num_channels()
|
||||
<< " (maxval = " << header.get_maxval() << ")\n";
|
||||
if (!_report_power_2 ||
|
||||
!is_power_2(header.get_x_size()) ||
|
||||
!is_power_2(header.get_y_size())) {
|
||||
nout << filename << ": " << header.get_x_size() << " x "
|
||||
<< header.get_y_size() << " x " << header.get_num_channels()
|
||||
<< " (maxval = " << header.get_maxval() << ")\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -78,6 +89,17 @@ handle_args(ProgramBase::Args &args) {
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ImageInfo::is_power_2
|
||||
// Access: Private
|
||||
// Description: Returns true if the indicated value is a power of 2,
|
||||
// false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool ImageInfo::
|
||||
is_power_2(int value) const {
|
||||
return (value & (value - 1)) == 0;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
// A call to pystub() to force libpystub.so to be linked in.
|
||||
|
@ -38,7 +38,11 @@ public:
|
||||
protected:
|
||||
virtual bool handle_args(Args &args);
|
||||
|
||||
private:
|
||||
bool is_power_2(int value) const;
|
||||
|
||||
Args _filenames;
|
||||
bool _report_power_2;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user